/** * Determines whether or not to include {@code transformedKey} in the output. It is possible that * transformation could have produced a key that falls outside of the seek range, a key with a * visibility the user can't see, a key with a visibility that doesn't parse, or a key with a * column family that wasn't fetched. We only do some checks (outside the range, user can see) if * we're scanning. The range check is not done for major/minor compaction since seek ranges won't * be in our transformed key space and we will never change the row so we can't produce keys that * would fall outside the tablet anyway. * * @param transformedKey * the key to check * @return {@code true} if the key should be included and {@code false} if not */ protected boolean includeTransformedKey(Key transformedKey) { boolean include = canSee(transformedKey); if (scanning && seekRange != null) { include = include && seekRange.contains(transformedKey); } return include; }
/** * @return True if there is a valid topKey which falls into the range this TermSource's iterator * was last seeked to, false otherwise. */ boolean hasEntryForTerm() { if (!iter.hasTop()) { return false; } return currentRange.contains(iter.getTopKey()); } }
if (startKeysEqual || currentRange.contains(range.start) || (!currentRange.stopKeyInclusive && range.startKeyInclusive && range.start.equals(currentRange.stop))) { int cmp;
static void trackScanning(Map<KeyExtent,List<Range>> failures, Map<KeyExtent,List<Range>> unscanned, MultiScanResult scanResult) { // translate returned failures, remove them from unscanned, and add them to failures Map<KeyExtent,List<Range>> retFailures = Translator.translate(scanResult.failures, Translators.TKET, new Translator.ListTranslator<>(Translators.TRT)); unscanned.keySet().removeAll(retFailures.keySet()); failures.putAll(retFailures); // translate full scans and remove them from unscanned HashSet<KeyExtent> fullScans = new HashSet<>( Translator.translate(scanResult.fullScans, Translators.TKET)); unscanned.keySet().removeAll(fullScans); // remove partial scan from unscanned if (scanResult.partScan != null) { KeyExtent ke = new KeyExtent(scanResult.partScan); Key nextKey = new Key(scanResult.partNextKey); ListIterator<Range> iterator = unscanned.get(ke).listIterator(); while (iterator.hasNext()) { Range range = iterator.next(); if (range.afterEndKey(nextKey) || (nextKey.equals(range.getEndKey()) && scanResult.partNextKeyInclusive != range.isEndKeyInclusive())) { iterator.remove(); } else if (range.contains(nextKey)) { iterator.remove(); Range partRange = new Range(nextKey, scanResult.partNextKeyInclusive, range.getEndKey(), range.isEndKeyInclusive()); iterator.add(partRange); } } } }
continueKey = new Key(yield.getPositionAndReset()); skipContinueKey = true; if (!range.contains(continueKey)) { throw new IOException("Underlying iterator yielded to a position outside of its range: " + continueKey + " not in " + range);
TreeMap<Key,Value> consume(IteratorTestInput testInput, SortedKeyValueIterator<Key,Value> skvi, YieldCallback<Key> yield) throws IOException { TreeMap<Key,Value> data = new TreeMap<>(); Key lastKey = null; while (yield.hasYielded() || skvi.hasTop()) { if (yield.hasYielded()) { Range r = testInput.getRange(); Key yieldPosition = yield.getPositionAndReset(); if (!r.contains(yieldPosition)) { throw new IOException("Underlying iterator yielded to a position outside of its range: " + yieldPosition + " not in " + r); } if (skvi.hasTop()) { throw new IOException( "Underlying iterator reports having a top, but has yielded: " + yieldPosition); } if (lastKey != null && yieldPosition.compareTo(lastKey) <= 0) { throw new IOException( "Underlying iterator yielded at a position that is not past the last key returned"); } skvi.seek(new Range(yieldPosition, false, r.getEndKey(), r.isEndKeyInclusive()), testInput.getFamilies(), testInput.isInclusive()); } else { // Make sure to copy the K-V data.put(new Key(skvi.getTopKey()), new Value(skvi.getTopValue())); skvi.next(); } } return data; }
yielded = true; Key yieldPosition = yield.getPositionAndReset(); if (!range.contains(yieldPosition)) { throw new IOException("Underlying iterator yielded to a position outside of its range: " + yieldPosition + " not in " + range);
@Override public boolean accept(Key k, Value v) { return range.contains(k); } }
else if (yielded) { Key yieldPosition = yield.get().getPositionAndReset(); if (!range.contains(yieldPosition)) { throw new IOException("Underlying iterator yielded to a position outside of its range: " + yieldPosition + " not in " + range);
private boolean isInStartNodes(String toNode) { Key toKey = new Key(toNode); for (Range startNode : startNodes) { if (startNode.contains(toKey)) return true; } return false; }
int i = 0; for (Range range : ranges) { if (range.contains(currentKey)) {
/** * Determines whether or not to include {@code transformedKey} in the output. It is possible that * transformation could have produced a key that falls outside of the seek range, a key with a * visibility the user can't see, a key with a visibility that doesn't parse, or a key with a * column family that wasn't fetched. We only do some checks (outside the range, user can see) if * we're scanning. The range check is not done for major/minor compaction since seek ranges won't * be in our transformed key space and we will never change the row so we can't produce keys that * would fall outside the tablet anyway. * * @param transformedKey * the key to check * @return {@code true} if the key should be included and {@code false} if not */ protected boolean includeTransformedKey(Key transformedKey) { boolean include = canSee(transformedKey); if (scanning && seekRange != null) { include = include && seekRange.contains(transformedKey); } return include; }
@Override public boolean hasTop() { if (!inner.hasNext()) return false; Key k = inner.peek().getKey(); return seekRng.contains(k); }
@Override public boolean hasTop() { if (!inner.hasNext()) return false; Key k = inner.peek().getKey(); return seekRng.contains(k); // do not return entries past the seek() range }
/** * @return True if there is a valid topKey which falls into the range this TermSource's iterator * was last seeked to, false otherwise. */ boolean hasEntryForTerm() { if (!iter.hasTop()) { return false; } return currentRange.contains(iter.getTopKey()); } }
@Override public boolean hasNext() { return ssi.hasTop() && range.contains(ssi.getTopKey()); }
public float getProgress(Key currentKey) { if (currentKey == null) return 0f; if (range.contains(currentKey)) { if (range.getStartKey() != null && range.getEndKey() != null) { if (range.getStartKey().compareTo(range.getEndKey(), PartialKey.ROW) != 0) { // just look at the row progress return getProgress(range.getStartKey().getRowData(), range.getEndKey().getRowData(), currentKey.getRowData()); } else if (range.getStartKey().compareTo(range.getEndKey(), PartialKey.ROW_COLFAM) != 0) { // just look at the column family progress return getProgress(range.getStartKey().getColumnFamilyData(), range.getEndKey().getColumnFamilyData(), currentKey.getColumnFamilyData()); } else if (range.getStartKey().compareTo(range.getEndKey(), PartialKey.ROW_COLFAM_COLQUAL) != 0) { // just look at the column qualifier progress return getProgress(range.getStartKey().getColumnQualifierData(), range.getEndKey().getColumnQualifierData(), currentKey.getColumnQualifierData()); } } } // if we can't figure it out, then claim no progress return 0f; }
public Collection<BindingSet> containsKey(Key key) { Set<BindingSet> bsSet = new HashSet<>(); for (Range range : ranges.keySet()) { // Check to see if the Key falls within Range and has same ColumnFamily // as beginning and ending key of Range. // The additional ColumnFamily check by the method // validateContext(...) is necessary because range.contains(key) // returns true if only the Row is within the Range but the ColumnFamily // doesn't fall within the Range ColumnFamily bounds. if (range.contains(key) && validateContext(key.getColumnFamily(), range.getStartKey().getColumnFamily(), range.getEndKey().getColumnFamily())) { bsSet.addAll(ranges.get(range)); } } return bsSet; }
@Override public Key nextSeekKey(List<String> fields, Key currentKey, Range currentRange, String separator) { Key startKey = currentRange.getStartKey(); Key endKey = currentRange.getEndKey(); List<String> values = Arrays.asList(currentKey.getRow().toString().split(separator)); List<String> startValues = Arrays.asList(startKey.getRow().toString().split(separator)); List<String> endValues = Arrays.asList(endKey.getRow().toString().split(separator)); String nextLowerBound = nextLowerBound(fields, values, separator, startValues, currentRange.isStartKeyInclusive(), endValues, currentRange.isEndKeyInclusive()); Key newStartKey = new Key(new Text(nextLowerBound), startKey.getColumnFamily(), startKey.getColumnQualifier(), startKey.getColumnVisibility(), 0L); // return a new seek key only if it falls within the current range if (currentRange.contains(newStartKey)) return newStartKey; return startKey; } }
public Collection<BindingSet> containsKey(Key key) { Set<BindingSet> bsSet = new HashSet<>(); for (Range range : ranges.keySet()) { // Check to see if the Key falls within Range and has same ColumnFamily // as beginning and ending key of Range. // The additional ColumnFamily check by the method // validateContext(...) is necessary because range.contains(key) // returns true if only the Row is within the Range but the ColumnFamily // doesn't fall within the Range ColumnFamily bounds. if (range.contains(key) && validateContext(key.getColumnFamily(), range.getStartKey().getColumnFamily(), range.getEndKey().getColumnFamily())) { bsSet.addAll(ranges.get(range)); } } return bsSet; }