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

Public Member Functions

 TransactionCollection ()
 
void AddTransaction (ITransaction transaction)
 
void RemoveTransaction (ITransaction transaction)
 
long MinimumCommitId (ITransaction transaction)
 
IEnumerator< ITransactionGetEnumerator ()
 
ITransaction FindById (int commitId)
 

Properties

int Count [get]
 

Private Member Functions

IEnumerator IEnumerable. GetEnumerator ()
 

Private Attributes

readonly List< ITransactiontransactions
 
long minCommitId
 
long maxCommitId
 

Detailed Description

Definition at line 23 of file TransactionCollection.cs.

Constructor & Destructor Documentation

Deveel.Data.Transactions.TransactionCollection.TransactionCollection ( )
inline

Definition at line 28 of file TransactionCollection.cs.

28  {
29  transactions = new List<ITransaction>();
30  minCommitId = Int64.MaxValue;
31  maxCommitId = 0;
32  }

Member Function Documentation

void Deveel.Data.Transactions.TransactionCollection.AddTransaction ( ITransaction  transaction)
inline

Definition at line 42 of file TransactionCollection.cs.

42  {
43  lock (this) {
44  long currentCommitId = transaction.CommitId;
45  if (currentCommitId < maxCommitId)
46  throw new InvalidOperationException("Added a transaction with a lower than maximum commit id");
47 
48  transactions.Add(transaction);
49  //TODO: SystemContext.Stats.Increment(StatsDefaultKeys.OpenTransactionsCount);
50  maxCommitId = currentCommitId;
51  }
52  }
ITransaction Deveel.Data.Transactions.TransactionCollection.FindById ( int  commitId)
inline

Definition at line 108 of file TransactionCollection.cs.

108  {
109  lock (this) {
110  return transactions.FirstOrDefault(x => x.CommitId == commitId);
111  }
112  }
IEnumerator<ITransaction> Deveel.Data.Transactions.TransactionCollection.GetEnumerator ( )
inline

Definition at line 98 of file TransactionCollection.cs.

98  {
99  lock (this) {
100  return transactions.GetEnumerator();
101  }
102  }
IEnumerator IEnumerable. Deveel.Data.Transactions.TransactionCollection.GetEnumerator ( )
inlineprivate

Definition at line 104 of file TransactionCollection.cs.

104  {
105  return GetEnumerator();
106  }
long Deveel.Data.Transactions.TransactionCollection.MinimumCommitId ( ITransaction  transaction)
inline

Definition at line 79 of file TransactionCollection.cs.

79  {
80  lock (this) {
81  long commitId = Int64.MaxValue;
82  if (transactions.Count > 0) {
83  // If the bottom transaction is this transaction, then go to the
84  // next up from the bottom (we don't count this transaction as the
85  // minimum commit_id).
86  var testTransaction = transactions[0];
87  if (testTransaction != transaction) {
88  commitId = testTransaction.CommitId;
89  } else if (transactions.Count > 1) {
90  commitId = transactions[1].CommitId;
91  }
92  }
93 
94  return commitId;
95  }
96  }
void Deveel.Data.Transactions.TransactionCollection.RemoveTransaction ( ITransaction  transaction)
inline

Definition at line 54 of file TransactionCollection.cs.

54  {
55  lock (this) {
56  int size = transactions.Count;
57  int i = transactions.IndexOf(transaction);
58  if (i == 0) {
59  // First in list.
60  if (i == size - 1) {
61  // And last.
62  minCommitId = Int32.MaxValue;
63  maxCommitId = 0;
64  } else {
65  minCommitId = transactions[i + 1].CommitId;
66  }
67  } else if (i == transactions.Count - 1) {
68  // Last in list.
69  maxCommitId = transactions[i - 1].CommitId;
70  } else if (i == -1) {
71  throw new InvalidOperationException("Unable to find transaction in the list.");
72  }
73 
74  transactions.RemoveAt(i);
75  //TODO: SystemContext.Stats.Decrement(StatsDefaultKeys.OpenTransactionsCount);
76  }
77  }

Member Data Documentation

long Deveel.Data.Transactions.TransactionCollection.maxCommitId
private

Definition at line 26 of file TransactionCollection.cs.

long Deveel.Data.Transactions.TransactionCollection.minCommitId
private

Definition at line 25 of file TransactionCollection.cs.

readonly List<ITransaction> Deveel.Data.Transactions.TransactionCollection.transactions
private

Definition at line 24 of file TransactionCollection.cs.

Property Documentation

int Deveel.Data.Transactions.TransactionCollection.Count
get

Definition at line 34 of file TransactionCollection.cs.


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