DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Package Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.TableEventRegistry Class Reference
Inheritance diagram for Deveel.Data.TableEventRegistry:

Public Member Functions

IEnumerator< ITableEventGetEnumerator ()
 
ITableEvent GetEvent (int index)
 

Package Functions

 TableEventRegistry (TableSource tableSource)
 
void Rollback (int count)
 
void Register (ITableEvent tableEvent)
 
void TestCommitClash (TableInfo tableInfo, TableEventRegistry journal)
 

Properties

TableSource TableSource [get, private set]
 
int TableId [get]
 
long CommitId [get, set]
 
IEnumerable< int > AddedRows [get]
 
IEnumerable< int > RemovedRows [get]
 
int EventCount [get]
 

Private Member Functions

IEnumerator IEnumerable. GetEnumerator ()
 

Private Attributes

readonly List< ITableEventevents
 

Detailed Description

Definition at line 27 of file TableEventRegistry.cs.

Constructor & Destructor Documentation

Deveel.Data.TableEventRegistry.TableEventRegistry ( TableSource  tableSource)
inlinepackage

Definition at line 30 of file TableEventRegistry.cs.

30  {
31  if (tableSource == null)
32  throw new ArgumentNullException("tableSource");
33 
34  TableSource = tableSource;
35  CommitId = -1;
36 
37  events = new List<ITableEvent>();
38  }
readonly List< ITableEvent > events

Member Function Documentation

IEnumerator<ITableEvent> Deveel.Data.TableEventRegistry.GetEnumerator ( )
inline

Definition at line 145 of file TableEventRegistry.cs.

145  {
146  lock (this) {
147  return events.GetEnumerator();
148  }
149  }
readonly List< ITableEvent > events
IEnumerator IEnumerable. Deveel.Data.TableEventRegistry.GetEnumerator ( )
inlineprivate

Definition at line 151 of file TableEventRegistry.cs.

151  {
152  return GetEnumerator();
153  }
IEnumerator< ITableEvent > GetEnumerator()
ITableEvent Deveel.Data.TableEventRegistry.GetEvent ( int  index)
inline

Definition at line 155 of file TableEventRegistry.cs.

155  {
156  lock (this) {
157  if (index < 0 || index >= events.Count)
158  throw new ArgumentOutOfRangeException("index");
159 
160  return events[index];
161  }
162  }
readonly List< ITableEvent > events
void Deveel.Data.TableEventRegistry.Register ( ITableEvent  tableEvent)
inlinepackage

Definition at line 120 of file TableEventRegistry.cs.

120  {
121  lock (this) {
122  events.Add(tableEvent);
123  }
124  }
readonly List< ITableEvent > events
void Deveel.Data.TableEventRegistry.Rollback ( int  count)
inlinepackage

Definition at line 95 of file TableEventRegistry.cs.

95  {
96  lock (this) {
97  if (count > events.Count)
98  throw new Exception("Trying to rollback more events than are in the registry.");
99 
100  List<int> toAdd = new List<int>();
101 
102  // Find all entries and added new rows to the table
103  foreach (var tableEvent in events.OfType<TableRowEvent>()) {
104  if (tableEvent.EventType == TableRowEventType.Add ||
105  tableEvent.EventType == TableRowEventType.UpdateAdd)
106  toAdd.Add(tableEvent.RowNumber);
107  }
108 
109  events.RemoveRange(0, count);
110 
111  // Mark all added entries to deleted.
112  for (int i = 0; i < toAdd.Count; ++i) {
113  events.Add(new TableRowEvent(TableId, toAdd[i], TableRowEventType.Add));
114  events.Add(new TableRowEvent(TableId, toAdd[i], TableRowEventType.Remove));
115  }
116 
117  }
118  }
TableRowEventType
The kind of events that can happen on a table row during the life-time of a transaction.
readonly List< ITableEvent > events
void Deveel.Data.TableEventRegistry.TestCommitClash ( TableInfo  tableInfo,
TableEventRegistry  journal 
)
inlinepackage

Definition at line 126 of file TableEventRegistry.cs.

126  {
127  lock (this) {
128  // Very nasty search here...
129  foreach (var rowEvent in events.OfType<TableRowEvent>()) {
130  if (rowEvent.EventType == TableRowEventType.Remove) {
131  var rowNum = rowEvent.RowNumber;
132  foreach (var otherRowEvent in journal.events.OfType<TableRowEvent>()) {
133  if (otherRowEvent.RowNumber == rowNum &&
134  otherRowEvent.EventType == TableRowEventType.Remove) {
136  String.Format("Concurrent Serializable Transaction Conflict(1): " +
137  "Current row remove clash ( row: {0}, table: {1})", rowNum, tableInfo.TableName));
138  }
139  }
140  }
141  }
142  }
143  }
A long string in the system.
ObjectName TableName
Gets the fully qualified name of the table that is ensured to be unique within the system...
Definition: TableInfo.cs:97
TableRowEventType
The kind of events that can happen on a table row during the life-time of a transaction.
readonly List< ITableEvent > events

Member Data Documentation

readonly List<ITableEvent> Deveel.Data.TableEventRegistry.events
private

Definition at line 28 of file TableEventRegistry.cs.

Property Documentation

IEnumerable<int> Deveel.Data.TableEventRegistry.AddedRows
get

Definition at line 48 of file TableEventRegistry.cs.

long Deveel.Data.TableEventRegistry.CommitId
getset

Definition at line 46 of file TableEventRegistry.cs.

int Deveel.Data.TableEventRegistry.EventCount
get

Definition at line 87 of file TableEventRegistry.cs.

IEnumerable<int> Deveel.Data.TableEventRegistry.RemovedRows
get

Definition at line 71 of file TableEventRegistry.cs.

int Deveel.Data.TableEventRegistry.TableId
get

Definition at line 42 of file TableEventRegistry.cs.

TableSource Deveel.Data.TableEventRegistry.TableSource
getprivate setpackage

Definition at line 40 of file TableEventRegistry.cs.


The documentation for this class was generated from the following file: