public override IndexSample Result() { KEY lowest = _layout.newKey(); lowest.initialize(long.MinValue); lowest.initValuesAsLowest(); KEY highest = _layout.newKey(); highest.initialize(long.MaxValue); highest.initValuesAsHighest(); KEY prev = _layout.newKey(); try { using (RawCursor <Hit <KEY, VALUE>, IOException> seek = _gbpTree.seek(lowest, highest)) { long sampledValues = 0; long uniqueValues = 0; // Get the first one so that prev gets initialized if (seek.Next()) { prev = _layout.copyKey(seek.get().key(), prev); sampledValues++; uniqueValues++; // Then do the rest while (seek.Next()) { Hit <KEY, VALUE> hit = seek.get(); if (_layout.compareValue(prev, hit.Key()) != 0) { uniqueValues++; _layout.copyKey(hit.Key(), prev); } // else this is a duplicate of the previous one sampledValues++; } } return(new IndexSample(sampledValues, uniqueValues, sampledValues)); } } catch (IOException e) { throw new UncheckedIOException(e); } }
private Hit <KEY, VALUE> DeepCopy(Hit <KEY, VALUE> from) { KEY intoKey = Layout.newKey(); VALUE intoValue = Layout.newValue(); Layout.copyKey(from.Key(), intoKey); CopyValue(from.Value(), intoValue); return(new SimpleHit <KEY, VALUE>(intoKey, intoValue)); }
public override bool Next() { try { while (seeker.next()) { KEY key = seeker.get().key(); if (_first) { _first = false; _countForCurrentValue = 1; _layout.copyKey(key, _prev); } else if (_comparator.Compare(_prev, key) == 0) { // same as previous _countForCurrentValue++; } else { // different from previous bool accepted = client.acceptNode(_countForCurrentValue, extractValues(_prev)); _countForCurrentValue = 1; _layout.copyKey(key, _prev); if (accepted) { return(true); } } } bool finalResult = !_first && !_last && client.acceptNode(_countForCurrentValue, extractValues(_prev)); _last = true; return(finalResult); } catch (IOException e) { throw new UncheckedIOException(e); } }