use of org.apache.accumulo.iteratortest.environments.SimpleIteratorEnvironment in project accumulo by apache.
the class IsolatedDeepCopiesTestCase method consumeMany.
TreeMap<Key, Value> consumeMany(Collection<SortedKeyValueIterator<Key, Value>> iterators, Range range, Collection<ByteSequence> seekColumnFamilies, boolean seekInclusive) throws IOException {
TreeMap<Key, Value> data = new TreeMap<>();
// All of the copies should have consistent results from concurrent use
while (allHasTop(iterators)) {
// occasionally deep copy one of the existing iterators
if (random.nextInt(3) == 0) {
log.debug("Deep-copying and re-seeking an iterator");
SortedKeyValueIterator<Key, Value> newcopy = getRandomElement(iterators).deepCopy(new SimpleIteratorEnvironment());
newcopy.seek(new Range(getTopKey(iterators), true, range.getEndKey(), range.isEndKeyInclusive()), seekColumnFamilies, seekInclusive);
// keep using the new one too, should act like the others
iterators.add(newcopy);
}
data.put(getTopKey(iterators), getTopValue(iterators));
next(iterators);
}
// All of the iterators should be consumed.
for (SortedKeyValueIterator<Key, Value> iter : iterators) {
if (iter.hasTop()) {
return null;
}
}
return data;
}
use of org.apache.accumulo.iteratortest.environments.SimpleIteratorEnvironment in project accumulo by apache.
the class MultipleHasTopCalls method test.
@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());
skvi.seek(testInput.getRange(), testInput.getFamilies(), testInput.isInclusive());
return new IteratorTestOutput(consume(skvi));
} catch (IOException e) {
return new IteratorTestOutput(e);
}
}
Aggregations