public IEnumerable <SeekResult> SeekForwardFrom(TableSchema.SchemaIndexDef index, Slice value, bool startsWith = false) { var tree = GetTree(index); using (var it = tree.Iterate(false)) { if (startsWith) { it.RequiredPrefix = value.Clone(_tx.Allocator); } if (it.Seek(value) == false) { yield break; } do { yield return(new SeekResult { Key = it.CurrentKey, Results = GetSecondaryIndexForValue(tree, it.CurrentKey.Clone(_tx.Allocator)) }); } while (it.MoveNext()); } }
private Tree GetTree(TableSchema.SchemaIndexDef idx) { if (idx.IsGlobal) { return(_tx.ReadTree(idx.Name)); } return(GetTree(idx.Name)); }
public IEnumerable <SeekResult> SeekForwardFrom(TableSchema.SchemaIndexDef index, string value, bool startsWith = false) { Slice str; using (Slice.From(_tx.Allocator, value, ByteStringType.Immutable, out str)) { return(SeekForwardFrom(index, str, startsWith)); } }
public long DeleteForwardFrom(TableSchema.SchemaIndexDef index, Slice value, long numberOfEntriesToDelete) { if (numberOfEntriesToDelete < 0) { throw new ArgumentOutOfRangeException(nameof(numberOfEntriesToDelete), "Number of entries should not be negative"); } if (numberOfEntriesToDelete == 0) { return(0); } var toDelete = new List <long>(); var tree = GetTree(index); using (var it = tree.Iterate(false)) { if (it.Seek(value) == false) { return(0); } do { var fst = GetFixedSizeTree(tree, it.CurrentKey.Clone(_tx.Allocator), 0); using (var fstIt = fst.Iterate()) { if (fstIt.Seek(long.MinValue) == false) { break; } do { toDelete.Add(fstIt.CurrentKey); numberOfEntriesToDelete--; }while (numberOfEntriesToDelete > 0 && fstIt.MoveNext()); } }while (numberOfEntriesToDelete > 0 && it.MoveNext()); } foreach (var id in toDelete) { Delete(id); } return(toDelete.Count); }