accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1423565 - 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 Tue, 18 Dec 2012 18:18:32 GMT
Author: billie
Date: Tue Dec 18 18:18:31 2012
New Revision: 1423565

URL: http://svn.apache.org/viewvc?rev=1423565&view=rev
Log:
ACCUMULO-776 added fast failure when unusable longs are set for 1.4

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=1423565&r1=1423564&r2=1423565&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
Tue Dec 18 18:18:31 2012
@@ -17,6 +17,7 @@
 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;
@@ -185,6 +186,11 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the start is inclusive
    */
   public static void setStart(IteratorSetting is, String start, boolean startInclusive) {
+    try {
+      initDateParser().parse(start);
+    } catch (ParseException e) {
+      throw new IllegalArgumentException(e);
+    }
     is.addOption(START, start);
     is.addOption(START_INCL, Boolean.toString(startInclusive));
   }
@@ -200,6 +206,11 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the end is inclusive
    */
   public static void setEnd(IteratorSetting is, String end, boolean endInclusive) {
+    try {
+      initDateParser().parse(end);
+    } catch (ParseException e) {
+      throw new IllegalArgumentException(e);
+    }
     is.addOption(END, end);
     is.addOption(END_INCL, Boolean.toString(endInclusive));
   }
@@ -248,9 +259,7 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the start is inclusive
    */
   public static void setStart(IteratorSetting is, long start, boolean startInclusive) {
-    SimpleDateFormat dateParser = initDateParser();
-    is.addOption(START, dateParser.format(new Date(start)));
-    is.addOption(START_INCL, Boolean.toString(startInclusive));
+    setStart(is, initDateParser().format(new Date(start)), startInclusive);
   }
   
   /**
@@ -264,8 +273,6 @@ public class TimestampFilter extends Fil
    *          boolean indicating whether the end is inclusive
    */
   public static void setEnd(IteratorSetting is, long end, boolean endInclusive) {
-    SimpleDateFormat dateParser = initDateParser();
-    is.addOption(END, dateParser.format(new Date(end)));
-    is.addOption(END_INCL, Boolean.toString(endInclusive));
+    setEnd(is, initDateParser().format(new Date(end)), 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=1423565&r1=1423564&r2=1423565&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
Tue Dec 18 18:18:31 2012
@@ -443,6 +443,15 @@ public class FilterTest {
     a.init(new SortedMapIterator(tm), is.getOptions(), null);
     a.seek(new Range(), EMPTY_COL_FAMS, false);
     assertEquals(size(a), 31);
+    
+    try {
+      TimestampFilter.setStart(is, 253402300800001l, true);
+      assertTrue(false);
+    } catch (Exception e) {}
+    try {
+      TimestampFilter.setEnd(is, 253402300800001l, true);
+      assertTrue(false);
+    } catch (Exception e) {}
   }
   
   @Test



Mime
View raw message