Search in sources :

Example 6 with MemoryIterator

use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.

the class InMemoryMapTest method testDecodeValueModification.

@Test
public void testDecodeValueModification() throws Exception {
    // This test case is the fix for ACCUMULO-4483
    InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
    mutate(imm, "r1", "foo:cq1", 3, "");
    MemoryIterator ski1 = imm.skvIterator(null);
    imm.delete(0);
    ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false);
    assertEqualsNoNext(ski1, "r1", "foo:cq1", 3, "");
    ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false);
    testAndCallNext(ski1, "r1", "foo:cq1", 3, "");
    assertFalse(ski1.hasTop());
    ski1.close();
}
Also used : MemoryIterator(org.apache.accumulo.tserver.InMemoryMap.MemoryIterator) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 7 with MemoryIterator

use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.

the class InMemoryMapTest method testEmptyNoSampleConfig.

@Test
public void testEmptyNoSampleConfig() throws Exception {
    InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
    SamplerConfigurationImpl sampleConfig2 = new SamplerConfigurationImpl(RowSampler.class.getName(), ImmutableMap.of("hasher", "murmur3_32", "modulus", "9"));
    // when in mem map is empty should be able to get sample iterator with any sample config
    MemoryIterator iter = imm.skvIterator(sampleConfig2);
    iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
    Assert.assertFalse(iter.hasTop());
}
Also used : RowSampler(org.apache.accumulo.core.client.sample.RowSampler) SamplerConfigurationImpl(org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl) MemoryIterator(org.apache.accumulo.tserver.InMemoryMap.MemoryIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 8 with MemoryIterator

use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.

the class InMemoryMapTest method deepCopyAndDelete.

private void deepCopyAndDelete(int interleaving, boolean interrupt) throws Exception {
    // interleaving == 0 intentionally omitted, this runs the test w/o deleting in mem map
    InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
    mutate(imm, "r1", "foo:cq1", 3, "bar1");
    mutate(imm, "r1", "foo:cq2", 3, "bar2");
    MemoryIterator ski1 = imm.skvIterator(null);
    AtomicBoolean iflag = new AtomicBoolean(false);
    ski1.setInterruptFlag(iflag);
    if (interleaving == 1) {
        imm.delete(0);
        if (interrupt)
            iflag.set(true);
    }
    SortedKeyValueIterator<Key, Value> dc = ski1.deepCopy(new SampleIE());
    if (interleaving == 2) {
        imm.delete(0);
        if (interrupt)
            iflag.set(true);
    }
    dc.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
    ski1.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
    if (interleaving == 3) {
        imm.delete(0);
        if (interrupt)
            iflag.set(true);
    }
    testAndCallNext(dc, "r1", "foo:cq1", 3, "bar1");
    testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1");
    dc.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
    if (interleaving == 4) {
        imm.delete(0);
        if (interrupt)
            iflag.set(true);
    }
    testAndCallNext(ski1, "r1", "foo:cq2", 3, "bar2");
    testAndCallNext(dc, "r1", "foo:cq1", 3, "bar1");
    testAndCallNext(dc, "r1", "foo:cq2", 3, "bar2");
    assertFalse(dc.hasTop());
    assertFalse(ski1.hasTop());
    if (interrupt)
        dc.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MemoryIterator(org.apache.accumulo.tserver.InMemoryMap.MemoryIterator) Value(org.apache.accumulo.core.data.Value) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key)

Example 9 with MemoryIterator

use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.

the class InMemoryMapTest method testSeekBackWards.

@Test
public void testSeekBackWards() throws Exception {
    InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
    mutate(imm, "r1", "foo:cq1", 3, "bar1");
    mutate(imm, "r1", "foo:cq2", 3, "bar2");
    mutate(imm, "r1", "foo:cq3", 3, "bar3");
    mutate(imm, "r1", "foo:cq4", 3, "bar4");
    MemoryIterator skvi1 = imm.skvIterator(null);
    skvi1.seek(new Range(newKey("r1", "foo:cq3", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
    testAndCallNext(skvi1, "r1", "foo:cq3", 3, "bar3");
    skvi1.seek(new Range(newKey("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
    testAndCallNext(skvi1, "r1", "foo:cq1", 3, "bar1");
}
Also used : MemoryIterator(org.apache.accumulo.tserver.InMemoryMap.MemoryIterator) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 10 with MemoryIterator

use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.

the class InMemoryMapTest method test6.

@Test
public void test6() throws Exception {
    InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
    mutate(imm, "r1", "foo:cq1", 3, "bar1");
    mutate(imm, "r1", "foo:cq2", 3, "bar2");
    mutate(imm, "r1", "foo:cq3", 3, "bar3");
    mutate(imm, "r1", "foo:cq4", 3, "bar4");
    MemoryIterator ski1 = imm.skvIterator(null);
    mutate(imm, "r1", "foo:cq5", 3, "bar5");
    SortedKeyValueIterator<Key, Value> dc = ski1.deepCopy(new SampleIE());
    ski1.seek(new Range(newKey("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
    testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1");
    dc.seek(new Range(newKey("r1", "foo:cq2", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
    testAndCallNext(dc, "r1", "foo:cq2", 3, "bar2");
    imm.delete(0);
    testAndCallNext(ski1, "r1", "foo:cq2", 3, "bar2");
    testAndCallNext(dc, "r1", "foo:cq3", 3, "bar3");
    testAndCallNext(ski1, "r1", "foo:cq3", 3, "bar3");
    testAndCallNext(dc, "r1", "foo:cq4", 3, "bar4");
    testAndCallNext(ski1, "r1", "foo:cq4", 3, "bar4");
    assertFalse(ski1.hasTop());
    assertFalse(dc.hasTop());
    ski1.seek(new Range(newKey("r1", "foo:cq3", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
    dc.seek(new Range(newKey("r1", "foo:cq4", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
    testAndCallNext(dc, "r1", "foo:cq4", 3, "bar4");
    assertFalse(dc.hasTop());
    testAndCallNext(ski1, "r1", "foo:cq3", 3, "bar3");
    testAndCallNext(ski1, "r1", "foo:cq4", 3, "bar4");
    assertFalse(ski1.hasTop());
    assertFalse(dc.hasTop());
    ski1.close();
}
Also used : MemoryIterator(org.apache.accumulo.tserver.InMemoryMap.MemoryIterator) Value(org.apache.accumulo.core.data.Value) Range(org.apache.accumulo.core.data.Range) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

MemoryIterator (org.apache.accumulo.tserver.InMemoryMap.MemoryIterator)17 Test (org.junit.Test)15 Range (org.apache.accumulo.core.data.Range)14 Value (org.apache.accumulo.core.data.Value)7 RowSampler (org.apache.accumulo.core.client.sample.RowSampler)6 Key (org.apache.accumulo.core.data.Key)6 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)6 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)5 Text (org.apache.hadoop.io.Text)5 TreeMap (java.util.TreeMap)3 Sampler (org.apache.accumulo.core.client.sample.Sampler)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Mutation (org.apache.accumulo.core.data.Mutation)2 ArrayList (java.util.ArrayList)1 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)1 ByteSequence (org.apache.accumulo.core.data.ByteSequence)1 IterationInterruptedException (org.apache.accumulo.core.iterators.IterationInterruptedException)1 ColumnFamilySkippingIterator (org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator)1