You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by gi...@git.apache.org on 2017/10/04 13:24:51 UTC

[GitHub] FineAndDandy commented on a change in pull request #303: ACCUMULO-4713: Correctly set ranges for IteratorUtil.maximizeStartKey?

FineAndDandy commented on a change in pull request #303: ACCUMULO-4713: Correctly set ranges for IteratorUtil.maximizeStartKey?
URL: https://github.com/apache/accumulo/pull/303#discussion_r142668228
 
 

 ##########
 File path: core/src/test/java/org/apache/accumulo/core/iterators/system/TimeSettingIteratorTest.java
 ##########
 @@ -106,4 +117,135 @@ public void testAvoidKeyCopy() throws Exception {
     assertFalse(tsi.hasTop());
   }
 
+  @Test
+  public void testExclusiveEndKey() throws IOException {
+    Text row = new Text("a");
+    Text colf = new Text("b");
+    Text colq = new Text("c");
+    Text cv = new Text();
+
+    List<Map.Entry<Key,Value>> sources = new ArrayList<>();
+    sources.add(new AbstractMap.SimpleImmutableEntry<>(new Key(row, colf, colq, cv, Long.MIN_VALUE), new Value("00".getBytes())));
+    sources.add(new AbstractMap.SimpleImmutableEntry<>(new Key(row, colf, colq, cv, Long.MIN_VALUE), new Value("11".getBytes())));
+
+    TimeSettingIterator it = new TimeSettingIterator(new IteratorToSortedKeyValueIterator(sources.iterator()), 111L);
+    IteratorSetting is = new IteratorSetting(1, TimeSettingIterator.class);
+    it.init(null, is.getOptions(), null);
+
+    Key startKey = new Key();
+    Key endKey = new Key(row, colf, colq, cv, Long.MIN_VALUE);
+    Range testRange = new Range(startKey, false, endKey, false);
+    it.seek(testRange, new HashSet<ByteSequence>(), false);
+
+    assertTrue(it.hasTop());
+    assertTrue(it.getTopValue().equals(new Value("00".getBytes())));
+    assertTrue(it.getTopKey().getTimestamp() == 111L);
+    it.next();
+    assertTrue(it.hasTop());
+    assertTrue(it.getTopValue().equals(new Value("11".getBytes())));
+    assertTrue(it.getTopKey().getTimestamp() == 111L);
+    it.next();
+    assertFalse(it.hasTop());
+  }
+
+  @Test
+  public void testInclusiveEndKey() throws IOException {
+    Text row = new Text("a");
+    Text colf = new Text("b");
+    Text colq = new Text("c");
+    Text cv = new Text();
+
+    List<Map.Entry<Key,Value>> sources = new ArrayList<>();
+    sources.add(new AbstractMap.SimpleImmutableEntry<>(new Key(row, colf, colq, cv, Long.MIN_VALUE), new Value("00".getBytes())));
+    sources.add(new AbstractMap.SimpleImmutableEntry<>(new Key(row, colf, colq, cv, Long.MIN_VALUE), new Value("11".getBytes())));
+
+    TimeSettingIterator it = new TimeSettingIterator(new IteratorToSortedKeyValueIterator(sources.iterator()), 111L);
+    IteratorSetting is = new IteratorSetting(1, TimeSettingIterator.class);
+    it.init(null, is.getOptions(), null);
+
+    Key startKey = new Key();
+    Key endKey = new Key(row, colf, colq, cv, Long.MIN_VALUE);
+    Range testRange = new Range(startKey, false, endKey, true);
+    it.seek(testRange, new HashSet<ByteSequence>(), false);
+
+    assertTrue(it.hasTop());
+    assertTrue(it.getTopValue().equals(new Value("00".getBytes())));
+    assertTrue(it.getTopKey().getTimestamp() == 111L);
+    it.next();
+    assertTrue(it.hasTop());
+    assertTrue(it.getTopValue().equals(new Value("11".getBytes())));
+    assertTrue(it.getTopKey().getTimestamp() == 111L);
+    it.next();
+    assertFalse(it.hasTop());
+  }
+
+  public class IteratorToSortedKeyValueIterator implements SortedKeyValueIterator<Key,Value> {
 
 Review comment:
   I think I can rework this to use a deleted flag rather than the internal class for testing. The important part was that I have two keys with the same Row/CF/CQ/MIN_LONG in a row to reproduce the problem case. 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services