use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RFileMetricsTest method oneEntryNonDefaultLocGroup.
@Test
public void oneEntryNonDefaultLocGroup() throws IOException {
// test an rfile with two entries in a non-default locality group
trf.openWriter(false);
Set<ByteSequence> lg1 = new HashSet<>();
lg1.add(new ArrayByteSequence("cf1"));
trf.writer.startNewLocalityGroup("lg1", lg1);
trf.writer.append(RFileTest.newKey("r1", "cf1", "cq1", "L1", 55), RFileTest.newValue("foo"));
trf.closeWriter();
trf.openReader(false);
VisMetricsGatherer vmg = trf.gatherMetrics();
AtomicLongMap<String> metrics = vmg.metric.get("lg1");
AtomicLongMap<String> blocks = vmg.blocks.get("lg1");
assertEquals(1, metrics.get("L1"));
assertEquals(1, blocks.get("L1"));
assertEquals(1, vmg.numEntries.get(vmg.localityGroups.indexOf("lg1")).longValue());
assertEquals(1, vmg.numBlocks.get(vmg.localityGroups.indexOf("lg1")).longValue());
trf.closeReader();
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RelativeKeyTest method testCommonPrefix.
@Test
public void testCommonPrefix() {
// exact matches
ArrayByteSequence exact = new ArrayByteSequence("abc");
assertEquals(-1, RelativeKey.getCommonPrefix(exact, exact));
assertEquals(-1, commonPrefixHelper("", ""));
assertEquals(-1, commonPrefixHelper("a", "a"));
assertEquals(-1, commonPrefixHelper("aa", "aa"));
assertEquals(-1, commonPrefixHelper("aaa", "aaa"));
assertEquals(-1, commonPrefixHelper("abab", "abab"));
assertEquals(-1, commonPrefixHelper(new String("aaa"), new ArrayByteSequence("aaa").toString()));
assertEquals(-1, commonPrefixHelper("abababababab".substring(3, 6), "ccababababcc".substring(3, 6)));
// no common prefix
assertEquals(0, commonPrefixHelper("", "a"));
assertEquals(0, commonPrefixHelper("a", ""));
assertEquals(0, commonPrefixHelper("a", "b"));
assertEquals(0, commonPrefixHelper("aaaa", "bbbb"));
// some common prefix
assertEquals(1, commonPrefixHelper("a", "ab"));
assertEquals(1, commonPrefixHelper("ab", "ac"));
assertEquals(1, commonPrefixHelper("ab", "ac"));
assertEquals(2, commonPrefixHelper("aa", "aaaa"));
assertEquals(4, commonPrefixHelper("aaaaa", "aaaab"));
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class LargeRowFilterTest method testCompaction.
public void testCompaction() throws Exception {
TreeMap<Key, Value> testData = new TreeMap<>();
genTestData(testData, 20);
LargeRowFilter lrfi = setupIterator(testData, 13, IteratorScope.majc);
lrfi.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
TreeMap<Key, Value> compactedData = new TreeMap<>();
while (lrfi.hasTop()) {
compactedData.put(lrfi.getTopKey(), lrfi.getTopValue());
lrfi.next();
}
// compacted data should now contain suppression markers
// add column to row that should be suppressed\
genRow(compactedData, 15, 15, 16);
// scanning over data w/ higher max columns should not change behavior
// because there are suppression markers.. if there was a bug and data
// was not suppressed, increasing the threshold would expose the bug
lrfi = setupIterator(compactedData, 20, IteratorScope.scan);
lrfi.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
// only expect to see 13 rows
TreeMap<Key, Value> expectedData = new TreeMap<>();
genTestData(expectedData, 13);
TreeMap<Key, Value> filteredData = new TreeMap<>();
while (lrfi.hasTop()) {
filteredData.put(lrfi.getTopKey(), lrfi.getTopValue());
lrfi.next();
}
assertEquals(expectedData.size() + 8, compactedData.size());
assertEquals(expectedData, filteredData);
// try seeking to the middle of row 15... row has data and suppression marker... this seeks past the marker but before the column
lrfi.seek(new Range(new Key(genRow(15), "cf001", genCQ(4), 5), true, new Key(genRow(15)).followingKey(PartialKey.ROW), false), LocalityGroupUtil.EMPTY_CF_SET, false);
assertFalse(lrfi.hasTop());
// test seeking w/ column families
HashSet<ByteSequence> colfams = new HashSet<>();
colfams.add(new ArrayByteSequence("cf001"));
lrfi.seek(new Range(new Key(genRow(15), "cf001", genCQ(4), 5), true, new Key(genRow(15)).followingKey(PartialKey.ROW), false), colfams, true);
assertFalse(lrfi.hasTop());
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RowDeletingIteratorTest method test3.
public void test3() throws Exception {
TreeMap<Key, Value> tm1 = new TreeMap<>();
put(tm1, "r1", "", "", 10, RowDeletingIterator.DELETE_ROW_VALUE);
put(tm1, "r1", "", "cq1", 5, "v1");
put(tm1, "r1", "cf1", "cq1", 5, "v1");
put(tm1, "r2", "", "cq1", 5, "v1");
put(tm1, "r2", "cf1", "cq1", 5, "v1");
RowDeletingIterator rdi = new RowDeletingIterator();
rdi.init(new ColumnFamilySkippingIterator(new SortedMapIterator(tm1)), null, new TestIE(IteratorScope.scan, false));
HashSet<ByteSequence> cols = new HashSet<>();
cols.add(new ArrayByteSequence("cf1".getBytes()));
rdi.seek(new Range(), cols, true);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
cols.clear();
cols.add(new ArrayByteSequence("".getBytes()));
rdi.seek(new Range(), cols, false);
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
cols.clear();
rdi.seek(new Range(), cols, false);
testAssertions(rdi, "r2", "", "cq1", 5, "v1");
rdi.next();
testAssertions(rdi, "r2", "cf1", "cq1", 5, "v1");
}
use of org.apache.accumulo.core.data.ArrayByteSequence in project accumulo by apache.
the class RowFilterTest method test1.
@Test
public void test1() throws Exception {
ColumnFamilySkippingIterator source = new ColumnFamilySkippingIterator(new SortedMapIterator(createKeyValues()));
RowFilter filter = new SummingRowFilter();
filter.init(source, Collections.emptyMap(), new DefaultIteratorEnvironment());
filter.seek(new Range(), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("2", "3")), getRows(filter));
ByteSequence cf = new ArrayByteSequence("cf2");
filter.seek(new Range(), ImmutableSet.of(cf), true);
assertEquals(new HashSet<>(Arrays.asList("1", "3", "0", "4")), getRows(filter));
filter.seek(new Range("0", "4"), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("2", "3")), getRows(filter));
filter.seek(new Range("2"), Collections.emptySet(), false);
assertEquals(new HashSet<>(Arrays.asList("2")), getRows(filter));
filter.seek(new Range("4"), Collections.emptySet(), false);
assertEquals(new HashSet<String>(), getRows(filter));
filter.seek(new Range("4"), ImmutableSet.of(cf), true);
assertEquals(new HashSet<>(Arrays.asList("4")), getRows(filter));
}
Aggregations