internal override IEnumerable<IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { var start = _start.Normalize(index.Options); var end = _end.Normalize(index.Options); // define order var order = start.CompareTo(end) <= 0 ? Query.Ascending : Query.Descending; // find first indexNode var node = indexer.Find(index, start, true, order); // navigate using next[0] do next node - if less or equals returns while (node != null) { var diff = node.Key.CompareTo(end); if (diff == 0 || diff != order) { yield return node; } else { break; } node = indexer.GetNode(node.NextPrev(0, order)); } }
internal override IEnumerable<IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { // find first indexNode var value = _value.Normalize(index.Options); var node = indexer.Find(index, value, true, Query.Ascending); var str = value.AsString; // navigate using next[0] do next node - if less or equals returns while (node != null) { var valueString = node.Key.AsString; // value will not be null because null occurs before string (bsontype sort order) if (valueString.StartsWith(str)) { if (!node.DataBlock.IsEmpty) { yield return node; } } else { break; // if not more startswith, stop scanning } node = indexer.GetNode(node.Next[0]); } }
internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { // find first indexNode var value = _value.Normalize(index.Options); var node = indexer.Find(index, value, true, Query.Ascending); if (node == null) { yield break; } // move until next is last while (node != null) { var diff = node.Key.CompareTo(value); if (diff == 1 || (_equals && diff == 0)) { if (node.IsHeadTail(index)) { yield break; } yield return(node); } node = indexer.GetNode(node.Next[0]); } }
internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { // find first indexNode var value = _value.Normalize(index.Options); var node = indexer.Find(index, value, true, Query.Ascending); var str = value.AsString; // navigate using next[0] do next node - if less or equals returns while (node != null) { var valueString = node.Key.AsString; // value will not be null because null occurs before string (bsontype sort order) if (valueString.StartsWith(str)) { if (!node.DataBlock.IsEmpty) { yield return(node); } } else { break; // if not more startswith, stop scanning } node = indexer.GetNode(node.Next[0]); } }
internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { var value = _value.Normalize(index.Options); var node = indexer.Find(index, value, false, Query.Ascending); if (node == null) { yield break; } yield return(node); if (index.Options.Unique == false) { // navigate using next[0] do next node - if equals, returns while (!node.Next[0].IsEmpty && ((node = indexer.GetNode(node.Next[0])).Key.CompareTo(value) == 0)) { if (node.IsHeadTail(index)) { yield break; } yield return(node); } } }
internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { var start = _start.Normalize(index.Options); var end = _end.Normalize(index.Options); // define order var order = start.CompareTo(end) <= 0 ? Query.Ascending : Query.Descending; // find first indexNode var node = indexer.Find(index, start, true, order); // navigate using next[0] do next node - if less or equals returns while (node != null) { var diff = node.Key.CompareTo(end); if (diff == 0 || diff != order) { yield return(node); } else { break; } node = indexer.GetNode(node.NextPrev(0, order)); } }
internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { // find first indexNode var node = indexer.Find(index, _value, true, Query.Ascending); if (node == null) { yield break; } // move until next is last while (node != null) { // compares only with are same type if (node.Key.Type == _value.Type || (node.Key.IsNumber && _value.IsNumber)) { var diff = node.Key.CompareTo(_value); if (diff == 1 || (_equals && diff == 0)) { if (node.IsHeadTail(index)) { yield break; } yield return(node); } } node = indexer.GetNode(node.Next[0]); } }
internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { // define order var order = _start.CompareTo(_end) <= 0 ? Query.Ascending : Query.Descending; // find first indexNode var node = indexer.Find(index, _start, true, order); // returns (or not) equals start value while (node != null) { var diff = node.Key.CompareTo(_start); // if current value are not equals start, go out this loop if (diff != 0) { break; } if (_startEquals) { yield return(node); } node = indexer.GetNode(node.NextPrev(0, order)); } // navigate using next[0] do next node - if less or equals returns while (node != null) { var diff = node.Key.CompareTo(_end); if (_endEquals && diff == 0) { yield return(node); } else if (diff == -order) { yield return(node); } else { break; } node = indexer.GetNode(node.NextPrev(0, order)); } }
internal override IEnumerable<IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { var node = indexer.Find(index, _value, false, Query.Ascending); if (node == null) yield break; yield return node; if (index.Unique == false) { // navigate using next[0] do next node - if equals, returns while (!node.Next[0].IsEmpty && ((node = indexer.GetNode(node.Next[0])).Key.CompareTo(_value) == 0)) { if (node.IsHeadTail(index)) yield break; yield return node; } } }
internal override IEnumerable<IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index) { // find first indexNode var value = _value.Normalize(index.Options); var node = indexer.Find(index, value, true, Query.Ascending); if (node == null) yield break; // move until next is last while (node != null) { var diff = node.Key.CompareTo(value); if (diff == 1 || (_equals && diff == 0)) { if (node.IsHeadTail(index)) yield break; yield return node; } node = indexer.GetNode(node.Next[0]); } }