org.apache.accumulo.core.data.Range.contains()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.apache.accumulo.core.data.Range.contains方法的一些代码示例,展示了Range.contains的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Range.contains方法的具体详情如下:
包路径:org.apache.accumulo.core.data.Range
类名称:Range
方法名:contains

Range.contains介绍

[英]Determines if the given key falls within this range.
[中]确定给定的密钥是否在此范围内。

代码示例

代码示例来源:origin: apache/accumulo

/**
 * 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;
}

代码示例来源:origin: apache/accumulo

/**
  * @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());
 }
}

代码示例来源:origin: apache/accumulo

if (startKeysEqual || currentRange.contains(range.start) || (!currentRange.stopKeyInclusive
  && range.startKeyInclusive && range.start.equals(currentRange.stop))) {
 int cmp;

代码示例来源:origin: apache/accumulo

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);
   }
  }
 }
}

代码示例来源:origin: apache/accumulo

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);

代码示例来源:origin: apache/accumulo

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;
}

代码示例来源:origin: apache/accumulo

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);

代码示例来源:origin: org.apache.accumulo/accumulo-core

@Override
 public boolean accept(Key k, Value v) {
  return range.contains(k);
 }
}

代码示例来源:origin: apache/accumulo

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);

代码示例来源:origin: Accla/graphulo

private boolean isInStartNodes(String toNode) {
 Key toKey = new Key(toNode);
 for (Range startNode : startNodes) {
  if (startNode.contains(toKey))
   return true;
 }
 return false;
}

代码示例来源:origin: apache/accumulo

int i = 0;
for (Range range : ranges) {
 if (range.contains(currentKey)) {

代码示例来源:origin: org.apache.accumulo/accumulo-core

/**
 * 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;
}

代码示例来源:origin: Accla/graphulo

@Override
public boolean hasTop() {
 if (!inner.hasNext())
  return false;
 Key k = inner.peek().getKey();
 return seekRng.contains(k);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@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
}

代码示例来源:origin: org.apache.accumulo/accumulo-core

/**
  * @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());
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-server

@Override
public boolean hasNext() {
 return ssi.hasTop() && range.contains(ssi.getTopKey());
}

代码示例来源:origin: apache/accumulo

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;
}

代码示例来源:origin: apache/incubator-rya

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;
}

代码示例来源:origin: NationalSecurityAgency/datawave

@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;
  }
}

代码示例来源:origin: org.apache.rya/accumulo.rya

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;
}

相关文章