本文整理了Java中org.apache.accumulo.core.iterators.YieldCallback
类的一些代码示例,展示了YieldCallback
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YieldCallback
类的具体详情如下:
包路径:org.apache.accumulo.core.iterators.YieldCallback
类名称:YieldCallback
[英]This callback handles the state of yielding within an iterator
[中]这个回调处理迭代器中的屈服状态
代码示例来源:origin: apache/accumulo
boolean skipContinueKey = false;
YieldCallback<Key> yield = new YieldCallback<>();
if (yield.hasYielded()) {
throw new IOException(
"Coding error: hasTop returned true but has yielded at " + yield.getPositionAndReset());
if (yield.hasYielded()) {
continueKey = new Key(yield.getPositionAndReset());
skipContinueKey = true;
if (!range.contains(continueKey)) {
代码示例来源: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: org.apache.accumulo/accumulo-test
@Override
public boolean hasTop() {
return (!(yield.isPresent() && yield.get().hasYielded()) && super.hasTop());
}
代码示例来源:origin: apache/accumulo
@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<>();
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);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Override
public void next() throws IOException {
log.info("start YieldingIterator.next: " + getTopValue());
boolean yielded = false;
// yield on every other next call.
yieldNextKey.set(!yieldNextKey.get());
if (yield.isPresent() && yieldNextKey.get()) {
yielded = true;
yieldNexts.incrementAndGet();
// since we are not actually skipping keys underneath, simply use the key following the top
// key as the yield key
yield.get().yield(getTopKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME));
log.info("end YieldingIterator.next: yielded at " + getTopKey());
}
// if not yielding, then simply pass on the next call
if (!yielded) {
super.next();
log.info("end YieldingIterator.next: "
+ (hasTop() ? getTopKey() + " " + getTopValue() : "no top"));
}
}
代码示例来源:origin: apache/accumulo
boolean yielded = (yield.isPresent() && yield.get().hasYielded());
iter.seek(range, columnFamilies, inclusive);
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: "
if (yield.isPresent() && yield.get().hasYielded()) {
throw new IOException("Coding error: hasTop returned true but has yielded at "
+ yield.get().getPositionAndReset());
代码示例来源: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);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
throws IOException {
log.info("start YieldingIterator.seek: " + getTopValue() + " with range " + range);
boolean yielded = false;
if (!range.isStartKeyInclusive()) {
rebuilds.incrementAndGet();
// yield on every other seek call.
yieldSeekKey.set(!yieldSeekKey.get());
if (yield.isPresent() && yieldSeekKey.get()) {
yielded = true;
yieldSeeks.incrementAndGet();
// since we are not actually skipping keys underneath, simply use the key following the
// range start key
yield.get()
.yield(range.getStartKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME));
log.info("end YieldingIterator.next: yielded at " + range.getStartKey());
}
}
// if not yielding, then simply pass on the call to the source
if (!yielded) {
super.seek(range, columnFamilies, inclusive);
log.info("end YieldingIterator.seek: "
+ (hasTop() ? getTopKey() + " " + getTopValue() : "no top"));
}
}
代码示例来源:origin: apache/accumulo
YieldCallback<Key> yield = new YieldCallback<>();
mmfi.enableYielding(yield);
boolean yielded = false;
if (yield.hasYielded()) {
throw new IOException("Coding error: hasTop returned true but has yielded at "
+ yield.getPositionAndReset());
if (yield.hasYielded()) {
yielded = true;
Key yieldPosition = yield.getPositionAndReset();
if (!range.contains(yieldPosition)) {
throw new IOException("Underlying iterator yielded to a position outside of its range: "
代码示例来源:origin: org.apache.accumulo/accumulo-iterator-test-harness
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: org.apache.accumulo/accumulo-tserver
boolean skipContinueKey = false;
YieldCallback<Key> yield = new YieldCallback<>();
if (yield.hasYielded()) {
throw new IOException(
"Coding error: hasTop returned true but has yielded at " + yield.getPositionAndReset());
if (yield.hasYielded()) {
continueKey = new Key(yield.getPositionAndReset());
skipContinueKey = true;
if (!range.contains(continueKey)) {
代码示例来源:origin: org.apache.accumulo/accumulo-core
boolean yielded = (yield.isPresent() && yield.get().hasYielded());
iter.seek(range, columnFamilies, inclusive);
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: "
if (yield.isPresent() && yield.get().hasYielded()) {
throw new IOException("Coding error: hasTop returned true but has yielded at "
+ yield.get().getPositionAndReset());
代码示例来源:origin: org.apache.accumulo/accumulo-tserver
YieldCallback<Key> yield = new YieldCallback<>();
if (mmfi instanceof YieldingKeyValueIterator)
((YieldingKeyValueIterator<Key,Value>) mmfi).enableYielding(yield);
if (yield.hasYielded()) {
throw new IOException("Coding error: hasTop returned true but has yielded at "
+ yield.getPositionAndReset());
if (yield.hasYielded()) {
yielded = true;
Key yieldPosition = yield.getPositionAndReset();
if (!range.contains(yieldPosition)) {
throw new IOException("Underlying iterator yielded to a position outside of its range: "
内容来源于网络,如有侵权,请联系作者删除!