org.apache.accumulo.core.iterators.YieldingKeyValueIterator.enableYielding()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(103)

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

YieldingKeyValueIterator.enableYielding介绍

[英]Allows implementations to preempt further iteration of this iterator in the current RPC. Implementations can use the yield method on the callback to instruct the caller to cease collecting more results within this RPC. An implementation would only need to implement this mechanism if a next or seek call has been taking so long as to starve out other scans within the same thread pool. Most iterators do not need to implement this method. The yield method on the callback accepts a Key which will be used as the start key (non-inclusive) on the seek call in the next RPC. This feature is not supported for isolated scans.
[中]允许实现抢占当前RPC中此迭代器的进一步迭代。实现可以在回调上使用yield方法来指示调用方停止在此RPC中收集更多结果。如果下一个或seek调用花费了很长时间来耗尽同一线程池中的其他扫描,则实现只需要实现此机制。大多数迭代器不需要实现这种方法。回调上的yield方法接受一个键,该键将用作下一个RPC中seek调用的开始键(非包含键)。隔离扫描不支持此功能。

代码示例

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

@Override
public void enableYielding(YieldCallback<Key> yield) {
 this.yield = Optional.of(yield);
 // if we require row isolation, then we cannot support yielding in the middle.
 if (!onlySwitchAfterRow) {
  if (iter != null && iter instanceof YieldingKeyValueIterator) {
   ((YieldingKeyValueIterator<Key,Value>) iter).enableYielding(yield);
  }
 }
}

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

@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
  throws IOException {
 synchronized (copies) {
  this.range = range;
  this.inclusive = inclusive;
  this.columnFamilies = columnFamilies;
  if (iter == null) {
   iter = source.iterator();
   if (!onlySwitchAfterRow && yield.isPresent()) {
    if (iter instanceof YieldingKeyValueIterator) {
     ((YieldingKeyValueIterator<Key,Value>) iter).enableYielding(yield.get());
    }
   }
  }
  readNext(true);
 }
}

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

private boolean switchSource() throws IOException {
 if (!source.isCurrent()) {
  source = source.getNewDataSource();
  iter = source.iterator();
  if (!onlySwitchAfterRow && yield.isPresent()) {
   if (iter instanceof YieldingKeyValueIterator) {
    ((YieldingKeyValueIterator<Key,Value>) iter).enableYielding(yield.get());
   }
  }
  return true;
 }
 return false;
}

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

((YieldingKeyValueIterator<Key,Value>) iter).enableYielding(yield);

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

((YieldingKeyValueIterator<Key,Value>) mmfi).enableYielding(yield);
boolean yielded = false;

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

@Override
public IteratorTestOutput test(IteratorTestInput testInput) {
 final SortedKeyValueIterator<Key,Value> skvi = IteratorTestUtil.instantiateIterator(testInput);
 final SortedKeyValueIterator<Key,Value> source = IteratorTestUtil.createSource(testInput);
 try {
  skvi.init(source, testInput.getIteratorOptions(), new SimpleIteratorEnvironment());
  YieldCallback<Key> yield = new YieldCallback<>();
  if (skvi instanceof YieldingKeyValueIterator) {
   ((YieldingKeyValueIterator<Key,Value>) skvi).enableYielding(yield);
  }
  skvi.seek(testInput.getRange(), testInput.getFamilies(), testInput.isInclusive());
  return new IteratorTestOutput(consume(testInput, skvi, yield));
 } catch (IOException e) {
  return new IteratorTestOutput(e);
 }
}

相关文章

YieldingKeyValueIterator类方法