use of org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator in project accumulo by apache.
the class InMemoryMap method skvIterator.
public synchronized MemoryIterator skvIterator(SamplerConfigurationImpl iteratorSamplerConfig) {
if (map == null)
throw new NullPointerException();
if (deleted)
throw new IllegalStateException("Can not obtain iterator after map deleted");
int mc = kvCount.get();
MemoryDataSource mds = new MemoryDataSource(iteratorSamplerConfig);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(mds);
MemoryIterator mi = new MemoryIterator(new PartialMutationSkippingIterator(ssi, mc));
mi.setSSI(ssi);
mi.setMDS(mds);
activeIters.add(mi);
return mi;
}
use of org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator in project accumulo by apache.
the class Tablet method checkConditions.
public void checkConditions(ConditionChecker checker, Authorizations authorizations, AtomicBoolean iFlag) throws IOException {
ScanParameters scanParams = new ScanParameters(-1, authorizations, Collections.emptySet(), null, null, false, null, -1, null);
scanParams.setScanDispatch(ScanDispatch.builder().build());
ScanDataSource dataSource = new ScanDataSource(this, scanParams, false, iFlag);
try {
SortedKeyValueIterator<Key, Value> iter = new SourceSwitchingIterator(dataSource);
checker.check(iter);
} catch (IOException ioe) {
dataSource.close(true);
throw ioe;
} finally {
// code in finally block because always want
// to return mapfiles, even when exception is thrown
dataSource.close(false);
}
}
use of org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method testYield.
@Test
public void testYield() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq3", 5, "v2");
put(tm1, "r2", "cf1", "cq1", 5, "v3");
SortedMapIterator smi = new SortedMapIterator(tm1);
YieldingIterator ymi = new YieldingIterator(smi);
TestDataSource tds = new TestDataSource(ymi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds);
YieldCallback<Key> yield = new YieldCallback<>();
ssi.enableYielding(yield);
Range r = new Range();
ssi.seek(r, new ArrayList<>(), false);
r = doYield(r, ssi, yield);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
r = doYield(r, ssi, yield);
testAndCallNext(ssi, "r1", "cf1", "cq3", 5, "v2", true);
r = doYield(r, ssi, yield);
testAndCallNext(ssi, "r2", "cf1", "cq1", 5, "v3", true);
r = doYield(r, ssi, yield);
assertFalse(ssi.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method test2.
@Test
public void test2() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq3", 5, "v2");
put(tm1, "r2", "cf1", "cq1", 5, "v3");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds);
ssi.seek(new Range(), new ArrayList<>(), false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
TreeMap<Key, Value> tm2 = new TreeMap<>();
put(tm2, "r1", "cf1", "cq1", 5, "v4");
put(tm2, "r1", "cf1", "cq3", 5, "v5");
put(tm2, "r2", "cf1", "cq1", 5, "v6");
SortedMapIterator smi2 = new SortedMapIterator(tm2);
tds.next = new TestDataSource(smi2);
testAndCallNext(ssi, "r1", "cf1", "cq3", 5, "v2", true);
testAndCallNext(ssi, "r2", "cf1", "cq1", 5, "v6", true);
assertFalse(ssi.hasTop());
}
use of org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator in project accumulo by apache.
the class SourceSwitchingIteratorTest method testSetInterrupt.
@Test
public void testSetInterrupt() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "cf1", "cq1", 5, "v1");
SortedMapIterator smi = new SortedMapIterator(tm1);
TestDataSource tds = new TestDataSource(smi);
SourceSwitchingIterator ssi = new SourceSwitchingIterator(tds, false);
AtomicBoolean flag = new AtomicBoolean();
ssi.setInterruptFlag(flag);
assertSame(flag, tds.iflag);
final Range r1Range = new Range("r1");
final List<ByteSequence> columnFamilies = List.of();
ssi.seek(r1Range, columnFamilies, false);
testAndCallNext(ssi, "r1", "cf1", "cq1", 5, "v1", true);
assertFalse(ssi.hasTop());
flag.set(true);
assertThrows(IterationInterruptedException.class, () -> ssi.seek(r1Range, columnFamilies, false));
}
Aggregations