18 using System.Collections.Generic;
23 namespace Deveel.Data.Index {
25 private readonly List<IndexRange>
ranges;
32 this.ranges =
new List<IndexRange>(ranges);
51 if (nullCheck && value.
IsNull) {
72 if (nullCheck && value.
IsNull) {
108 return new IndexRange(startPosition, start, endPosition, end);
130 bool intersect1 =
false;
131 if (startCell1 != null && endCell2 != null) {
132 int c = startCell1.CompareTo(endCell2);
142 bool intersect2 =
false;
143 if (startCell2 != null && endCell1 != null) {
144 int c = startCell2.CompareTo(endCell1);
154 return (intersect1 && intersect2);
182 startPosition1 = startPosition2;
186 startPosition1 = startPosition2;
193 int c = cell.CompareTo(end2);
198 endPosition1 = endPosition2;
202 endPosition1 = endPosition2;
206 return new IndexRange(startPosition1, start1, endPosition1, end1);
211 int sz = ranges.Count;
212 var list = ranges.GetRange(0, sz);
215 op = op.SubQueryPlainType();
223 var leftRange = IntersectOn(range,
SqlExpressionType.SmallerThan, value, nullCheck);
224 var rightRange = IntersectOn(range,
SqlExpressionType.GreaterThan, value, nullCheck);
230 list.Add(rightRange);
241 range = IntersectOn(range, op, value, nullCheck);
260 var rangeSet =
new List<IndexRange>(ranges);
261 var inputSet = unionTo.
ranges;
263 int inSz = inputSet.Count;
266 var inRange = inputSet[n];
267 int sz = rangeSet.Count;
268 var i = rangeSet.GetRange(0, sz);
270 while (j < i.Count) {
272 if (IntersectedBy(inRange, range)) {
274 inRange = ChangeRangeSizeToEncompass(inRange, range);
280 var startPoint = inRange.StartOffset;
281 var start = inRange.StartValue;
282 var endPoint = inRange.EndOffset;
283 var end = inRange.EndValue;
286 rangeSet.Insert(0, inRange);
288 var startCell = start;
289 i = rangeSet.GetRange(0, rangeSet.Count);
291 while (j < i.Count) {
293 var curStart = range.StartValue;
295 if (curStart.CompareTo(startCell) > 0) {
313 return ranges.ToArray();
bool IsNull
Gets a value that indicates if this object is materialized as null.
override bool Equals(object obj)
static IndexRange ChangeRangeSizeToEncompass(IndexRange range1, IndexRange range2)
Alters the first range so it encompasses the second range.
Describes the range of values to select from an index.
static IndexRange IntersectOn(IndexRange range, SqlExpressionType op, DataObject value, bool nullCheck)
static readonly IndexRange FullRange
The entire range of values in an index (including NULL)
readonly List< IndexRange > ranges
static DataObject Null(SqlType type)
DataObject EndValue
Gets the last value of the range.
SqlExpressionType
All the possible type of SqlExpression supported
static readonly DataObject FirstInSet
RangeFieldOffset EndOffset
Gets the offset of the last value of the range.
static bool IntersectedBy(IndexRange range1, IndexRange range2)
Returns true if the two SelectableRange ranges intersect.
int CompareTo(DataObject other)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
static readonly IndexRange Null
DataObject StartValue
Gets the first value of the range.
static readonly DataObject LastInSet
IndexRangeSet Intersect(SqlExpressionType op, DataObject value)
IndexRangeSet(IEnumerable< IndexRange > ranges)
RangeFieldOffset
The absolute offset of a field in a range of a selection.
RangeFieldOffset StartOffset
Gets the offset of the first value of the range.
IndexRangeSet Union(IndexRangeSet unionTo)
Unions the current range set with the given range set.