use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method test4.
@Test
public void test4() 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");
imm.delete(0);
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());
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());
ski1.seek(new Range(new Text("r2")), LocalityGroupUtil.EMPTY_CF_SET, false);
assertFalse(ski1.hasTop());
ski1.seek(new Range(newKey("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false);
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar2");
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1");
assertFalse(ski1.hasTop());
ski1.close();
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method test5.
@Test
public void test5() throws Exception {
InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
mutate(imm, "r1", "foo:cq1", 3, "bar1");
mutate(imm, "r1", "foo:cq1", 3, "bar2");
mutate(imm, "r1", "foo:cq1", 3, "bar3");
MemoryIterator ski1 = imm.skvIterator(null);
ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false);
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar3");
imm.delete(0);
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar2");
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1");
assertFalse(ski1.hasTop());
ski1.close();
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");
ski1 = imm.skvIterator(null);
ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false);
testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1");
imm.delete(0);
testAndCallNext(ski1, "r1", "foo:cq2", 3, "bar2");
testAndCallNext(ski1, "r1", "foo:cq3", 3, "bar3");
assertFalse(ski1.hasTop());
ski1.close();
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method testSample.
@Test
public void testSample() throws Exception {
SamplerConfigurationImpl sampleConfig = new SamplerConfigurationImpl(RowSampler.class.getName(), ImmutableMap.of("hasher", "murmur3_32", "modulus", "7"));
Sampler sampler = SamplerFactory.newSampler(sampleConfig, DefaultConfiguration.getInstance());
ConfigurationCopy config1 = newConfig(tempFolder.newFolder().getAbsolutePath());
for (Entry<String, String> entry : sampleConfig.toTablePropertiesMap().entrySet()) {
config1.set(entry.getKey(), entry.getValue());
}
ConfigurationCopy config2 = newConfig(tempFolder.newFolder().getAbsolutePath());
config2.set(Property.TABLE_LOCALITY_GROUP_PREFIX + "lg1", LocalityGroupUtil.encodeColumnFamilies(toTextSet("cf2")));
config2.set(Property.TABLE_LOCALITY_GROUPS.getKey(), "lg1");
for (Entry<String, String> entry : sampleConfig.toTablePropertiesMap().entrySet()) {
config2.set(entry.getKey(), entry.getValue());
}
for (ConfigurationCopy config : Arrays.asList(config1, config2)) {
InMemoryMap imm = new InMemoryMap(config);
TreeMap<Key, Value> expectedSample = new TreeMap<>();
TreeMap<Key, Value> expectedAll = new TreeMap<>();
TreeMap<Key, Value> expectedNone = new TreeMap<>();
MemoryIterator iter0 = imm.skvIterator(sampleConfig);
for (int r = 0; r < 100; 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 iter1 = imm.skvIterator(sampleConfig);
MemoryIterator iter2 = imm.skvIterator(null);
SortedKeyValueIterator<Key, Value> iter0dc1 = iter0.deepCopy(new SampleIE());
SortedKeyValueIterator<Key, Value> iter0dc2 = iter0.deepCopy(new SampleIE(sampleConfig));
SortedKeyValueIterator<Key, Value> iter1dc1 = iter1.deepCopy(new SampleIE());
SortedKeyValueIterator<Key, Value> iter1dc2 = iter1.deepCopy(new SampleIE(sampleConfig));
SortedKeyValueIterator<Key, Value> iter2dc1 = iter2.deepCopy(new SampleIE());
SortedKeyValueIterator<Key, Value> iter2dc2 = iter2.deepCopy(new SampleIE(sampleConfig));
assertEquals(expectedNone, readAll(iter0));
assertEquals(expectedNone, readAll(iter0dc1));
assertEquals(expectedNone, readAll(iter0dc2));
assertEquals(expectedSample, readAll(iter1));
assertEquals(expectedAll, readAll(iter2));
assertEquals(expectedAll, readAll(iter1dc1));
assertEquals(expectedAll, readAll(iter2dc1));
assertEquals(expectedSample, readAll(iter1dc2));
assertEquals(expectedSample, readAll(iter2dc2));
imm.delete(0);
assertEquals(expectedNone, readAll(iter0));
assertEquals(expectedNone, readAll(iter0dc1));
assertEquals(expectedNone, readAll(iter0dc2));
assertEquals(expectedSample, readAll(iter1));
assertEquals(expectedAll, readAll(iter2));
assertEquals(expectedAll, readAll(iter1dc1));
assertEquals(expectedAll, readAll(iter2dc1));
assertEquals(expectedSample, readAll(iter1dc2));
assertEquals(expectedSample, readAll(iter2dc2));
SortedKeyValueIterator<Key, Value> iter0dc3 = iter0.deepCopy(new SampleIE());
SortedKeyValueIterator<Key, Value> iter0dc4 = iter0.deepCopy(new SampleIE(sampleConfig));
SortedKeyValueIterator<Key, Value> iter1dc3 = iter1.deepCopy(new SampleIE());
SortedKeyValueIterator<Key, Value> iter1dc4 = iter1.deepCopy(new SampleIE(sampleConfig));
SortedKeyValueIterator<Key, Value> iter2dc3 = iter2.deepCopy(new SampleIE());
SortedKeyValueIterator<Key, Value> iter2dc4 = iter2.deepCopy(new SampleIE(sampleConfig));
assertEquals(expectedNone, readAll(iter0dc3));
assertEquals(expectedNone, readAll(iter0dc4));
assertEquals(expectedAll, readAll(iter1dc3));
assertEquals(expectedAll, readAll(iter2dc3));
assertEquals(expectedSample, readAll(iter1dc4));
assertEquals(expectedSample, readAll(iter2dc4));
iter1.close();
iter2.close();
}
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method testBug1.
@Test
public void testBug1() throws Exception {
InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());
for (int i = 0; i < 20; i++) {
mutate(imm, "r1", "foo:cq" + i, 3, "bar" + i);
}
for (int i = 0; i < 20; i++) {
mutate(imm, "r2", "foo:cq" + i, 3, "bar" + i);
}
MemoryIterator ski1 = imm.skvIterator(null);
ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(ski1);
imm.delete(0);
ArrayList<ByteSequence> columns = new ArrayList<>();
columns.add(new ArrayByteSequence("bar"));
// this seek resulted in an infinite loop before a bug was fixed
cfsi.seek(new Range("r1"), columns, true);
assertFalse(cfsi.hasTop());
ski1.close();
}
use of org.apache.accumulo.tserver.InMemoryMap.MemoryIterator in project accumulo by apache.
the class InMemoryMapTest method testLocalityGroups.
@Test
public void testLocalityGroups() throws Exception {
ConfigurationCopy config = newConfig(tempFolder.newFolder().getAbsolutePath());
config.set(Property.TABLE_LOCALITY_GROUP_PREFIX + "lg1", LocalityGroupUtil.encodeColumnFamilies(toTextSet("cf1", "cf2")));
config.set(Property.TABLE_LOCALITY_GROUP_PREFIX + "lg2", LocalityGroupUtil.encodeColumnFamilies(toTextSet("cf3", "cf4")));
config.set(Property.TABLE_LOCALITY_GROUPS.getKey(), "lg1,lg2");
InMemoryMap imm = new InMemoryMap(config);
Mutation m1 = new Mutation("r1");
m1.put("cf1", "x", 2, "1");
m1.put("cf1", "y", 2, "2");
m1.put("cf3", "z", 2, "3");
m1.put("foo", "b", 2, "9");
Mutation m2 = new Mutation("r2");
m2.put("cf2", "x", 3, "5");
Mutation m3 = new Mutation("r3");
m3.put("foo", "b", 4, "6");
Mutation m4 = new Mutation("r4");
m4.put("foo", "b", 5, "7");
m4.put("cf4", "z", 5, "8");
Mutation m5 = new Mutation("r5");
m5.put("cf3", "z", 6, "A");
m5.put("cf4", "z", 6, "B");
imm.mutate(Arrays.asList(m1, m2, m3, m4, m5));
MemoryIterator iter1 = imm.skvIterator(null);
seekLocalityGroups(iter1);
SortedKeyValueIterator<Key, Value> dc1 = iter1.deepCopy(new SampleIE());
seekLocalityGroups(dc1);
assertTrue(imm.getNumEntries() == 10);
assertTrue(imm.estimatedSizeInBytes() > 0);
imm.delete(0);
seekLocalityGroups(iter1);
seekLocalityGroups(dc1);
// TODO uncomment following when ACCUMULO-1628 is fixed
// seekLocalityGroups(iter1.deepCopy(null));
}
Aggregations