public long GetNumberEntriesFor(TableSchema.FixedSizeSchemaIndexDef index, long afterValue, out long totalCount) { var fst = GetFixedSizeTree(index); totalCount = fst.NumberOfEntries; if (afterValue == 0 || totalCount == 0) { return(totalCount); } long count = 0; using (var it = fst.Iterate()) { if (it.Seek(afterValue) == false) { return(0); } do { if (it.CurrentKey == afterValue) { continue; } count++; } while (it.MoveNext()); } return(count); }
public void DeleteBackwardFrom(TableSchema.FixedSizeSchemaIndexDef index, long value, long numberOfEntriesToDelete) { if (numberOfEntriesToDelete < 0) { throw new ArgumentOutOfRangeException(nameof(numberOfEntriesToDelete), "Number of entries should not be negative"); } if (numberOfEntriesToDelete == 0) { return; } var toDelete = new List <long>(); var fst = GetFixedSizeTree(index); using (var it = fst.Iterate()) { if (it.Seek(value) == false && it.SeekToLast() == false) { return; } do { toDelete.Add(it.CreateReaderForCurrent().ReadLittleEndianInt64()); numberOfEntriesToDelete--; } while (numberOfEntriesToDelete > 0 && it.MovePrev()); } foreach (var id in toDelete) { Delete(id); } }
private FixedSizeTree GetFixedSizeTree(TableSchema.FixedSizeSchemaIndexDef indexDef) { if (indexDef.IsGlobal) { return(_tx.GetGlobalFixedSizeTree(indexDef.Name, sizeof(long))); } var tableTree = _tx.ReadTree(Name); return(GetFixedSizeTree(tableTree, indexDef.Name, sizeof(long))); }
private FixedSizeTree GetFixedSizeTree(TableSchema.FixedSizeSchemaIndexDef indexDef) { if (indexDef.IsGlobal) { return(GetFixedSizeTree(_tx.LowLevelTransaction.RootObjects, indexDef.NameAsSlice, sizeof(long))); } var tableTree = _tx.ReadTree(Name); return(GetFixedSizeTree(tableTree, indexDef.NameAsSlice, sizeof(long))); }
public IEnumerable <TableValueReader> SeekBackwardFrom(TableSchema.FixedSizeSchemaIndexDef index, long key) { var fst = GetFixedSizeTree(index); using (var it = fst.Iterate()) { if (it.Seek(key) == false && it.SeekToLast() == false) { yield break; } do { yield return(GetTableValueReader(it)); } while (it.MovePrev()); } }
public long GetNumberEntriesFor(TableSchema.FixedSizeSchemaIndexDef index) { var fst = GetFixedSizeTree(index); return(fst.NumberOfEntries); }