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

Classes

class  RangeChecker
 

Public Member Functions

 BlindSearchIndex (ITable table, int columnOffset)
 
override ColumnIndex Copy (ITable table, bool readOnly)
 
override void Insert (int rowNumber)
 
override void Remove (int rowNumber)
 
override IEnumerable< int > SelectRange (IndexRange[] ranges)
 
override IEnumerable< int > SelectAll ()
 
- Public Member Functions inherited from Deveel.Data.Index.ColumnIndex
void Dispose ()
 
IIndex< int > Order (IEnumerable< int > rows)
 
IEnumerable< int > SelectRange (IndexRange range)
 
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)
 

Properties

override string IndexType [get]
 
- Properties inherited from Deveel.Data.Index.ColumnIndex
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

void AssertNotReadOnly ()
 
int HighestSearch (DataObject ob, IList< int > list, int lower, int higher)
 
void DoInsertSort (IList< int > list, int row)
 

Additional Inherited Members

- Protected Member Functions inherited from Deveel.Data.Index.ColumnIndex
 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)
 

Detailed Description

Definition at line 25 of file BlindSearchIndex.cs.

Constructor & Destructor Documentation

Deveel.Data.Index.BlindSearchIndex.BlindSearchIndex ( ITable  table,
int  columnOffset 
)
inline

Definition at line 26 of file BlindSearchIndex.cs.

27  : base(table, columnOffset) {
28  }

Member Function Documentation

void Deveel.Data.Index.BlindSearchIndex.AssertNotReadOnly ( )
inlineprivate

Definition at line 34 of file BlindSearchIndex.cs.

34  {
35  if (IsReadOnly)
36  throw new ArgumentException("Cannot mutate a read-only index.");
37  }
override ColumnIndex Deveel.Data.Index.BlindSearchIndex.Copy ( ITable  table,
bool  readOnly 
)
inlinevirtual

Implements Deveel.Data.Index.ColumnIndex.

Definition at line 78 of file BlindSearchIndex.cs.

78  {
79  return new BlindSearchIndex(table, ColumnOffset);
80  }
BlindSearchIndex(ITable table, int columnOffset)
void Deveel.Data.Index.BlindSearchIndex.DoInsertSort ( IList< int >  list,
int  row 
)
inlineprivate

Definition at line 64 of file BlindSearchIndex.cs.

64  {
65  int listSize = list.Count;
66  if (listSize == 0) {
67  list.Add(row);
68  } else {
69  var point = HighestSearch(GetValue(row), list, 0, listSize - 1);
70  if (point == listSize) {
71  list.Add(row);
72  } else {
73  list.Insert(point, row);
74  }
75  }
76  }
DataObject GetValue(long row)
Definition: ColumnIndex.cs:60
int HighestSearch(DataObject ob, IList< int > list, int lower, int higher)
int Deveel.Data.Index.BlindSearchIndex.HighestSearch ( DataObject  ob,
IList< int >  list,
int  lower,
int  higher 
)
inlineprivate

Definition at line 39 of file BlindSearchIndex.cs.

39  {
40  if ((higher - lower) <= 5) {
41  // Start from the bottom up until we find the highest val
42  for (var i = higher; i >= lower; --i) {
43  int res = ob.CompareTo(GetValue(list[i]));
44  if (res >= 0)
45  return i + 1;
46  }
47  // Didn't find return lowest
48  return lower;
49  }
50 
51  var mid = (lower + higher)/2;
52  int compResult = ob.CompareTo(GetValue(list[mid]));
53 
54  if (compResult == 0)
55  // We know the bottom is between 'mid' and 'higher'
56  return HighestSearch(ob, list, mid, higher);
57 
58  if (compResult < 0)
59  return HighestSearch(ob, list, lower, mid - 1);
60 
61  return HighestSearch(ob, list, mid + 1, higher);
62  }
DataObject GetValue(long row)
Definition: ColumnIndex.cs:60
int HighestSearch(DataObject ob, IList< int > list, int lower, int higher)
override void Deveel.Data.Index.BlindSearchIndex.Insert ( int  rowNumber)
inlinevirtual

Implements Deveel.Data.Index.ColumnIndex.

Definition at line 82 of file BlindSearchIndex.cs.

82  {
84  }
override void Deveel.Data.Index.BlindSearchIndex.Remove ( int  rowNumber)
inlinevirtual

Implements Deveel.Data.Index.ColumnIndex.

Definition at line 86 of file BlindSearchIndex.cs.

86  {
88  }
override IEnumerable<int> Deveel.Data.Index.BlindSearchIndex.SelectAll ( )
inlinevirtual

Reimplemented from Deveel.Data.Index.ColumnIndex.

Definition at line 100 of file BlindSearchIndex.cs.

100  {
101  var rowList = new List<int>(Table.RowCount);
102  var e = Table.GetEnumerator();
103  while (e.MoveNext()) {
104  DoInsertSort(rowList, e.Current.RowId.RowNumber);
105  }
106  return rowList;
107  }
abstract IEnumerator< Row > GetEnumerator()
void DoInsertSort(IList< int > list, int row)
abstract int RowCount
Definition: Table.cs:67
override IEnumerable<int> Deveel.Data.Index.BlindSearchIndex.SelectRange ( IndexRange[]  ranges)
inlinevirtual

Implements Deveel.Data.Index.ColumnIndex.

Definition at line 90 of file BlindSearchIndex.cs.

90  {
91  int setSize = Table.RowCount;
92  // If no items in the set return an empty set
93  if (setSize == 0)
94  return new List<int>(0);
95 
96  var checker = new RangeChecker(this, ranges);
97  return checker.Resolve();
98  }
abstract int RowCount
Definition: Table.cs:67

Property Documentation

override string Deveel.Data.Index.BlindSearchIndex.IndexType
get

Definition at line 30 of file BlindSearchIndex.cs.


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