use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method test3.
@Test
public void test3() throws Exception {
InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
mutate(imm, "r1", "foo:cq1", 3, "bar1");
mutate(imm, "r1", "foo:cq1", 3, "bar2");
MemoryIterator ski1 = imm.skvIterator(null);
mutate(imm, "r1", "foo:cq1", 3, "bar3");
mutate(imm, "r3", "foo:cq1", 3, "bar9");
mutate(imm, "r3", "foo:cq1", 3, "bara");
MemoryIterator ski2 = imm.skvIterator(null);
ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false);
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar2");
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1");
assertFalse(ski1.hasTop());
ski2.seek(new Range(new Text("r3")), LocalityGroupUtil.EMPTY_CF_SET, false);
testAndCallNext(ski2, "r3", "foo:cq1", 3, "bara");
testAndCallNext(ski2, "r3", "foo:cq1", 3, "bar9");
assertFalse(ski1.hasTop());
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method test2.
@Test
public void test2() throws Exception {
InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
MemoryIterator ski1 = imm.skvIterator(null);
mutate(imm, "r1", "foo:cq1", 3, "bar1");
MemoryIterator ski2 = imm.skvIterator(null);
ski1.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
assertFalse(ski1.hasTop());
ski2.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
assertTrue(ski2.hasTop());
testAndCallNext(ski2, "r1", "foo:cq1", 3, "bar1");
assertFalse(ski2.hasTop());
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method testNoSampleConfig.
@Test(expected = SampleNotPresentException.class)
public void testNoSampleConfig() throws Exception {
InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
mutate(imm, "r", "cf:cq", 5, "b");
SamplerConfigurationImpl sampleConfig2 = new SamplerConfigurationImpl(RowSampler.class.getName(), ImmutableMap.of("hasher", "murmur3_32", "modulus", "9"));
MemoryIterator iter = imm.skvIterator(sampleConfig2);
iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method runInterruptSampleTest.
private void runInterruptSampleTest(boolean deepCopy, boolean delete, boolean dcAfterDelete) throws Exception {
SamplerConfigurationImpl sampleConfig1 = new SamplerConfigurationImpl(RowSampler.class.getName(), ImmutableMap.of("hasher", "murmur3_32", "modulus", "2"));
Sampler sampler = SamplerFactory.newSampler(sampleConfig1, DefaultConfiguration.getInstance());
ConfigurationCopy config1 = newConfig(tempFolder.newFolder().getAbsolutePath());
for (Entry<String, String> entry : sampleConfig1.toTablePropertiesMap().entrySet()) {
config1.set(entry.getKey(), entry.getValue());
}
InMemoryMap imm = new InMemoryMap(config1);
TreeMap<Key, Value> expectedSample = new TreeMap<>();
TreeMap<Key, Value> expectedAll = new TreeMap<>();
for (int r = 0; r < 1000; r++) {
String row = String.format("r%06d", r);
mutate(imm, row, "cf1:cq1", 5, "v" + (2 * r), sampler, expectedSample, expectedAll);
mutate(imm, row, "cf2:cq2", 5, "v" + ((2 * r) + 1), sampler, expectedSample, expectedAll);
}
assertTrue(expectedSample.size() > 0);
MemoryIterator miter = imm.skvIterator(sampleConfig1);
AtomicBoolean iFlag = new AtomicBoolean(false);
miter.setInterruptFlag(iFlag);
SortedKeyValueIterator<Key, Value> iter = miter;
if (delete && !dcAfterDelete) {
imm.delete(0);
}
if (deepCopy) {
iter = iter.deepCopy(new SampleIE(sampleConfig1));
}
if (delete && dcAfterDelete) {
imm.delete(0);
}
assertEquals(expectedSample, readAll(iter));
iFlag.set(true);
try {
readAll(iter);
Assert.fail();
} catch (IterationInterruptedException iie) {
}
miter.close();
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method testDeferredSamplerCreation.
@Test
public void testDeferredSamplerCreation() throws Exception {
SamplerConfigurationImpl sampleConfig1 = new SamplerConfigurationImpl(RowSampler.class.getName(), ImmutableMap.of("hasher", "murmur3_32", "modulus", "9"));
ConfigurationCopy config1 = newConfig(tempFolder.newFolder().getAbsolutePath());
for (Entry<String, String> entry : sampleConfig1.toTablePropertiesMap().entrySet()) {
config1.set(entry.getKey(), entry.getValue());
}
InMemoryMap imm = new InMemoryMap(config1);
// change sampler config after creating in mem map.
SamplerConfigurationImpl sampleConfig2 = new SamplerConfigurationImpl(RowSampler.class.getName(), ImmutableMap.of("hasher", "murmur3_32", "modulus", "7"));
for (Entry<String, String> entry : sampleConfig2.toTablePropertiesMap().entrySet()) {
config1.set(entry.getKey(), entry.getValue());
}
TreeMap<Key, Value> expectedSample = new TreeMap<>();
TreeMap<Key, Value> expectedAll = new TreeMap<>();
Sampler sampler = SamplerFactory.newSampler(sampleConfig2, config1);
for (int i = 0; i < 100; i++) {
mutate(imm, "r" + i, "cf:cq", 5, "v" + i, sampler, expectedSample, expectedAll);
}
MemoryIterator iter = imm.skvIterator(sampleConfig2);
iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
Assert.assertEquals(expectedSample, readAll(iter));
SortedKeyValueIterator<Key, Value> dc = iter.deepCopy(new SampleIE(sampleConfig2));
dc.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
Assert.assertEquals(expectedSample, readAll(dc));
iter = imm.skvIterator(null);
iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
Assert.assertEquals(expectedAll, readAll(iter));
iter = imm.skvIterator(sampleConfig1);
thrown.expect(SampleNotPresentException.class);
iter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
}
Aggregations