Java Code Examples for org.apache.accumulo.core.data.Range#exact()
The following examples show how to use
org.apache.accumulo.core.data.Range#exact() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 6 votes |
@Test public void testWriteInvalidatesLock() { TestData input = new TestData(); // the row is locked input.add("0 f q WRITE 116", "111"); input.add("0 f q LOCK 111", "0 f q"); input.add("0 f q DATA 111", "15"); TestData output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); input.add("0 f q TX_DONE 116", "111"); output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); addLots(input); output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); }
Example 2
Source File: AccumuloUtils.java From geowave with Apache License 2.0 | 5 votes |
public static Range byteArrayRangeToAccumuloRange(final ByteArrayRange byteArrayRange) { if (byteArrayRange.isSingleValue()) { return Range.exact(new Text(byteArrayRange.getStart())); } final Text start = byteArrayRange.getStart() == null ? null : new Text(byteArrayRange.getStart()); final Text end = byteArrayRange.getEnd() == null ? null : new Text(byteArrayRange.getEnd()); if ((start != null) && (end != null) && (start.compareTo(end) > 0)) { return null; } return new Range(start, true, end == null ? null : Range.followingPrefix(end), false); }
Example 3
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 5 votes |
@Test public void testAck() { TestData input = new TestData(); input.add("0 f q WRITE 116", "111"); input.add("0 f q LOCK 111", "0 f q"); input.add("0 f q DATA 111", "15"); input.add("0 f q ACK 111", ""); for (int i = 0; i < 2; i++) { TestData output = new TestData(newPI(input, 117, 100), Range.exact("0", "f", "q")); TestData expected = new TestData().add("0 f q ACK 111", ""); Assert.assertEquals(expected, output); output = new TestData(newPI(input, 117, 116), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); output = new TestData(newPI(input, 112, 100), Range.exact("0", "f", "q")); expected = new TestData().add("0 f q WRITE 116", "111"); Assert.assertEquals(expected, output); addLots(input); input.add("0 f q TX_DONE 116", "111"); for (int j = 3; j < 100; j += 3) { input.add("0 f q ACK " + j, ""); } } }
Example 4
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 5 votes |
@Test public void testDelLock() { TestData input = new TestData(); // the row is locked input.add("0 f q DEL_LOCK 111", "ABORT"); input.add("0 f q LOCK 111", "0 f q"); input.add("0 f q DATA 111", "15"); for (int i = 0; i < 2; i++) { TestData output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(new TestData(), output); output = new TestData(newPI(input, 108), Range.exact("0", "f", "q")); TestData expected = new TestData(); expected.add("0 f q DEL_LOCK 111", "ABORT"); Assert.assertEquals(expected, output); input.add("0 f q TX_DONE 116", "111"); output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); output = new TestData(newPI(input, 108), Range.exact("0", "f", "q")); Assert.assertEquals(expected, output); addLots(input); } }
Example 5
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 5 votes |
@Test public void testWriteAndDelLockMax() { // ensure the delete lock or write with max timestamp invalidates lock TestData input = new TestData(); input.add("0 f q WRITE 116", "111"); input.add("0 f q LOCK 111", "0 f q"); input.add("0 f q DEL_LOCK 108", "ABORT"); TestData output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); output = new TestData(newPI(input, 111), Range.exact("0", "f", "q")); TestData expected = new TestData(); expected.add("0 f q WRITE 116", "111"); Assert.assertEquals(expected, output); input = new TestData(); input.add("0 f q DEL_LOCK 116", "ABORT"); input.add("0 f q LOCK 111", "0 f q"); input.add("0 f q WRITE 108", "100"); output = new TestData(newPI(input, 117), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); output = new TestData(newPI(input, 111), Range.exact("0", "f", "q")); expected = new TestData(); expected.add("0 f q DEL_LOCK 116", "ABORT"); Assert.assertEquals(expected, output); }
Example 6
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 5 votes |
@Test public void testWriteLockPreventsReadLock() { for (int i = 0; i < 2; i++) { TestData input = new TestData(); if (i == 1) { // this should have no impact input.add("0 f q RLOCK 13", "0 f q"); } input.add("0 f q LOCK 5", "0 f q"); input.add("0 f q DATA 5", "15"); TestData output = new TestData(newPI(input, 117, true), Range.exact("0", "f", "q")); TestData expected = new TestData(); expected.add("0 f q LOCK 5", "0 f q"); Assert.assertEquals(expected, output); input.add("0 f q WRITE 10", "5"); output = new TestData(newPI(input, 117, true), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); output = new TestData(newPI(input, 11, true), Range.exact("0", "f", "q")); Assert.assertEquals(0, output.data.size()); output = new TestData(newPI(input, 7, true), Range.exact("0", "f", "q")); expected = new TestData(); expected.add("0 f q WRITE 10", "5"); Assert.assertEquals(expected, output); output = new TestData(newPI(input, 4, true), Range.exact("0", "f", "q")); Assert.assertEquals(expected, output); } }
Example 7
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 5 votes |
@Test public void testManyReadLocks() { TestData input = new TestData(); input.add("0 f q WRITE 10", "5"); input.add("0 f q DATA 5", "15"); for (int i = 10; i < 2010; i += 2) { input.add("0 f q DEL_RLOCK " + i, "" + (i + 1)); input.add("0 f q RLOCK " + i, "0 f q"); } TestData output = new TestData(newPI(input, 3000, false), Range.exact("0", "f", "q")); // scans all read locks looking for an active lock Assert.assertEquals(2001, input.counter.nextCalls); Assert.assertEquals(0, output.data.size()); // read locks do not need to scan for other read locks... this checks that read locks are // skipped input.counter.reset(); output = new TestData(newPI(input, 3000, true), Range.exact("0", "f", "q")); // read locks should not scan everything looking for a read lock Assert.assertEquals(12, input.counter.nextCalls); // skipping will read 11 before seeking Assert.assertEquals(0, output.data.size()); // This write invalidates the 2000 read locks, so should skip read locks input.add("0 f q WRITE 2500", "2490"); input.add("0 f q DATA 2490", "16"); input.counter.reset(); output = new TestData(newPI(input, 3000, false), Range.exact("0", "f", "q")); Assert.assertEquals(13, input.counter.nextCalls); Assert.assertEquals(0, output.data.size()); }
Example 8
Source File: SnapshotIteratorTest.java From fluo with Apache License 2.0 | 4 votes |
@Test public void testSeek() { // data contains multiple columns and multiple rows TestData input = new TestData(); input.add("0 f q1 WRITE 16", "11"); input.add("0 f q1 LOCK 21", "1 f q"); input.add("0 f q1 LOCK 11", "1 f q"); input.add("0 f q1 DATA 21", "j"); input.add("0 f q1 DATA 11", "i"); input.add("0 f q2 WRITE 26", "20"); input.add("0 f q2 WRITE 18", "9"); input.add("0 f q2 LOCK 20", "1 f q"); input.add("0 f q2 LOCK 9", "1 f q"); input.add("0 f q2 DATA 20", "b"); input.add("0 f q2 DATA 9", "a"); input.add("1 f q1 DEL_LOCK 21", "0 ROLLBACK"); input.add("1 f q1 WRITE 18", "9"); input.add("1 f q1 LOCK 21", "1 f q"); input.add("1 f q1 LOCK 9", "1 f q"); input.add("1 f q1 DATA 21", "y"); input.add("1 f q1 DATA 9", "x"); for (Range range : new Range[] {Range.exact("0"), Range.exact("1"), Range.exact("0", "f"), Range.exact("0", "f", "q1"), Range.exact("0", "f", "q2"), Range.exact("1", "f", "q1")}) { TestData output = new TestData(newSI(input, 6), range); Assert.assertEquals(0, output.data.size()); output = new TestData(newSI(input, 17), range); TestData expected = new TestData(); expected.addIfInRange("0 f q1 DATA 11", "i", range); Assert.assertEquals(expected, output); output = new TestData(newSI(input, 19), range); expected = new TestData(); expected.addIfInRange("0 f q1 DATA 11", "i", range); expected.addIfInRange("0 f q2 DATA 9", "a", range); expected.addIfInRange("1 f q1 DATA 9", "x", range); Assert.assertEquals(expected, output); output = new TestData(newSI(input, 22), range); expected = new TestData(); expected.addIfInRange("0 f q1 LOCK 21", "1 f q", range); expected.addIfInRange("0 f q2 DATA 9", "a", range); expected.addIfInRange("1 f q1 DATA 9", "x", range); Assert.assertEquals(expected, output); output = new TestData(newSI(input, 27), range); expected = new TestData(); expected.addIfInRange("0 f q1 LOCK 21", "1 f q", range); expected.addIfInRange("0 f q2 DATA 20", "b", range); expected.addIfInRange("1 f q1 DATA 9", "x", range); Assert.assertEquals(expected, output); } }
Example 9
Source File: PrewriteIteratorTest.java From fluo with Apache License 2.0 | 4 votes |
@Test public void testGarbageCollectedReadLocks() { // After a partial compaction the garbage collection iterator will drop read lock entries, but // not del_read_locks entries. This test ensures that prewrite works w/ this. TestData input = new TestData(); input.add("0 f q DEL_RLOCK 42", "50"); input.add("0 f q DEL_RLOCK 44", "51"); TestData output = new TestData(newPI(input, 47), Range.exact("0", "f", "q")); TestData expected = new TestData(); expected.add("0 f q DEL_RLOCK 44", "51"); Assert.assertEquals(expected, output); output = new TestData(newPI(input, 43), Range.exact("0", "f", "q")); Assert.assertEquals(expected, output); }