accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [1/3] accumulo git commit: ACCUMULO-1604: added check for negate option in ColumnAgeOffFilter and new test in FilterTest
Date Sun, 17 Jul 2016 15:14:12 GMT
Repository: accumulo
Updated Branches:
  refs/heads/1.8 6848a38c5 -> a8f804e9e
  refs/heads/master c39d17779 -> 5c5290b70


ACCUMULO-1604: added check for negate option in ColumnAgeOffFilter and new test in FilterTest

Closes apache/accumulo#122

Signed-off-by: Josh Elser <elserj@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/a8f804e9
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a8f804e9
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a8f804e9

Branch: refs/heads/1.8
Commit: a8f804e9e8d0bfe1ff93065e4714483a262440de
Parents: 6848a38
Author: Mike Miller <michaelpmiller@gmail.com>
Authored: Tue Jul 5 15:11:26 2016 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Sun Jul 17 11:13:30 2016 -0400

----------------------------------------------------------------------
 .../core/iterators/user/ColumnAgeOffFilter.java |  3 +
 .../core/iterators/user/FilterTest.java         | 81 ++++++++++++++++++++
 2 files changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a8f804e9/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
b/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
index c3da5c1..8093e92 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
@@ -43,6 +43,9 @@ public class ColumnAgeOffFilter extends Filter {
       for (Entry<String,String> entry : objectStrings.entrySet()) {
         String column = entry.getKey();
         String ttl = entry.getValue();
+        // skip the negate option, it will cause an exception to be thrown
+        if (column.equals(NEGATE) && (ttl.equalsIgnoreCase("true") || ttl.equalsIgnoreCase("false")))
+          continue;
         Long l = Long.parseLong(ttl);
 
         Pair<Text,Text> colPair = ColumnSet.decodeColumns(column);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a8f804e9/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
index 61d98e6..e7e2266 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
@@ -250,6 +250,87 @@ public class FilterTest {
     assertEquals(size(a), 902);
   }
 
+  /**
+   * Test for fix to ACCUMULO-1604: ColumnAgeOffFilter was throwing an error when using negate
+   */
+  @Test
+  public void test2aNegate() throws IOException {
+    Text colf = new Text("a");
+    Text colq = new Text("b");
+    Value dv = new Value();
+    TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
+    IteratorSetting is = new IteratorSetting(1, ColumnAgeOffFilter.class);
+    ColumnAgeOffFilter.addTTL(is, new IteratorSetting.Column("a"), 901l);
+    ColumnAgeOffFilter.setNegate(is, true);
+    long ts = System.currentTimeMillis();
+
+    for (long i = 0; i < 1000; i++) {
+      Key k = new Key(new Text(String.format("%03d", i)), colf, colq, ts - i);
+      tm.put(k, dv);
+    }
+    assertTrue(tm.size() == 1000);
+
+    ColumnAgeOffFilter a = new ColumnAgeOffFilter();
+    assertTrue(a.validateOptions(is.getOptions()));
+    a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
+    a.overrideCurrentTime(ts);
+    a.seek(new Range(), EMPTY_COL_FAMS, false);
+    assertEquals(size(a), 98);
+
+    ColumnAgeOffFilter.addTTL(is, new IteratorSetting.Column("a", "b"), 101l);
+    a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
+    a.overrideCurrentTime(ts);
+    a.seek(new Range(), EMPTY_COL_FAMS, false);
+    assertEquals(size(a), 898);
+
+    ColumnAgeOffFilter.removeTTL(is, new IteratorSetting.Column("a", "b"));
+    a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
+    a = (ColumnAgeOffFilter) a.deepCopy(null);
+    a.overrideCurrentTime(ts);
+    a.seek(new Range(), EMPTY_COL_FAMS, false);
+    assertEquals(size(a), 98);
+  }
+
+  /**
+   * Test for fix to ACCUMULO-1604: ColumnAgeOffFilter was throwing an error when using negate
Test case for when "negate" is an actual column name
+   */
+  @Test
+  public void test2b() throws IOException {
+    Text colf = new Text("negate");
+    Text colq = new Text("b");
+    Value dv = new Value();
+    TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
+    IteratorSetting is = new IteratorSetting(1, ColumnAgeOffFilter.class);
+    ColumnAgeOffFilter.addTTL(is, new IteratorSetting.Column("negate"), 901l);
+    long ts = System.currentTimeMillis();
+
+    for (long i = 0; i < 1000; i++) {
+      Key k = new Key(new Text(String.format("%03d", i)), colf, colq, ts - i);
+      tm.put(k, dv);
+    }
+    assertTrue(tm.size() == 1000);
+
+    ColumnAgeOffFilter a = new ColumnAgeOffFilter();
+    assertTrue(a.validateOptions(is.getOptions()));
+    a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
+    a.overrideCurrentTime(ts);
+    a.seek(new Range(), EMPTY_COL_FAMS, false);
+    assertEquals(size(a), 902);
+
+    ColumnAgeOffFilter.addTTL(is, new IteratorSetting.Column("negate", "b"), 101l);
+    a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
+    a.overrideCurrentTime(ts);
+    a.seek(new Range(), EMPTY_COL_FAMS, false);
+    assertEquals(size(a), 102);
+
+    ColumnAgeOffFilter.removeTTL(is, new IteratorSetting.Column("negate", "b"));
+    a.init(new SortedMapIterator(tm), is.getOptions(), new DefaultIteratorEnvironment());
+    a = (ColumnAgeOffFilter) a.deepCopy(null);
+    a.overrideCurrentTime(ts);
+    a.seek(new Range(), EMPTY_COL_FAMS, false);
+    assertEquals(size(a), 902);
+  }
+
   @Test
   public void test3() throws IOException {
     Value dv = new Value();


Mime
View raw message