Search in sources :

Example 6 with SimpleIteratorEnvironment

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;
}
Also used : SimpleIteratorEnvironment(org.apache.accumulo.iteratortest.environments.SimpleIteratorEnvironment) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key)

Example 7 with SimpleIteratorEnvironment

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);
    }
}
Also used : IteratorTestOutput(org.apache.accumulo.iteratortest.IteratorTestOutput) SimpleIteratorEnvironment(org.apache.accumulo.iteratortest.environments.SimpleIteratorEnvironment) Value(org.apache.accumulo.core.data.Value) IOException(java.io.IOException) Key(org.apache.accumulo.core.data.Key)

Aggregations

Key (org.apache.accumulo.core.data.Key)7 Value (org.apache.accumulo.core.data.Value)7 SimpleIteratorEnvironment (org.apache.accumulo.iteratortest.environments.SimpleIteratorEnvironment)7 IOException (java.io.IOException)5 IteratorTestOutput (org.apache.accumulo.iteratortest.IteratorTestOutput)5 Range (org.apache.accumulo.core.data.Range)3 TreeMap (java.util.TreeMap)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2 YieldCallback (org.apache.accumulo.core.iterators.YieldCallback)1