public GetStatus getNextRecord_LowLevel_OLD(
IComparable<RecordKey> lowkey,
bool direction_is_forward,
ref RecordKey key,
ref RecordData record,
bool equal_ok,
bool tombstone_ok)
{
SegmentWalkStats stats = new SegmentWalkStats();
BDSkipList<RecordKey, RecordData> handledIndexRecords = new BDSkipList<RecordKey, RecordData>();
BDSkipList<RecordKey, RecordData> recordsBeingAssembled = new BDSkipList<RecordKey, RecordData>();
#if DEBUG_SEGMENT_WALK
Console.WriteLine("getNextRecord_LowLevel({0})", lowkey);
#endif
SegmentMemoryBuilder[] layers;
// snapshot the working segment layers
lock (this.store.segmentlayers) {
layers = this.store.segmentlayers.ToArray();
}
DateTime start = DateTime.Now;
// TODO: fix this super-hack to do "minKey/maxKey"
foreach (SegmentMemoryBuilder layer in layers) {
if (layer.RowCount == 0) {
continue;
}
// use the first and last records in the segment as the rangekeys
var segrk = RangeKey.newSegmentRangeKey(
layer.FindNext(null, true).Key,
layer.FindPrev(null, true).Key,
num_generations_persisted);
INTERNAL_segmentWalkForNextKey(
lowkey,
direction_is_forward,
layer,
segrk,
handledIndexRecords,
num_generations_persisted,
recordsBeingAssembled,
equal_ok,
stats: stats);
}
DateTime end = DateTime.Now;
#if DEBUG_SEGMENT_WALK_COUNTERS
Console.WriteLine("getNextRecord({0}) took {1}ms", lowkey, (((end-start).TotalMilliseconds)));
Console.WriteLine(stats);
#endif
// now check the assembled records list
try {
IEnumerable<KeyValuePair<RecordKey, RecordData>> assembled_candidates;
if (direction_is_forward) {
assembled_candidates = recordsBeingAssembled.scanForward(null);
} else {
assembled_candidates = recordsBeingAssembled.scanBackward(null);
}
foreach (var kvp in assembled_candidates) {
if (kvp.Value.State == RecordDataState.FULL) {
key = kvp.Key;
record = kvp.Value;
return GetStatus.PRESENT;
} else if (kvp.Value.State == RecordDataState.DELETED) {
if (tombstone_ok) {
key = kvp.Key;
record = kvp.Value;
return GetStatus.PRESENT;
}
} else {
throw new Exception("invalid record state in getNextRecord, record assembly processing: " +
kvp.Value.State + " k:" + kvp.Key + " v:" + kvp.Value);
}
}
return GetStatus.MISSING;
} catch (KeyNotFoundException) {
return GetStatus.MISSING;
}
}