DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
Deveel.Data.Index.ColumnIndex Class Referenceabstract
Inheritance diagram for Deveel.Data.Index.ColumnIndex:
Deveel.Data.Index.BlindSearchIndex Deveel.Data.Index.CollatedSearchIndex Deveel.Data.Index.LuceneIndex Deveel.Data.Index.InsertSearchIndex

Classes

class  IndexComparer
 
class  SubsetIndexComparer
 

Public Member Functions

abstract ColumnIndex Copy (ITable table, bool readOnly)
 
void Dispose ()
 
abstract void Insert (int rowNumber)
 
abstract void Remove (int rowNumber)
 
IIndex< int > Order (IEnumerable< int > rows)
 
IEnumerable< int > SelectRange (IndexRange range)
 
abstract IEnumerable< int > SelectRange (IndexRange[] ranges)
 
virtual IEnumerable< int > SelectAll ()
 
virtual IEnumerable< int > SelectFirst ()
 
IEnumerable< int > SelectNotFirst ()
 
IEnumerable< int > SelectLast ()
 
IEnumerable< int > SelectNotLast ()
 
IEnumerable< int > SelectAllNonNull ()
 
IEnumerable< int > SelectEqual (DataObject ob)
 
IEnumerable< int > SelectNotEqual (DataObject ob)
 
IEnumerable< int > SelectGreater (DataObject ob)
 
IEnumerable< int > SelectLess (DataObject ob)
 
IEnumerable< int > SelectGreaterOrEqual (DataObject ob)
 
IEnumerable< int > SelectLessOrEqual (DataObject ob)
 
IEnumerable< int > SelectBetween (DataObject ob1, DataObject ob2)
 
IEnumerable< int > SelectLike (DataObject value)
 
virtual ColumnIndex GetSubset (ITable subsetTable, int subsetColumn)
 

Protected Member Functions

 ColumnIndex (ITable table, int columnOffset)
 
DataObject GetValue (long row)
 
virtual void Dispose (bool disposing)
 
virtual IEnumerable< int > SearchText (DataObject value)
 
virtual ColumnIndex CreateSubset (ITable table, int column, IEnumerable< int > rows)
 

Properties

ITable Table [get, private set]
 
int ColumnOffset [get, private set]
 
virtual bool IsReadOnly [get]
 
virtual bool HandlesTextSearch [get]
 
abstract string IndexType [get]
 

Private Member Functions

 ~ColumnIndex ()
 

Static Private Member Functions

static ColumnIndex ()
 

Static Private Attributes

static readonly BlockIndex< int > EmptyList
 
static readonly BlockIndex< int > OneList
 

Detailed Description

Definition at line 25 of file ColumnIndex.cs.

Constructor & Destructor Documentation

Deveel.Data.Index.ColumnIndex.ColumnIndex ( ITable  table,
int  columnOffset 
)
inlineprotected

Definition at line 29 of file ColumnIndex.cs.

29  {
30  ColumnOffset = columnOffset;
31  Table = table;
32  }
Deveel.Data.Index.ColumnIndex.~ColumnIndex ( )
inlineprivate

Definition at line 34 of file ColumnIndex.cs.

34  {
35  Dispose(false);
36  }
static Deveel.Data.Index.ColumnIndex.ColumnIndex ( )
inlinestaticprivate

Definition at line 38 of file ColumnIndex.cs.

38  {
39  EmptyList = new BlockIndex<int>();
40  EmptyList.IsReadOnly = true;
41  OneList = new BlockIndex<int>();
42  OneList.Add(0);
43  OneList.IsReadOnly = true;
44  }
static readonly BlockIndex< int > OneList
Definition: ColumnIndex.cs:27
static readonly BlockIndex< int > EmptyList
Definition: ColumnIndex.cs:26

Member Function Documentation

abstract ColumnIndex Deveel.Data.Index.ColumnIndex.Copy ( ITable  table,
bool  readOnly 
)
pure virtual
virtual ColumnIndex Deveel.Data.Index.ColumnIndex.CreateSubset ( ITable  table,
int  column,
IEnumerable< int >  rows 
)
inlineprotectedvirtual

Definition at line 288 of file ColumnIndex.cs.

288  {
289  var index = new InsertSearchIndex(table, column, rows);
290  index.RecordUid = false;
291  return index;
292  }
void Deveel.Data.Index.ColumnIndex.Dispose ( )
inline

Definition at line 66 of file ColumnIndex.cs.

66  {
67  Dispose(true);
68  GC.SuppressFinalize(this);
69  }
virtual void Deveel.Data.Index.ColumnIndex.Dispose ( bool  disposing)
inlineprotectedvirtual

Reimplemented in Deveel.Data.Index.InsertSearchIndex, and Deveel.Data.Index.CollatedSearchIndex.

Definition at line 71 of file ColumnIndex.cs.

71  {
72  }
virtual ColumnIndex Deveel.Data.Index.ColumnIndex.GetSubset ( ITable  subsetTable,
int  subsetColumn 
)
inlinevirtual

Definition at line 263 of file ColumnIndex.cs.

263  {
264  if (subsetTable == null)
265  throw new ArgumentNullException("subsetTable");
266 
267  // Resolve table rows in this table scheme domain.
268  List<int> rowSet = new List<int>(subsetTable.RowCount);
269  var e = subsetTable.GetEnumerator();
270  while (e.MoveNext()) {
271  rowSet.Add(e.Current.RowId.RowNumber);
272  }
273 
274  var rows = subsetTable.ResolveRows(subsetColumn, rowSet, Table);
275 
276  // Generates an IIndex which contains indices into 'rowSet' in
277  // sorted order.
278  var newSet = Order(rows);
279 
280  // Our 'new_set' should be the same size as 'rowSet'
281  if (newSet.Count != rowSet.Count) {
282  throw new Exception("Internal sort error in finding sub-set.");
283  }
284 
285  return CreateSubset(subsetTable, subsetColumn, newSet);
286  }
IIndex< int > Order(IEnumerable< int > rows)
Definition: ColumnIndex.cs:78
int RowCount
Gets the total number of rows in the table.
Definition: ITable.cs:52
virtual ColumnIndex CreateSubset(ITable table, int column, IEnumerable< int > rows)
Definition: ColumnIndex.cs:288
DataObject Deveel.Data.Index.ColumnIndex.GetValue ( long  row)
inlineprotected

Definition at line 60 of file ColumnIndex.cs.

60  {
61  return Table.GetValue(row, ColumnOffset);
62  }
abstract DataObject GetValue(long rowNumber, int columnOffset)
Gets a single cell within the table that is located at the given column offset and row...
abstract void Deveel.Data.Index.ColumnIndex.Insert ( int  rowNumber)
pure virtual
IIndex<int> Deveel.Data.Index.ColumnIndex.Order ( IEnumerable< int >  rows)
inline

Definition at line 78 of file ColumnIndex.cs.

78  {
79  var rowSet = rows.ToList();
80 
81  // The length of the set to order
82  int rowSetLength = rowSet.Count;
83 
84  // Trivial cases where sorting is not required:
85  // NOTE: We use readOnly objects to save some memory.
86  if (rowSetLength == 0)
87  return EmptyList;
88  if (rowSetLength == 1)
89  return OneList;
90 
91  // This will be 'row set' sorted by its entry lookup. This must only
92  // contain indices to rowSet entries.
93  var newSet = new BlockIndex<int>();
94 
95  if (rowSetLength <= 250000) {
96  // If the subset is less than or equal to 250,000 elements, we generate
97  // an array in memory that contains all values in the set and we sort
98  // it. This requires use of memory from the heap but is faster than
99  // the no heap use method.
100  var subsetList = new List<DataObject>(rowSetLength);
101  foreach (long row in rowSet) {
102  subsetList.Add(GetValue(row));
103  }
104 
105  // The comparator we use to sort
106  var comparer = new SubsetIndexComparer(subsetList.ToArray());
107 
108  // Fill new_set with the set { 0, 1, 2, .... , row_set_length }
109  for (int i = 0; i < rowSetLength; ++i) {
110  var cell = subsetList[i];
111  newSet.InsertSort(cell, i, comparer);
112  }
113 
114  } else {
115  // This is the no additional heap use method to sorting the sub-set.
116 
117  // The comparator we use to sort
118  var comparer = new IndexComparer(this, rowSet);
119 
120  // Fill new_set with the set { 0, 1, 2, .... , row_set_length }
121  for (int i = 0; i < rowSetLength; ++i) {
122  var cell = GetValue(rowSet[i]);
123  newSet.InsertSort(cell, i, comparer);
124  }
125  }
126 
127  return newSet;
128  }
DataObject GetValue(long row)
Definition: ColumnIndex.cs:60
static readonly BlockIndex< int > OneList
Definition: ColumnIndex.cs:27
static readonly BlockIndex< int > EmptyList
Definition: ColumnIndex.cs:26
abstract void Deveel.Data.Index.ColumnIndex.Remove ( int  rowNumber)
pure virtual
virtual IEnumerable<int> Deveel.Data.Index.ColumnIndex.SearchText ( DataObject  value)
inlineprotectedvirtual

Definition at line 259 of file ColumnIndex.cs.

259  {
260  throw new NotSupportedException("The column index does not support text search.");
261  }
virtual IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectAll ( )
inlinevirtual

Reimplemented in Deveel.Data.Index.BlindSearchIndex, and Deveel.Data.Index.CollatedSearchIndex.

Definition at line 136 of file ColumnIndex.cs.

136  {
137  return SelectRange(new IndexRange(
138  RangeFieldOffset.FirstValue, IndexRange.FirstInSet,
139  RangeFieldOffset.LastValue, IndexRange.LastInSet));
140  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectAllNonNull ( )
inline

Definition at line 174 of file ColumnIndex.cs.

174  {
175  return SelectRange(new IndexRange(
176  RangeFieldOffset.AfterLastValue, DataObject.Null(),
177  RangeFieldOffset.LastValue, IndexRange.LastInSet));
178  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectBetween ( DataObject  ob1,
DataObject  ob2 
)
inline

Definition at line 240 of file ColumnIndex.cs.

240  {
241  if (ob1.IsNull || ob2.IsNull)
242  return new List<int>(0);
243 
244  return SelectRange(new IndexRange(
245  RangeFieldOffset.FirstValue, ob1,
246  RangeFieldOffset.BeforeFirstValue, ob2));
247  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectEqual ( DataObject  ob)
inline

Definition at line 180 of file ColumnIndex.cs.

180  {
181  if (ob.IsNull)
182  return new List<int>(0);
183 
184  return SelectRange(new IndexRange(
185  RangeFieldOffset.FirstValue, ob,
186  RangeFieldOffset.LastValue, ob));
187  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
virtual IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectFirst ( )
inlinevirtual

Definition at line 142 of file ColumnIndex.cs.

142  {
143  // NOTE: This will find NULL at start which is probably wrong. The
144  // first value should be the first non null value.
145  return SelectRange(new IndexRange(
146  RangeFieldOffset.FirstValue, IndexRange.FirstInSet,
147  RangeFieldOffset.LastValue, IndexRange.FirstInSet));
148  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectGreater ( DataObject  ob)
inline

Definition at line 204 of file ColumnIndex.cs.

204  {
205  if (ob.IsNull)
206  return new List<int>(0);
207 
208  return SelectRange(new IndexRange(
209  RangeFieldOffset.AfterLastValue, ob,
210  RangeFieldOffset.LastValue, IndexRange.LastInSet));
211  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectGreaterOrEqual ( DataObject  ob)
inline

Definition at line 222 of file ColumnIndex.cs.

222  {
223  if (ob.IsNull)
224  return new List<int>(0);
225 
226  return SelectRange(new IndexRange(
227  RangeFieldOffset.FirstValue, ob,
228  RangeFieldOffset.LastValue, IndexRange.LastInSet));
229  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectLast ( )
inline

Definition at line 158 of file ColumnIndex.cs.

158  {
159  return SelectRange(new IndexRange(
160  RangeFieldOffset.FirstValue, IndexRange.LastInSet,
161  RangeFieldOffset.LastValue, IndexRange.LastInSet));
162  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectLess ( DataObject  ob)
inline

Definition at line 213 of file ColumnIndex.cs.

213  {
214  if (ob.IsNull)
215  return new List<int>(0);
216 
217  return SelectRange(new IndexRange(
218  RangeFieldOffset.AfterLastValue, DataObject.Null(),
219  RangeFieldOffset.BeforeFirstValue, ob));
220  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectLessOrEqual ( DataObject  ob)
inline

Definition at line 231 of file ColumnIndex.cs.

231  {
232  if (ob.IsNull)
233  return new List<int>(0);
234 
235  return SelectRange(new IndexRange(
236  RangeFieldOffset.AfterLastValue, DataObject.Null(),
237  RangeFieldOffset.LastValue, ob));
238  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectLike ( DataObject  value)
inline

Definition at line 249 of file ColumnIndex.cs.

249  {
250  if (value.IsNull)
251  return new List<int>(0);
252 
253  if (!HandlesTextSearch)
254  return SelectEqual(value);
255 
256  return SearchText(value);
257  }
IEnumerable< int > SelectEqual(DataObject ob)
Definition: ColumnIndex.cs:180
virtual IEnumerable< int > SearchText(DataObject value)
Definition: ColumnIndex.cs:259
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectNotEqual ( DataObject  ob)
inline

Definition at line 189 of file ColumnIndex.cs.

189  {
190  if (ob.IsNull) {
191  return new List<int>(0);
192  }
193  return SelectRange(new IndexRange[]
194  {
195  new IndexRange(
196  RangeFieldOffset.AfterLastValue, DataObject.Null(),
197  RangeFieldOffset.BeforeFirstValue, ob)
198  , new IndexRange(
199  RangeFieldOffset.AfterLastValue, ob,
200  RangeFieldOffset.LastValue, IndexRange.LastInSet)
201  });
202  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectNotFirst ( )
inline

Definition at line 150 of file ColumnIndex.cs.

150  {
151  // NOTE: This will find NULL at start which is probably wrong. The
152  // first value should be the first non null value.
153  return SelectRange(new IndexRange(
154  RangeFieldOffset.AfterLastValue, IndexRange.FirstInSet,
155  RangeFieldOffset.LastValue, IndexRange.LastInSet));
156  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
RangeFieldOffset
The absolute offset of a field in a range of a selection.
IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectNotLast ( )
inline

summary> Selects all values in the column that are not null. /summary> returns>

Definition at line 164 of file ColumnIndex.cs.

IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectRange ( IndexRange  range)
inline

Definition at line 130 of file ColumnIndex.cs.

130  {
131  return SelectRange(new[] {range});
132  }
IEnumerable< int > SelectRange(IndexRange range)
Definition: ColumnIndex.cs:130
abstract IEnumerable<int> Deveel.Data.Index.ColumnIndex.SelectRange ( IndexRange[]  ranges)
pure virtual

Member Data Documentation

readonly BlockIndex<int> Deveel.Data.Index.ColumnIndex.EmptyList
staticprivate

Definition at line 26 of file ColumnIndex.cs.

readonly BlockIndex<int> Deveel.Data.Index.ColumnIndex.OneList
staticprivate

Definition at line 27 of file ColumnIndex.cs.

Property Documentation

int Deveel.Data.Index.ColumnIndex.ColumnOffset
getprivate set

Definition at line 48 of file ColumnIndex.cs.

virtual bool Deveel.Data.Index.ColumnIndex.HandlesTextSearch
get

Definition at line 54 of file ColumnIndex.cs.

abstract string Deveel.Data.Index.ColumnIndex.IndexType
get

Definition at line 58 of file ColumnIndex.cs.

virtual bool Deveel.Data.Index.ColumnIndex.IsReadOnly
get

Definition at line 50 of file ColumnIndex.cs.

ITable Deveel.Data.Index.ColumnIndex.Table
getprivate set

Definition at line 46 of file ColumnIndex.cs.


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