DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Private Attributes | List of all members
Deveel.Data.Sql.Tables.TableSourceGC Class Reference

Public Member Functions

 TableSourceGC (TableSource tableSource)
 
void DeleteRow (int rowIndex)
 
void Collect (bool force)
 

Private Attributes

readonly TableSource tableSource
 
BlockIndex< int > deletedRows
 
bool fullSweep
 

Detailed Description

Definition at line 23 of file TableSourceGC.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Tables.TableSourceGC.TableSourceGC ( TableSource  tableSource)
inline

Definition at line 32 of file TableSourceGC.cs.

32  {
33  this.tableSource = tableSource;
35 
36  // lastSuccess = DateTime.UtcNow;
37  // lastTry = null;
38  }

Member Function Documentation

void Deveel.Data.Sql.Tables.TableSourceGC.Collect ( bool  force)
inline

Definition at line 47 of file TableSourceGC.cs.

47  {
48  try {
49  int checkCount = 0;
50  int deleteCount = 0;
51 
52  // Synchronize over the master data table source so no other threads
53  // can interfere when we collect this information.
54  lock (tableSource) {
56  return;
57 
58  // If root is locked, or has transaction changes pending, then we
59  // can't delete any rows marked as deleted because they could be
60  // referenced by transactions or result sets.
61  if (force ||
64 
65  // lastSuccess = DateTime.Now;
66  // lastTry = null;
67 
68  // Are we due a full sweep?
69  if (fullSweep) {
70  int rawRowCount = tableSource.RawRowCount;
71  for (int i = 0; i < rawRowCount; ++i) {
72  // Synchronized in dataSource.
74  ++deleteCount;
75 
76  ++checkCount;
77  }
78 
79  fullSweep = false;
80  } else {
81  // Are there any rows marked as deleted?
82  int size = deletedRows.Count;
83  if (size > 0) {
84  // Go remove all rows marked as deleted.
85  foreach (int rowIndex in deletedRows) {
86  // Synchronized in dataSource.
87  tableSource.HardRemoveRow(rowIndex);
88  ++deleteCount;
89  ++checkCount;
90  }
91  }
92 
93  deletedRows = new BlockIndex<int>();
94  }
95 
96  if (checkCount > 0) {
97  // TODO: Emit the information to the system
98  }
99 
100  } // if not roots locked and not transactions pending
101 
102  } // lock
103  } catch (IOException) {
104  // TODO: Log the error to the system
105  }
106  }
void HardRemoveRow(int rowIndex)
Definition: TableSource.cs:818
bool HardCheckAndReclaimRow(int recordIndex)
Definition: TableSource.cs:833
void Deveel.Data.Sql.Tables.TableSourceGC.DeleteRow ( int  rowIndex)
inline

Definition at line 40 of file TableSourceGC.cs.

40  {
41  if (!fullSweep) {
42  if (!deletedRows.UniqueInsertSort(rowIndex))
43  throw new InvalidOperationException("Row marked twice for deletion.");
44  }
45  }

Member Data Documentation

BlockIndex<int> Deveel.Data.Sql.Tables.TableSourceGC.deletedRows
private

Definition at line 25 of file TableSourceGC.cs.

bool Deveel.Data.Sql.Tables.TableSourceGC.fullSweep
private

Definition at line 30 of file TableSourceGC.cs.

readonly TableSource Deveel.Data.Sql.Tables.TableSourceGC.tableSource
private

Definition at line 24 of file TableSourceGC.cs.


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