Search in sources :

Example 6 with SourceSwitchingIterator

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;
}
Also used : SourceSwitchingIterator(org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator)

Example 7 with SourceSwitchingIterator

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);
    }
}
Also used : ScanParameters(org.apache.accumulo.tserver.scan.ScanParameters) Value(org.apache.accumulo.core.data.Value) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) IOException(java.io.IOException) SourceSwitchingIterator(org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator) Key(org.apache.accumulo.core.data.Key)

Example 8 with SourceSwitchingIterator

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());
}
Also used : YieldCallback(org.apache.accumulo.core.iterators.YieldCallback) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) SourceSwitchingIterator(org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) Test(org.junit.jupiter.api.Test)

Example 9 with SourceSwitchingIterator

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());
}
Also used : Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) SourceSwitchingIterator(org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) Test(org.junit.jupiter.api.Test)

Example 10 with SourceSwitchingIterator

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));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Value(org.apache.accumulo.core.data.Value) TreeMap(java.util.TreeMap) SortedMapIterator(org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator) SourceSwitchingIterator(org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) ByteSequence(org.apache.accumulo.core.data.ByteSequence) Test(org.junit.jupiter.api.Test)

Aggregations

SourceSwitchingIterator (org.apache.accumulo.core.iteratorsImpl.system.SourceSwitchingIterator)11 Key (org.apache.accumulo.core.data.Key)10 Value (org.apache.accumulo.core.data.Value)10 Range (org.apache.accumulo.core.data.Range)9 TreeMap (java.util.TreeMap)7 PartialKey (org.apache.accumulo.core.data.PartialKey)7 SortedMapIterator (org.apache.accumulo.core.iteratorsImpl.system.SortedMapIterator)7 Test (org.junit.jupiter.api.Test)7 IOException (java.io.IOException)3 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ByteSequence (org.apache.accumulo.core.data.ByteSequence)1 YieldCallback (org.apache.accumulo.core.iterators.YieldCallback)1 IterationInterruptedException (org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException)1 ScanParameters (org.apache.accumulo.tserver.scan.ScanParameters)1