Repository: accumulo Updated Branches: refs/heads/ACCUMULO-4525_2.0 [created] 37ad8f505
http://git-wip-us.apache.org/repos/asf/accumulo/blob/37ad8f50/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java ---------------------------------------------------------------------- diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java index f813d42..43f0c0f 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java @@ -127,23 +127,23 @@ public class InMemoryMapTest { imm.mutate(Collections.singletonList(m)); } - static Key nk(String row, String column, long ts) { + static Key newKey(String row, String column, long ts) { String[] sa = column.split(":"); Key k = new Key(new Text(row), new Text(sa[0]), new Text(sa[1]), ts); return k; } - static void ae(SortedKeyValueIterator<Key,Value> dc, String row, String column, int ts, String val) throws IOException { + static void testAndCallNext(SortedKeyValueIterator<Key,Value> dc, String row, String column, int ts, String val) throws IOException { assertTrue(dc.hasTop()); - assertEquals(nk(row, column, ts), dc.getTopKey()); + assertEquals(newKey(row, column, ts), dc.getTopKey()); assertEquals(new Value(val.getBytes()), dc.getTopValue()); dc.next(); } - static void aeNoNext(SortedKeyValueIterator<Key,Value> dc, String row, String column, int ts, String val) throws IOException { + static void assertEqualsNoNext(SortedKeyValueIterator<Key,Value> dc, String row, String column, int ts, String val) throws IOException { assertTrue(dc.hasTop()); - assertEquals(nk(row, column, ts), dc.getTopKey()); + assertEquals(newKey(row, column, ts), dc.getTopKey()); assertEquals(new Value(val.getBytes()), dc.getTopValue()); } @@ -191,7 +191,7 @@ public class InMemoryMapTest { ski2.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); assertTrue(ski2.hasTop()); - ae(ski2, "r1", "foo:cq1", 3, "bar1"); + testAndCallNext(ski2, "r1", "foo:cq1", 3, "bar1"); assertFalse(ski2.hasTop()); } @@ -211,13 +211,13 @@ public class InMemoryMapTest { MemoryIterator ski2 = imm.skvIterator(null); ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, "bar2"); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + 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); - ae(ski2, "r3", "foo:cq1", 3, "bara"); - ae(ski2, "r3", "foo:cq1", 3, "bar9"); + testAndCallNext(ski2, "r3", "foo:cq1", 3, "bara"); + testAndCallNext(ski2, "r3", "foo:cq1", 3, "bar9"); assertFalse(ski1.hasTop()); } @@ -234,21 +234,21 @@ public class InMemoryMapTest { imm.delete(0); ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, "bar2"); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + 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); - ae(ski1, "r1", "foo:cq1", 3, "bar2"); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + 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(nk("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, "bar2"); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + 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(); @@ -265,9 +265,9 @@ public class InMemoryMapTest { imm.delete(0); ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); - aeNoNext(ski1, "r1", "foo:cq1", 3, ""); + assertEqualsNoNext(ski1, "r1", "foo:cq1", 3, ""); ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, ""); + testAndCallNext(ski1, "r1", "foo:cq1", 3, ""); assertFalse(ski1.hasTop()); ski1.close(); @@ -283,12 +283,12 @@ public class InMemoryMapTest { MemoryIterator ski1 = imm.skvIterator(null); ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, "bar3"); + testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar3"); imm.delete(0); - ae(ski1, "r1", "foo:cq1", 3, "bar2"); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar2"); + testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1"); assertFalse(ski1.hasTop()); ski1.close(); @@ -301,12 +301,12 @@ public class InMemoryMapTest { ski1 = imm.skvIterator(null); ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + testAndCallNext(ski1, "r1", "foo:cq1", 3, "bar1"); imm.delete(0); - ae(ski1, "r1", "foo:cq2", 3, "bar2"); - ae(ski1, "r1", "foo:cq3", 3, "bar3"); + testAndCallNext(ski1, "r1", "foo:cq2", 3, "bar2"); + testAndCallNext(ski1, "r1", "foo:cq3", 3, "bar3"); assertFalse(ski1.hasTop()); ski1.close(); @@ -327,30 +327,30 @@ public class InMemoryMapTest { SortedKeyValueIterator<Key,Value> dc = ski1.deepCopy(new SampleIE()); - ski1.seek(new Range(nk("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + 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(nk("r1", "foo:cq2", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(dc, "r1", "foo:cq2", 3, "bar2"); + 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); - ae(ski1, "r1", "foo:cq2", 3, "bar2"); - ae(dc, "r1", "foo:cq3", 3, "bar3"); - ae(ski1, "r1", "foo:cq3", 3, "bar3"); - ae(dc, "r1", "foo:cq4", 3, "bar4"); - ae(ski1, "r1", "foo:cq4", 3, "bar4"); + 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(nk("r1", "foo:cq3", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); + ski1.seek(new Range(newKey("r1", "foo:cq3", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - dc.seek(new Range(nk("r1", "foo:cq4", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(dc, "r1", "foo:cq4", 3, "bar4"); + 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()); - ae(ski1, "r1", "foo:cq3", 3, "bar3"); - ae(ski1, "r1", "foo:cq4", 3, "bar4"); + testAndCallNext(ski1, "r1", "foo:cq3", 3, "bar3"); + testAndCallNext(ski1, "r1", "foo:cq4", 3, "bar4"); assertFalse(ski1.hasTop()); assertFalse(dc.hasTop()); @@ -393,8 +393,8 @@ public class InMemoryMapTest { iflag.set(true); } - ae(dc, "r1", "foo:cq1", 3, "bar1"); - ae(ski1, "r1", "foo:cq1", 3, "bar1"); + 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) { @@ -403,9 +403,9 @@ public class InMemoryMapTest { iflag.set(true); } - ae(ski1, "r1", "foo:cq2", 3, "bar2"); - ae(dc, "r1", "foo:cq1", 3, "bar1"); - ae(dc, "r1", "foo:cq2", 3, "bar2"); + 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()); @@ -464,11 +464,11 @@ public class InMemoryMapTest { MemoryIterator skvi1 = imm.skvIterator(null); - skvi1.seek(new Range(nk("r1", "foo:cq3", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(skvi1, "r1", "foo:cq3", 3, "bar3"); + 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(nk("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(skvi1, "r1", "foo:cq1", 3, "bar1"); + skvi1.seek(new Range(newKey("r1", "foo:cq1", 3), null), LocalityGroupUtil.EMPTY_CF_SET, false); + testAndCallNext(skvi1, "r1", "foo:cq1", 3, "bar1"); } @@ -483,8 +483,8 @@ public class InMemoryMapTest { MemoryIterator skvi1 = imm.skvIterator(null); skvi1.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); - ae(skvi1, "r1", "foo:cq", 3, "v2"); - ae(skvi1, "r1", "foo:cq", 3, "v1"); + testAndCallNext(skvi1, "r1", "foo:cq", 3, "v2"); + testAndCallNext(skvi1, "r1", "foo:cq", 3, "v1"); } private static final Logger log = Logger.getLogger(InMemoryMapTest.class); @@ -733,7 +733,7 @@ public class InMemoryMapTest { private void mutate(InMemoryMap imm, String row, String cols, int ts, String val, Sampler sampler, TreeMap<Key,Value> expectedSample, TreeMap<Key,Value> expectedAll) { mutate(imm, row, cols, ts, val); - Key k1 = nk(row, cols, ts); + Key k1 = newKey(row, cols, ts); if (sampler.accept(k1)) { expectedSample.put(k1, new Value(val.getBytes())); } @@ -836,52 +836,52 @@ public class InMemoryMapTest { private void seekLocalityGroups(SortedKeyValueIterator<Key,Value> iter1) throws IOException { iter1.seek(new Range(), newCFSet("cf1"), true); - ae(iter1, "r1", "cf1:x", 2, "1"); - ae(iter1, "r1", "cf1:y", 2, "2"); - ae(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r1", "cf1:x", 2, "1"); + testAndCallNext(iter1, "r1", "cf1:y", 2, "2"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); assertFalse(iter1.hasTop()); iter1.seek(new Range("r2", "r4"), newCFSet("cf1"), true); - ae(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); assertFalse(iter1.hasTop()); iter1.seek(new Range(), newCFSet("cf3"), true); - ae(iter1, "r1", "cf3:z", 2, "3"); - ae(iter1, "r4", "cf4:z", 5, "8"); - ae(iter1, "r5", "cf3:z", 6, "A"); - ae(iter1, "r5", "cf4:z", 6, "B"); + testAndCallNext(iter1, "r1", "cf3:z", 2, "3"); + testAndCallNext(iter1, "r4", "cf4:z", 5, "8"); + testAndCallNext(iter1, "r5", "cf3:z", 6, "A"); + testAndCallNext(iter1, "r5", "cf4:z", 6, "B"); assertFalse(iter1.hasTop()); iter1.seek(new Range(), newCFSet("foo"), true); - ae(iter1, "r1", "foo:b", 2, "9"); - ae(iter1, "r3", "foo:b", 4, "6"); - ae(iter1, "r4", "foo:b", 5, "7"); + testAndCallNext(iter1, "r1", "foo:b", 2, "9"); + testAndCallNext(iter1, "r3", "foo:b", 4, "6"); + testAndCallNext(iter1, "r4", "foo:b", 5, "7"); assertFalse(iter1.hasTop()); iter1.seek(new Range(), newCFSet("cf1", "cf3"), true); - ae(iter1, "r1", "cf1:x", 2, "1"); - ae(iter1, "r1", "cf1:y", 2, "2"); - ae(iter1, "r1", "cf3:z", 2, "3"); - ae(iter1, "r2", "cf2:x", 3, "5"); - ae(iter1, "r4", "cf4:z", 5, "8"); - ae(iter1, "r5", "cf3:z", 6, "A"); - ae(iter1, "r5", "cf4:z", 6, "B"); + testAndCallNext(iter1, "r1", "cf1:x", 2, "1"); + testAndCallNext(iter1, "r1", "cf1:y", 2, "2"); + testAndCallNext(iter1, "r1", "cf3:z", 2, "3"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r4", "cf4:z", 5, "8"); + testAndCallNext(iter1, "r5", "cf3:z", 6, "A"); + testAndCallNext(iter1, "r5", "cf4:z", 6, "B"); assertFalse(iter1.hasTop()); iter1.seek(new Range("r2", "r4"), newCFSet("cf1", "cf3"), true); - ae(iter1, "r2", "cf2:x", 3, "5"); - ae(iter1, "r4", "cf4:z", 5, "8"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r4", "cf4:z", 5, "8"); assertFalse(iter1.hasTop()); iter1.seek(new Range(), newCFSet("cf1", "cf3", "foo"), true); assertAll(iter1); iter1.seek(new Range("r1", "r2"), newCFSet("cf1", "cf3", "foo"), true); - ae(iter1, "r1", "cf1:x", 2, "1"); - ae(iter1, "r1", "cf1:y", 2, "2"); - ae(iter1, "r1", "cf3:z", 2, "3"); - ae(iter1, "r1", "foo:b", 2, "9"); - ae(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r1", "cf1:x", 2, "1"); + testAndCallNext(iter1, "r1", "cf1:y", 2, "2"); + testAndCallNext(iter1, "r1", "cf3:z", 2, "3"); + testAndCallNext(iter1, "r1", "foo:b", 2, "9"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); assertFalse(iter1.hasTop()); iter1.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false); @@ -891,31 +891,31 @@ public class InMemoryMapTest { assertAll(iter1); iter1.seek(new Range(), newCFSet("cf1", "cf2"), false); - ae(iter1, "r1", "cf3:z", 2, "3"); - ae(iter1, "r1", "foo:b", 2, "9"); - ae(iter1, "r3", "foo:b", 4, "6"); - ae(iter1, "r4", "cf4:z", 5, "8"); - ae(iter1, "r4", "foo:b", 5, "7"); - ae(iter1, "r5", "cf3:z", 6, "A"); - ae(iter1, "r5", "cf4:z", 6, "B"); + testAndCallNext(iter1, "r1", "cf3:z", 2, "3"); + testAndCallNext(iter1, "r1", "foo:b", 2, "9"); + testAndCallNext(iter1, "r3", "foo:b", 4, "6"); + testAndCallNext(iter1, "r4", "cf4:z", 5, "8"); + testAndCallNext(iter1, "r4", "foo:b", 5, "7"); + testAndCallNext(iter1, "r5", "cf3:z", 6, "A"); + testAndCallNext(iter1, "r5", "cf4:z", 6, "B"); assertFalse(iter1.hasTop()); iter1.seek(new Range("r2"), newCFSet("cf1", "cf3", "foo"), true); - ae(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); assertFalse(iter1.hasTop()); } private void assertAll(SortedKeyValueIterator<Key,Value> iter1) throws IOException { - ae(iter1, "r1", "cf1:x", 2, "1"); - ae(iter1, "r1", "cf1:y", 2, "2"); - ae(iter1, "r1", "cf3:z", 2, "3"); - ae(iter1, "r1", "foo:b", 2, "9"); - ae(iter1, "r2", "cf2:x", 3, "5"); - ae(iter1, "r3", "foo:b", 4, "6"); - ae(iter1, "r4", "cf4:z", 5, "8"); - ae(iter1, "r4", "foo:b", 5, "7"); - ae(iter1, "r5", "cf3:z", 6, "A"); - ae(iter1, "r5", "cf4:z", 6, "B"); + testAndCallNext(iter1, "r1", "cf1:x", 2, "1"); + testAndCallNext(iter1, "r1", "cf1:y", 2, "2"); + testAndCallNext(iter1, "r1", "cf3:z", 2, "3"); + testAndCallNext(iter1, "r1", "foo:b", 2, "9"); + testAndCallNext(iter1, "r2", "cf2:x", 3, "5"); + testAndCallNext(iter1, "r3", "foo:b", 4, "6"); + testAndCallNext(iter1, "r4", "cf4:z", 5, "8"); + testAndCallNext(iter1, "r4", "foo:b", 5, "7"); + testAndCallNext(iter1, "r5", "cf3:z", 6, "A"); + testAndCallNext(iter1, "r5", "cf4:z", 6, "B"); assertFalse(iter1.hasTop()); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/37ad8f50/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java b/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java index f2a8dfe..136657e 100644 --- a/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java +++ b/test/src/main/java/org/apache/accumulo/test/NativeMapPerformanceTest.java @@ -41,11 +41,11 @@ public class NativeMapPerformanceTest { private static final byte ROW_PREFIX[] = new byte[] {'r'}; private static final byte COL_PREFIX[] = new byte[] {'c'}; - static Key nk(int r, int c) { + static Key newKey(int r, int c) { return new Key(new Text(FastFormat.toZeroPaddedString(r, 9, 10, ROW_PREFIX)), new Text(FastFormat.toZeroPaddedString(c, 6, 10, COL_PREFIX))); } - static Mutation nm(int r) { + static Mutation newMutation(int r) { return new Mutation(new Text(FastFormat.toZeroPaddedString(r, 9, 10, ROW_PREFIX))); } @@ -77,7 +77,7 @@ public class NativeMapPerformanceTest { if (nm != null) { for (int i = 0; i < numRows; i++) { int row = rand.nextInt(1000000000); - Mutation m = nm(row); + Mutation m = newMutation(row); for (int j = 0; j < numCols; j++) { int col = rand.nextInt(1000000); Value val = new Value("test".getBytes(UTF_8)); @@ -90,7 +90,7 @@ public class NativeMapPerformanceTest { int row = rand.nextInt(1000000000); for (int j = 0; j < numCols; j++) { int col = rand.nextInt(1000000); - Key key = nk(row, col); + Key key = newKey(row, col); Value val = new Value("test".getBytes(UTF_8)); tm.put(key, val); } @@ -134,14 +134,14 @@ public class NativeMapPerformanceTest { long tgs = System.currentTimeMillis(); if (nm != null) { for (int i = 0; i < numLookups; i++) { - Key key = nk(rowsToLookup[i], colsToLookup[i]); + Key key = newKey(rowsToLookup[i], colsToLookup[i]); if (nm.get(key) == null) { throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i); } } } else { for (int i = 0; i < numLookups; i++) { - Key key = nk(rowsToLookup[i], colsToLookup[i]); + Key key = newKey(rowsToLookup[i], colsToLookup[i]); if (tm.get(key) == null) { throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/37ad8f50/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java b/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java index ea3ba66..fc9e8d1 100644 --- a/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java +++ b/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java @@ -49,11 +49,11 @@ import org.junit.experimental.categories.Category; @Category(SunnyDayTests.class) public class NativeMapIT { - private Key nk(int r) { + private Key newKey(int r) { return new Key(new Text(String.format("r%09d", r))); } - private Key nk(int r, int cf, int cq, int cv, int ts, boolean deleted) { + private Key newKey(int r, int cf, int cq, int cv, int ts, boolean deleted) { Key k = new Key(new Text(String.format("r%09d", r)), new Text(String.format("cf%09d", cf)), new Text(String.format("cq%09d", cq)), new Text(String.format( "cv%09d", cv)), ts); @@ -62,7 +62,7 @@ public class NativeMapIT { return k; } - private Value nv(int v) { + private Value newValue(int v) { return new Value(String.format("r%09d", v).getBytes(UTF_8)); } @@ -81,8 +81,8 @@ public class NativeMapIT { for (int i = start; i <= end; i++) { assertTrue(iter.hasNext()); Entry<Key,Value> entry = iter.next(); - assertEquals(nk(i), entry.getKey()); - assertEquals(nv(i + valueOffset), entry.getValue()); + assertEquals(newKey(i), entry.getKey()); + assertEquals(newValue(i + valueOffset), entry.getValue()); } assertFalse(iter.hasNext()); @@ -90,34 +90,34 @@ public class NativeMapIT { private void insertAndVerify(NativeMap nm, int start, int end, int valueOffset) { for (int i = start; i <= end; i++) { - nm.put(nk(i), nv(i + valueOffset)); + nm.put(newKey(i), newValue(i + valueOffset)); } for (int i = start; i <= end; i++) { - Value v = nm.get(nk(i)); + Value v = nm.get(newKey(i)); assertNotNull(v); - assertEquals(nv(i + valueOffset), v); + assertEquals(newValue(i + valueOffset), v); - Iterator<Entry<Key,Value>> iter2 = nm.iterator(nk(i)); + Iterator<Entry<Key,Value>> iter2 = nm.iterator(newKey(i)); assertTrue(iter2.hasNext()); Entry<Key,Value> entry = iter2.next(); - assertEquals(nk(i), entry.getKey()); - assertEquals(nv(i + valueOffset), entry.getValue()); + assertEquals(newKey(i), entry.getKey()); + assertEquals(newValue(i + valueOffset), entry.getValue()); } - assertNull(nm.get(nk(start - 1))); + assertNull(nm.get(newKey(start - 1))); - assertNull(nm.get(nk(end + 1))); + assertNull(nm.get(newKey(end + 1))); Iterator<Entry<Key,Value>> iter = nm.iterator(); verifyIterator(start, end, valueOffset, iter); for (int i = start; i <= end; i++) { - iter = nm.iterator(nk(i)); + iter = nm.iterator(newKey(i)); verifyIterator(i, end, valueOffset, iter); // lookup nonexistant key that falls after existing key - iter = nm.iterator(nk(i, 1, 1, 1, 1, false)); + iter = nm.iterator(newKey(i, 1, 1, 1, 1, false)); verifyIterator(i + 1, end, valueOffset, iter); } @@ -130,12 +130,12 @@ public class NativeMapIT { for (int k = 0; k < num; k++) { for (int l = 0; l < num; l++) { for (int ts = 0; ts < num; ts++) { - Key key = nk(i, j, k, l, ts, true); + Key key = newKey(i, j, k, l, ts, true); Value value = new Value((i + "_" + j + "_" + k + "_" + l + "_" + ts + "_" + true + "_" + run).getBytes(UTF_8)); nm.put(key, value); - key = nk(i, j, k, l, ts, false); + key = newKey(i, j, k, l, ts, false); value = new Value((i + "_" + j + "_" + k + "_" + l + "_" + ts + "_" + false + "_" + run).getBytes(UTF_8)); nm.put(key, value); @@ -152,7 +152,7 @@ public class NativeMapIT { for (int k = 0; k < num; k++) { for (int l = 0; l < num; l++) { for (int ts = num - 1; ts >= 0; ts--) { - Key key = nk(i, j, k, l, ts, true); + Key key = newKey(i, j, k, l, ts, true); Value value = new Value((i + "_" + j + "_" + k + "_" + l + "_" + ts + "_" + true + "_" + run).getBytes(UTF_8)); assertTrue(iter.hasNext()); @@ -160,7 +160,7 @@ public class NativeMapIT { assertEquals(key, entry.getKey()); assertEquals(value, entry.getValue()); - key = nk(i, j, k, l, ts, false); + key = newKey(i, j, k, l, ts, false); value = new Value((i + "_" + j + "_" + k + "_" + l + "_" + ts + "_" + false + "_" + run).getBytes(UTF_8)); assertTrue(iter.hasNext()); @@ -180,7 +180,7 @@ public class NativeMapIT { for (int k = 0; k < num; k++) { for (int l = 0; l < num; l++) { for (int ts = 0; ts < num; ts++) { - Key key = nk(i, j, k, l, ts, true); + Key key = newKey(i, j, k, l, ts, true); Value value = new Value((i + "_" + j + "_" + k + "_" + l + "_" + ts + "_" + true + "_" + run).getBytes(UTF_8)); assertEquals(value, nm.get(key)); @@ -191,7 +191,7 @@ public class NativeMapIT { assertEquals(key, entry.getKey()); assertEquals(value, entry.getValue()); - key = nk(i, j, k, l, ts, false); + key = newKey(i, j, k, l, ts, false); value = new Value((i + "_" + j + "_" + k + "_" + l + "_" + ts + "_" + false + "_" + run).getBytes(UTF_8)); assertEquals(value, nm.get(key)); @@ -251,14 +251,14 @@ public class NativeMapIT { nm.delete(); try { - nm.put(nk(1), nv(1)); + nm.put(newKey(1), newValue(1)); assertTrue(false); } catch (IllegalStateException e) { } try { - nm.get(nk(1)); + nm.get(newKey(1)); assertTrue(false); } catch (IllegalStateException e) { @@ -272,7 +272,7 @@ public class NativeMapIT { } try { - nm.iterator(nk(1)); + nm.iterator(newKey(1)); assertTrue(false); } catch (IllegalStateException e) { @@ -377,13 +377,13 @@ public class NativeMapIT { NativeMap nm = new NativeMap(); for (int i = start; i <= end; i++) { - nm.put(nk(i), nv(i)); + nm.put(newKey(i), newValue(i)); } long mem1 = nm.getMemoryUsed(); for (int i = start; i <= end; i++) { - nm.put(nk(i), nv(i)); + nm.put(newKey(i), newValue(i)); } long mem2 = nm.getMemoryUsed(); @@ -393,7 +393,7 @@ public class NativeMapIT { } for (int i = start; i <= end; i++) { - nm.put(nk(i), nv(i)); + nm.put(newKey(i), newValue(i)); } long mem3 = nm.getMemoryUsed(); @@ -436,7 +436,7 @@ public class NativeMapIT { } // random length random field - private static byte[] rlrf(Random r, int maxLen) { + private static byte[] getRandomBytes(Random r, int maxLen) { int len = r.nextInt(maxLen); byte f[] = new byte[len]; @@ -458,8 +458,9 @@ public class NativeMapIT { for (int i = 0; i < 100000; i++) { - Key k = new Key(rlrf(r, 97), rlrf(r, 13), rlrf(r, 31), rlrf(r, 11), (r.nextLong() & 0x7fffffffffffffffl), false, false); - Value v = new Value(rlrf(r, 511)); + Key k = new Key(getRandomBytes(r, 97), getRandomBytes(r, 13), getRandomBytes(r, 31), getRandomBytes(r, 11), (r.nextLong() & 0x7fffffffffffffffl), false, + false); + Value v = new Value(getRandomBytes(r, 511)); testData.add(new Pair<>(k, v)); } @@ -506,7 +507,7 @@ public class NativeMapIT { Collections.shuffle(testData, r); // insert unsorted data for (Pair<Key,Value> pair : testData) { - pair.getSecond().set(rlrf(r, 511)); + pair.getSecond().set(getRandomBytes(r, 511)); nm.put(pair.getFirst(), pair.getSecond()); } } @@ -583,29 +584,29 @@ public class NativeMapIT { public void testConcurrentIter() throws IOException { NativeMap nm = new NativeMap(); - nm.put(nk(0), nv(0)); - nm.put(nk(1), nv(1)); - nm.put(nk(3), nv(3)); + nm.put(newKey(0), newValue(0)); + nm.put(newKey(1), newValue(1)); + nm.put(newKey(3), newValue(3)); SortedKeyValueIterator<Key,Value> iter = nm.skvIterator(); // modify map after iter created - nm.put(nk(2), nv(2)); + nm.put(newKey(2), newValue(2)); assertTrue(iter.hasTop()); - assertEquals(iter.getTopKey(), nk(0)); + assertEquals(iter.getTopKey(), newKey(0)); iter.next(); assertTrue(iter.hasTop()); - assertEquals(iter.getTopKey(), nk(1)); + assertEquals(iter.getTopKey(), newKey(1)); iter.next(); assertTrue(iter.hasTop()); - assertEquals(iter.getTopKey(), nk(2)); + assertEquals(iter.getTopKey(), newKey(2)); iter.next(); assertTrue(iter.hasTop()); - assertEquals(iter.getTopKey(), nk(3)); + assertEquals(iter.getTopKey(), newKey(3)); iter.next(); assertFalse(iter.hasTop());