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); } }
public override int Compare(KEY k1, KEY k2) { int comparison = _schemaLayout.compareValue(k1, k2); if (comparison != 0) { return(comparison); } try { return(Values.COMPARATOR.Compare(_propertyAccessor.getNodePropertyValue(k1.EntityId, _propertyKeyId), _propertyAccessor.getNodePropertyValue(k2.EntityId, _propertyKeyId))); } catch (EntityNotFoundException) { // We don't want this operation to fail since it's merely counting distinct values. // This entity not being there is most likely a result of a concurrent deletion happening as we speak. return(comparison); } }