accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1407165 - in /accumulo/branches/1.4/src/core/src: main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
Date Thu, 08 Nov 2012 16:57:46 GMT
Author: billie
Date: Thu Nov  8 16:57:46 2012
New Revision: 1407165

URL: http://svn.apache.org/viewvc?rev=1407165&view=rev
Log:
ACCUMULO-776 reverted 1.4 changes to timestamp filter

Modified:
    accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
    accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java

Modified: accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java?rev=1407165&r1=1407164&r2=1407165&view=diff
==============================================================================
--- accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
(original)
+++ accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
Thu Nov  8 16:57:46 2012
@@ -17,8 +17,8 @@
 package org.apache.accumulo.core.iterators.user;
 
 import java.io.IOException;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
 
@@ -33,7 +33,6 @@ import org.apache.accumulo.core.iterator
  * A Filter that matches entries whose timestamps fall within a range.
  */
 public class TimestampFilter extends Filter {
-  private static final String LONG_PREFIX = "LONG";
   private final SimpleDateFormat dateParser = initDateParser();
   
   private static SimpleDateFormat initDateParser() {
@@ -87,20 +86,10 @@ public class TimestampFilter extends Fil
       throw new IllegalArgumentException("must have either start or end for " + TimestampFilter.class.getName());
     
     try {
-      if (hasStart) {
-        String s = options.get(START);
-        if (s.startsWith(LONG_PREFIX))
-          start = Long.valueOf(s.substring(LONG_PREFIX.length()));
-        else
-          start = dateParser.parse(s).getTime();
-      }
-      if (hasEnd) {
-        String s = options.get(END);
-        if (s.startsWith(LONG_PREFIX))
-          end = Long.valueOf(s.substring(LONG_PREFIX.length()));
-        else
-          end = dateParser.parse(s).getTime();
-      }
+      if (hasStart)
+        start = dateParser.parse(options.get(START)).getTime();
+      if (hasEnd)
+        end = dateParser.parse(options.get(END)).getTime();
     } catch (Exception e) {
       throw new IllegalArgumentException(e);
     }
@@ -127,8 +116,8 @@ public class TimestampFilter extends Fil
     IteratorOptions io = super.describeOptions();
     io.setName("tsfilter");
     io.setDescription("TimestampFilter displays entries with timestamps between specified
values");
-    io.addNamedOption("start", "start timestamp (yyyyMMddHHmmssz or LONG<longstring>)");
-    io.addNamedOption("end", "end timestamp (yyyyMMddHHmmssz or LONG<longstring>)");
+    io.addNamedOption("start", "start timestamp (yyyyMMddHHmmssz)");
+    io.addNamedOption("end", "end timestamp (yyyyMMddHHmmssz)");
     io.addNamedOption("startInclusive", "true or false");
     io.addNamedOption("endInclusive", "true or false");
     return io;
@@ -137,27 +126,11 @@ public class TimestampFilter extends Fil
   @Override
   public boolean validateOptions(Map<String,String> options) {
     super.validateOptions(options);
-    boolean hasStart = false;
-    boolean hasEnd = false;
     try {
-      if (options.containsKey(START)) {
-        hasStart = true;
-        String s = options.get(START);
-        if (s.startsWith(LONG_PREFIX))
-          Long.valueOf(s.substring(LONG_PREFIX.length()));
-        else
-          dateParser.parse(s);
-      }
-      if (options.containsKey(END)) {
-        hasEnd = true;
-        String s = options.get(END);
-        if (s.startsWith(LONG_PREFIX))
-          Long.valueOf(s.substring(LONG_PREFIX.length()));
-        else
-          dateParser.parse(s);
-      }
-      if (!hasStart && !hasEnd)
-        return false;
+      if (options.containsKey(START))
+        dateParser.parse(options.get(START));
+      if (options.containsKey(END))
+        dateParser.parse(options.get(END));
       if (options.get(START_INCL) != null)
         Boolean.parseBoolean(options.get(START_INCL));
       if (options.get(END_INCL) != null)
@@ -212,13 +185,8 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the start is inclusive
    */
   public static void setStart(IteratorSetting is, String start, boolean startInclusive) {
-    SimpleDateFormat dateParser = initDateParser();
-    try {
-      long startTS = dateParser.parse(start).getTime();
-      setStart(is, startTS, startInclusive);
-    } catch (ParseException e) {
-      throw new IllegalArgumentException("couldn't parse " + start);
-    }
+    is.addOption(START, start);
+    is.addOption(START_INCL, Boolean.toString(startInclusive));
   }
   
   /**
@@ -232,13 +200,8 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the end is inclusive
    */
   public static void setEnd(IteratorSetting is, String end, boolean endInclusive) {
-    SimpleDateFormat dateParser = initDateParser();
-    try {
-      long endTS = dateParser.parse(end).getTime();
-      setEnd(is, endTS, endInclusive);
-    } catch (ParseException e) {
-      throw new IllegalArgumentException("couldn't parse " + end);
-    }
+    is.addOption(END, end);
+    is.addOption(END_INCL, Boolean.toString(endInclusive));
   }
   
   /**
@@ -285,7 +248,8 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the start is inclusive
    */
   public static void setStart(IteratorSetting is, long start, boolean startInclusive) {
-    is.addOption(START, LONG_PREFIX + Long.toString(start));
+    SimpleDateFormat dateParser = initDateParser();
+    is.addOption(START, dateParser.format(new Date(start)));
     is.addOption(START_INCL, Boolean.toString(startInclusive));
   }
   
@@ -300,7 +264,8 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the end is inclusive
    */
   public static void setEnd(IteratorSetting is, long end, boolean endInclusive) {
-    is.addOption(END, LONG_PREFIX + Long.toString(end));
+    SimpleDateFormat dateParser = initDateParser();
+    is.addOption(END, dateParser.format(new Date(end)));
     is.addOption(END_INCL, Boolean.toString(endInclusive));
   }
 }

Modified: accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java?rev=1407165&r1=1407164&r2=1407165&view=diff
==============================================================================
--- accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
(original)
+++ accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
Thu Nov  8 16:57:46 2012
@@ -17,7 +17,6 @@
 package org.apache.accumulo.core.iterators.user;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
@@ -198,8 +197,6 @@ public class FilterTest {
     AgeOffFilter.setTTL(is, 101l);
     AgeOffFilter.setCurrentTime(is, 1001l);
     AgeOffFilter.setNegate(is, true);
-    assertTrue(((AgeOffFilter) a).validateOptions(is.getOptions()));
-    assertFalse(((AgeOffFilter) a).validateOptions(EMPTY_OPTS));
     a.init(new SortedMapIterator(tm), is.getOptions(), null);
     a = a.deepCopy(null);
     SortedKeyValueIterator<Key,Value> copy = a.deepCopy(null);
@@ -226,7 +223,6 @@ public class FilterTest {
     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);
@@ -433,7 +429,6 @@ public class FilterTest {
     assertEquals(size(a), 89);
     
     TimestampFilter.setStart(is, "19990101000011GMT", false);
-    assertTrue(a.validateOptions(is.getOptions()));
     a.init(new SortedMapIterator(tm), is.getOptions(), null);
     a.seek(new Range(), EMPTY_COL_FAMS, false);
     assertEquals(size(a), 88);
@@ -445,29 +440,9 @@ public class FilterTest {
     assertEquals(size(a), 32);
     
     TimestampFilter.setEnd(is, "19990101000031GMT", false);
-    assertTrue(a.validateOptions(is.getOptions()));
     a.init(new SortedMapIterator(tm), is.getOptions(), null);
     a.seek(new Range(), EMPTY_COL_FAMS, false);
     assertEquals(size(a), 31);
-    
-    TimestampFilter.setEnd(is, 253402300800001l, true);
-    a.init(new SortedMapIterator(tm), is.getOptions(), null);
-    
-    is.clearOptions();
-    is.addOption(TimestampFilter.START, "19990101000011GMT");
-    assertTrue(a.validateOptions(is.getOptions()));
-    a.init(new SortedMapIterator(tm), is.getOptions(), null);
-    a.seek(new Range(), EMPTY_COL_FAMS, false);
-    assertEquals(size(a), 89);
-    
-    is.clearOptions();
-    is.addOption(TimestampFilter.END, "19990101000031GMT");
-    assertTrue(a.validateOptions(is.getOptions()));
-    a.init(new SortedMapIterator(tm), is.getOptions(), null);
-    a.seek(new Range(), EMPTY_COL_FAMS, false);
-    assertEquals(size(a), 32);
-    
-    assertFalse(a.validateOptions(EMPTY_OPTS));
   }
   
   @Test



Mime
View raw message