private Collection<Range> splitByTabletBoundaries(String tableName, Collection<Range> ranges) throws org.apache.accumulo.core.client.TableNotFoundException, AccumuloException, AccumuloSecurityException { ImmutableSet.Builder<Range> rangeBuilder = ImmutableSet.builder(); for (Range range : ranges) { // if start and end key are equivalent, no need to split the range if (range.getStartKey() != null && range.getEndKey() != null && range.getStartKey().equals(range.getEndKey())) { rangeBuilder.add(range); } else { // Call out to Accumulo to split the range on tablets rangeBuilder.addAll(connector.tableOperations().splitRangeByTablets(tableName, range, Integer.MAX_VALUE)); } } return rangeBuilder.build(); }
private static boolean isExact(Range range) { return !range.isInfiniteStartKey() && !range.isInfiniteStopKey() && range.getStartKey().followingKey(PartialKey.ROW).equals(range.getEndKey()); }
@Override public boolean equals(Object o) { if (o instanceof Key) return this.equals((Key) o, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME_DEL); return false; }
@Override public boolean hasTop() { // only have a top if the prefix matches return hasTop = source.hasTop() && source.getTopKey().equals(prefixKey, keyPrefix); }
public Value get(Key key) { rlock.lock(); try { Value ret = null; NMIterator nmi = new NMIterator(key); if (nmi.hasNext()) { Entry<Key,Value> entry = nmi.next(); if (entry.getKey().equals(key)) { ret = entry.getValue(); } } nmi.delete(); return ret; } finally { rlock.unlock(); } }
Key getTopKey(Collection<SortedKeyValueIterator<Key,Value>> iterators) { boolean first = true; Key topKey = null; for (SortedKeyValueIterator<Key,Value> iter : iterators) { if (first) { topKey = iter.getTopKey(); first = false; } else if (!topKey.equals(iter.getTopKey())) { throw new IllegalStateException( "Inconsistent keys between two iterators: " + topKey + " " + iter.getTopKey()); } } // Copy the key return new Key(topKey); }
@Override protected void advanceToIntersection() throws IOException { super.advanceToIntersection(); if (topKey == null) return; if (log.isTraceEnabled()) log.trace("using top key to seek for doc: {}", topKey); Key docKey = buildDocKey(); docSource.seek(new Range(docKey, true, null, false), docColfSet, true); log.debug("got doc key: {}", docSource.getTopKey()); if (docSource.hasTop() && docKey.equals(docSource.getTopKey(), PartialKey.ROW_COLFAM_COLQUAL)) { value = docSource.getTopValue(); } log.debug("got doc value: {}", value); }
@Override public Entry<Key,Value> next() { if (end == 0) { throw new NoSuchElementException(); } Entry<Key,Value> ret = nextEntries.get(index++); if (index == end) { rlock.lock(); try { fill(); } catch (ConcurrentModificationException cme) { source.delete(); source = new NMIterator(ret.getKey()); fill(); if (end > 0 && nextEntries.get(0).getKey().equals(ret.getKey())) { index++; if (index == end) { fill(); } } } finally { rlock.unlock(); } } return ret; }
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); } } } }
static boolean isRangeInBloomFilter(Range range, PartialKey keyDepth) { if (range.getStartKey() == null || range.getEndKey() == null) { return false; } if (range.getStartKey().equals(range.getEndKey(), keyDepth)) return true; // include everything but the deleted flag in the comparison... return range.getStartKey().followingKey(keyDepth).equals(range.getEndKey(), PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME) && !range.isEndKeyInclusive(); } }
private boolean _hasNext() { return source.hasTop() && !source.getTopKey().isDeleted() && topKey.equals(source.getTopKey(), PartialKey.ROW_COLFAM_COLQUAL_COLVIS); }
private void skipRowColumn() throws IOException { workKey.set(source.getTopKey()); Key keyToSkip = workKey; source.next(); while (source.hasTop() && source.getTopKey().equals(keyToSkip, PartialKey.ROW_COLFAM_COLQUAL_COLVIS)) { source.next(); } }
@Override public void append(Key key, Value val) { // ensure the key provided by the user has the correct prefix if (!key.equals(prefixKey, getKeyPrefix())) throw new IllegalArgumentException("Key prefixes are not equal " + key + " " + prefixKey); // Transformation could have produced a key that falls outside // of the seek range, or one that the user cannot see. Check // these before adding it to the output list. if (includeTransformedKey(key)) { // try to defend against a scan or compaction using all memory in a tablet server if (appened > maxBufferSize) throw new BufferOverflowException( "Exceeded buffer size of " + maxBufferSize + ", prefixKey: " + prefixKey); if (getSource().hasTop() && key == getSource().getTopKey()) key = new Key(key); keys.add(new Pair<>(key, new Value(val))); appened += (key.getSize() + val.getSize() + 128); } } });
while (super.hasTop() && super.getTopKey().equals(prefixKey, getKeyPrefix())) { super.next();
private void skipRowColumn() throws IOException { Key keyToSkip = currentKey; super.next(); int count = 0; SortedKeyValueIterator<Key,Value> source = getSource(); while (source.hasTop() && source.getTopKey().equals(keyToSkip, PartialKey.ROW_COLFAM_COLQUAL_COLVIS)) { if (count < maxCount) { // it is quicker to call next if we are close, but we never know if we are close // so give next a try a few times source.next(); count++; } else { reseek(keyToSkip.followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS)); count = 0; } } }
@Override public void next() throws IOException { if (numVersions >= maxVersions) { skipRowColumn(); resetVersionCount(); return; } super.next(); if (getSource().hasTop()) { if (getSource().getTopKey().equals(currentKey, PartialKey.ROW_COLFAM_COLQUAL_COLVIS)) { numVersions++; } else { resetVersionCount(); } } }
|| (getEndKey() != null && range.getStartKey().equals(getEndKey()) && !(range.isStartKeyInclusive() && isEndKeyInclusive()))) { if (returnNullIfDisjoint) || (getStartKey() != null && range.getEndKey().equals(getStartKey()) && !(range.isEndKeyInclusive() && isStartKeyInclusive()))) { if (returnNullIfDisjoint)
@Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { // do not want to seek to the middle of a value that should be combined... Range seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range); super.seek(seekRange, columnFamilies, inclusive); findTop(); if (range.getStartKey() != null) { while (hasTop() && getTopKey().equals(range.getStartKey(), PartialKey.ROW_COLFAM_COLQUAL_COLVIS) && getTopKey().getTimestamp() > range.getStartKey().getTimestamp()) { // the value has a more recent time stamp, so pass it up // log.debug("skipping "+getTopKey()); next(); } while (hasTop() && range.beforeStartKey(getTopKey())) { next(); } } }