accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1434751 - in /accumulo/trunk: core/src/main/java/org/apache/accumulo/core/iterators/ core/src/main/java/org/apache/accumulo/core/iterators/user/ core/src/test/java/org/apache/accumulo/core/iterators/user/ examples/simple/src/main/java/org/...
Date Thu, 17 Jan 2013 16:05:13 GMT
Author: billie
Date: Thu Jan 17 16:05:12 2013
New Revision: 1434751

URL: http://svn.apache.org/viewvc?rev=1434751&view=rev
Log:
ACCUMULO-846 cleaned up options validation

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/AggregatingIterator.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Filter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/VersioningIterator.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
    accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/combiner/StatsCombiner.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/AggregatingIterator.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/AggregatingIterator.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/AggregatingIterator.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/AggregatingIterator.java
Thu Jan 17 16:05:12 2013
@@ -190,7 +190,7 @@ public class AggregatingIterator impleme
     for (Entry<String,String> entry : options.entrySet()) {
       String classname = entry.getValue();
       if (classname == null)
-        return false;
+        throw new IllegalArgumentException("classname null");
       Class<? extends Aggregator> clazz;
       try {
         clazz = AccumuloVFSClassLoader.loadClass(classname, Aggregator.class);

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java Thu
Jan 17 16:05:12 2013
@@ -35,13 +35,13 @@ import org.apache.accumulo.core.iterator
 import org.apache.log4j.Logger;
 
 /**
- * A SortedKeyValueIterator that combines the Values for different versions (timestamps)
of a Key into a single Value. Combiner will replace one or more versions of a Key
- * and their Values with the most recent Key and a Value which is the result of the reduce
method.
+ * A SortedKeyValueIterator that combines the Values for different versions (timestamps)
of a Key into a single Value. Combiner will replace one or more
+ * versions of a Key and their Values with the most recent Key and a Value which is the result
of the reduce method.
  * 
  * Subclasses must implement a reduce method: {@code public Value reduce(Key key, Iterator<Value>
iter)}.
  * 
- * This reduce method will be passed the most recent Key and an iterator over the Values
for all non-deleted versions of that Key.
- * A combiner will not combine keys that differ by more than the timestamp.
+ * This reduce method will be passed the most recent Key and an iterator over the Values
for all non-deleted versions of that Key. A combiner will not combine
+ * keys that differ by more than the timestamp.
  */
 public abstract class Combiner extends WrappingIterator implements OptionDescriber {
   static final Logger log = Logger.getLogger(Combiner.class);
@@ -254,20 +254,24 @@ public abstract class Combiner extends W
   @Override
   public boolean validateOptions(Map<String,String> options) {
     if (options.containsKey(ALL_OPTION)) {
-      combineAllColumns = Boolean.parseBoolean(options.get(ALL_OPTION));
+      try {
+        combineAllColumns = Boolean.parseBoolean(options.get(ALL_OPTION));
+      } catch (Exception e) {
+        throw new IllegalArgumentException("bad boolean " + ALL_OPTION + ":" + options.get(ALL_OPTION));
+      }
       if (combineAllColumns)
         return true;
     }
     if (!options.containsKey(COLUMNS_OPTION))
-      return false;
+      throw new IllegalArgumentException("options must include " + ALL_OPTION + " or " +
COLUMNS_OPTION);
     
     String encodedColumns = options.get(COLUMNS_OPTION);
     if (encodedColumns.length() == 0)
-      return false;
+      throw new IllegalArgumentException("empty columns specified in option " + COLUMNS_OPTION);
     
     for (String columns : encodedColumns.split(",")) {
       if (!ColumnSet.isValidEncoding(columns))
-        return false;
+        throw new IllegalArgumentException("invalid column encoding " + encodedColumns);
     }
     
     return true;

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Filter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Filter.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Filter.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/Filter.java Thu Jan
17 16:05:12 2013
@@ -101,7 +101,11 @@ public abstract class Filter extends Wra
   @Override
   public boolean validateOptions(Map<String,String> options) {
     if (options.get(NEGATE) != null) {
-      Boolean.parseBoolean(options.get(NEGATE));
+      try {
+        Boolean.parseBoolean(options.get(NEGATE));
+      } catch (Exception e) {
+        throw new IllegalArgumentException("bad boolean " + NEGATE + ":" + options.get(NEGATE));
+      }
     }
     return true;
   }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/FirstEntryInRowIterator.java
Thu Jan 17 16:05:12 2013
@@ -92,8 +92,7 @@ public class FirstEntryInRowIterator ext
         Key nextKey = getSource().getTopKey().followingKey(PartialKey.ROW);
         if (!latestRange.afterEndKey(nextKey))
           getSource().seek(new Range(nextKey, true, latestRange.getEndKey(), latestRange.isEndKeyInclusive()),
latestColumnFamilies, latestInclusive);
-        else
-        {
+        else {
           finished = true;
           break;
         }
@@ -103,13 +102,12 @@ public class FirstEntryInRowIterator ext
   }
   
   private boolean finished = true;
-
+  
   @Override
-  public boolean hasTop()
-  {
+  public boolean hasTop() {
     return !finished && getSource().hasTop();
   }
-
+  
   @Override
   public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
throws IOException {
     // save parameters for future internal seeks
@@ -122,7 +120,7 @@ public class FirstEntryInRowIterator ext
     Range seekRange = new Range(startKey == null ? null : new Key(startKey.getRow()), true,
range.getEndKey(), range.isEndKeyInclusive());
     super.seek(seekRange, columnFamilies, inclusive);
     finished = false;
-
+    
     if (getSource().hasTop()) {
       lastRowFound = getSource().getTopKey().getRow();
       if (range.beforeStartKey(getSource().getTopKey()))
@@ -143,11 +141,12 @@ public class FirstEntryInRowIterator ext
   public boolean validateOptions(Map<String,String> options) {
     try {
       String o = options.get(NUM_SCANS_STRING_NAME);
-      Integer i = o == null ? 10 : Integer.parseInt(o);
-      return i != null;
+      if (o != null)
+        Integer.parseInt(o);
     } catch (Exception e) {
-      return false;
+      throw new IllegalArgumentException("bad integer " + NUM_SCANS_STRING_NAME + ":" + options.get(NUM_SCANS_STRING_NAME),
e);
     }
+    return true;
   }
   
 }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/LongCombiner.java
Thu Jan 17 16:05:12 2013
@@ -102,8 +102,13 @@ public abstract class LongCombiner exten
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
-    setEncoder(options);
+    if (super.validateOptions(options) == false)
+      return false;
+    try {
+      setEncoder(options);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad encoder option", e);
+    }
     return true;
   }
   

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/OptionDescriber.java
Thu Jan 17 16:05:12 2013
@@ -122,7 +122,9 @@ public interface OptionDescriber {
    * 
    * @param options
    *          a map of option names to option values
-   * @return true if options are valid, false otherwise
+   * @return true if options are valid, false otherwise (IllegalArgumentException preferred)
+   * @exception IllegalArgumentException
+   *              if there are problems with the options
    */
   public boolean validateOptions(Map<String,String> options);
 }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/SortedKeyIterator.java
Thu Jan 17 16:05:12 2013
@@ -47,6 +47,6 @@ public class SortedKeyIterator extends W
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    return options == null || options.isEmpty();
+    return true;
   }
 }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/TypedValueCombiner.java
Thu Jan 17 16:05:12 2013
@@ -211,8 +211,13 @@ public abstract class TypedValueCombiner
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
-    setLossyness(options);
+    if (super.validateOptions(options) == false)
+      return false;
+    try {
+      setLossyness(options);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad boolean " + LOSSY + ":" + options.get(LOSSY));
+    }
     return true;
   }
   

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/AgeOffFilter.java
Thu Jan 17 16:05:12 2013
@@ -91,11 +91,12 @@ public class AgeOffFilter extends Filter
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
+    if (super.validateOptions(options) == false)
+      return false;
     try {
       Long.parseLong(options.get(TTL));
-    } catch (NumberFormatException e) {
-      return false;
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad long " + TTL + ":" + options.get(TTL));
     }
     return true;
   }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/ColumnAgeOffFilter.java
Thu Jan 17 16:05:12 2013
@@ -99,8 +99,13 @@ public class ColumnAgeOffFilter extends 
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
-    this.ttls = new TTLSet(options);
+    if (super.validateOptions(options) == false)
+      return false;
+    try {
+      this.ttls = new TTLSet(options);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad TTL options", e);
+    }
     return true;
   }
   

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/LargeRowFilter.java
Thu Jan 17 16:05:12 2013
@@ -257,20 +257,15 @@ public class LargeRowFilter implements S
   @Override
   public boolean validateOptions(Map<String,String> options) {
     if (options == null || options.size() < 1) {
-      System.out.println("Bad # of options, must supply: " + MAX_COLUMNS + " as value");
-      return false;
+      throw new IllegalArgumentException("Bad # of options, must supply: " + MAX_COLUMNS
+ " as value");
     }
     
-    if (options.containsKey(MAX_COLUMNS)) {
-      try {
-        maxColumns = Integer.parseInt(options.get(MAX_COLUMNS));
-      } catch (NumberFormatException e) {
-        e.printStackTrace();
-        return false;
-      }
-    } else {
-      System.out.println("Need to have " + MAX_COLUMNS);
-      return false;
+    if (!options.containsKey(MAX_COLUMNS))
+      throw new IllegalArgumentException("Bad # of options, must supply: " + MAX_COLUMNS
+ " as value");
+    try {
+      maxColumns = Integer.parseInt(options.get(MAX_COLUMNS));
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad integer " + MAX_COLUMNS + ":" + options.get(MAX_COLUMNS));
     }
     
     return true;

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
Thu Jan 17 16:05:12 2013
@@ -46,8 +46,6 @@ public class RegExFilter extends Filter 
     return result;
   }
   
-  
-  
   public static final String ROW_REGEX = "rowRegex";
   public static final String COLF_REGEX = "colfRegex";
   public static final String COLQ_REGEX = "colqRegex";
@@ -101,18 +99,12 @@ public class RegExFilter extends Filter 
   @Override
   public boolean accept(Key key, Value value) {
     if (orFields)
-      return ( 
-          (matches(rowMatcher, rowMatcher == null ? null : key.getRowData())) || 
-          (matches(colfMatcher, colfMatcher == null ? null : key.getColumnFamilyData()))
|| 
-          (matches(colqMatcher, colqMatcher == null ? null : key.getColumnQualifierData()))
|| 
-          (matches(valueMatcher, value.get(), 0, value.get().length))
-          );
-    return (
-        (matches(rowMatcher, rowMatcher == null ? null : key.getRowData())) && 
-        (matches(colfMatcher, colfMatcher == null ? null : key.getColumnFamilyData())) &&

-        (matches(colqMatcher, colqMatcher == null ? null : key.getColumnQualifierData()))
&&
-        (matches(valueMatcher, value.get(), 0, value.get().length))
-        );
+      return ((matches(rowMatcher, rowMatcher == null ? null : key.getRowData()))
+          || (matches(colfMatcher, colfMatcher == null ? null : key.getColumnFamilyData()))
+          || (matches(colqMatcher, colqMatcher == null ? null : key.getColumnQualifierData()))
|| (matches(valueMatcher, value.get(), 0, value.get().length)));
+    return ((matches(rowMatcher, rowMatcher == null ? null : key.getRowData()))
+        && (matches(colfMatcher, colfMatcher == null ? null : key.getColumnFamilyData()))
+        && (matches(colqMatcher, colqMatcher == null ? null : key.getColumnQualifierData()))
&& (matches(valueMatcher, value.get(), 0, value.get().length)));
   }
   
   @Override
@@ -149,9 +141,9 @@ public class RegExFilter extends Filter 
     }
     
     if (options.containsKey(MATCH_SUBSTRING)) {
-    	matchSubstring = Boolean.parseBoolean(options.get(MATCH_SUBSTRING));
+      matchSubstring = Boolean.parseBoolean(options.get(MATCH_SUBSTRING));
     } else {
-    	matchSubstring = false;
+      matchSubstring = false;
     }
     
     if (options.containsKey(ENCODING)) {
@@ -176,29 +168,33 @@ public class RegExFilter extends Filter 
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
-    if (options.containsKey(ROW_REGEX))
-      Pattern.compile(options.get(ROW_REGEX)).matcher("");
-    
-    if (options.containsKey(COLF_REGEX))
-      Pattern.compile(options.get(COLF_REGEX)).matcher("");
+    if (super.validateOptions(options) == false)
+      return false;
     
-    if (options.containsKey(COLQ_REGEX))
-      Pattern.compile(options.get(COLQ_REGEX)).matcher("");
-    
-    if (options.containsKey(VALUE_REGEX))
-      Pattern.compile(options.get(VALUE_REGEX)).matcher("");
+    try {
+      if (options.containsKey(ROW_REGEX))
+        Pattern.compile(options.get(ROW_REGEX)).matcher("");
+      
+      if (options.containsKey(COLF_REGEX))
+        Pattern.compile(options.get(COLF_REGEX)).matcher("");
+      
+      if (options.containsKey(COLQ_REGEX))
+        Pattern.compile(options.get(COLQ_REGEX)).matcher("");
+      
+      if (options.containsKey(VALUE_REGEX))
+        Pattern.compile(options.get(VALUE_REGEX)).matcher("");
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad regex", e);
+    }
     
     if (options.containsKey(ENCODING)) {
       try {
         this.encoding = options.get(ENCODING);
         if ("".equals(this.encoding))
           encoding = ENCODING_DEFAULT;
-        @SuppressWarnings("unused")
-        String test = new String("test".getBytes(), encoding);
+        new String("test".getBytes(), encoding);
       } catch (UnsupportedEncodingException e) {
-        e.printStackTrace();
-        return false;
+        throw new IllegalArgumentException("invalid encoding " + ENCODING + ":" + this.encoding,
e);
       }
     }
     
@@ -206,8 +202,7 @@ public class RegExFilter extends Filter 
   }
   
   /**
-   * Encode the terms to match against in the iterator
-   * Same as calling setRegexs(IteratorSetting si, String rowTerm, String cfTerm, String
cqTerm, String valueTerm, boolean orFields, boolean matchSubstring)
+   * Encode the terms to match against in the iterator. Same as calling {@link #setRegexs(IteratorSetting,
String, String, String, String, boolean, boolean)}
    * with matchSubstring set to false
    * 
    * @param si
@@ -223,7 +218,7 @@ public class RegExFilter extends Filter 
    * @param orFields
    *          if true, any of the non-null terms can match to return the entry
    */
-  public static void setRegexs(IteratorSetting si, String rowTerm, String cfTerm, String
cqTerm, String valueTerm, boolean orFields) {  
+  public static void setRegexs(IteratorSetting si, String rowTerm, String cfTerm, String
cqTerm, String valueTerm, boolean orFields) {
     setRegexs(si, rowTerm, cfTerm, cqTerm, valueTerm, orFields, false);
   }
   
@@ -244,7 +239,7 @@ public class RegExFilter extends Filter 
    *          if true then search expressions will match on partial strings
    */
   public static void setRegexs(IteratorSetting si, String rowTerm, String cfTerm, String
cqTerm, String valueTerm, boolean orFields, boolean matchSubstring) {
-	 
+    
     if (rowTerm != null)
       si.addOption(RegExFilter.ROW_REGEX, rowTerm);
     if (cfTerm != null)
@@ -254,13 +249,10 @@ public class RegExFilter extends Filter 
     if (valueTerm != null)
       si.addOption(RegExFilter.VALUE_REGEX, valueTerm);
     si.addOption(RegExFilter.OR_FIELDS, String.valueOf(orFields));
-	  si.addOption(RegExFilter.MATCH_SUBSTRING, String.valueOf(matchSubstring));
-	  
+    si.addOption(RegExFilter.MATCH_SUBSTRING, String.valueOf(matchSubstring));
+    
   }
   
-  
-  
-  
   /**
    * Set the encoding string to use when interpreting characters
    * 

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/SummingArrayCombiner.java
Thu Jan 17 16:05:12 2013
@@ -127,8 +127,13 @@ public class SummingArrayCombiner extend
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
-    setEncoder(options);
+    if (super.validateOptions(options) == false)
+      return false;
+    try {
+      setEncoder(options);
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad encoder option", e);
+    }
     return true;
   }
   

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/TimestampFilter.java
Thu Jan 17 16:05:12 2013
@@ -136,7 +136,8 @@ public class TimestampFilter extends Fil
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    super.validateOptions(options);
+    if (super.validateOptions(options) == false)
+      return false;
     boolean hasStart = false;
     boolean hasEnd = false;
     try {
@@ -157,13 +158,13 @@ public class TimestampFilter extends Fil
           dateParser.parse(s);
       }
       if (!hasStart && !hasEnd)
-        return false;
+        throw new IllegalArgumentException(START + " or " + END + " must be specified");
       if (options.get(START_INCL) != null)
         Boolean.parseBoolean(options.get(START_INCL));
       if (options.get(END_INCL) != null)
         Boolean.parseBoolean(options.get(END_INCL));
     } catch (Exception e) {
-      return false;
+      throw new IllegalArgumentException("invalid options", e);
     }
     return true;
   }

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/VersioningIterator.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/VersioningIterator.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/VersioningIterator.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/user/VersioningIterator.java
Thu Jan 17 16:05:12 2013
@@ -147,7 +147,12 @@ public class VersioningIterator extends 
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
-    int i = Integer.parseInt(options.get(MAXVERSIONS_OPT));
+    int i;
+    try {
+      i = Integer.parseInt(options.get(MAXVERSIONS_OPT));
+    } catch (Exception e) {
+      throw new IllegalArgumentException("bad integer " + MAXVERSIONS_OPT + ":" + options.get(MAXVERSIONS_OPT));
+    }
     if (i < 1)
       throw new IllegalArgumentException(MAXVERSIONS_OPT + " for versioning iterator must
be >= 1");
     return true;

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
(original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/user/FilterTest.java
Thu Jan 17 16:05:12 2013
@@ -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;
@@ -199,7 +198,10 @@ public class FilterTest {
     AgeOffFilter.setCurrentTime(is, 1001l);
     AgeOffFilter.setNegate(is, true);
     assertTrue(((AgeOffFilter) a).validateOptions(is.getOptions()));
-    assertFalse(((AgeOffFilter) a).validateOptions(EMPTY_OPTS));
+    try {
+      ((AgeOffFilter) a).validateOptions(EMPTY_OPTS);
+      assertTrue(false);
+    } catch (IllegalArgumentException e) {}
     a.init(new SortedMapIterator(tm), is.getOptions(), null);
     a = a.deepCopy(null);
     SortedKeyValueIterator<Key,Value> copy = a.deepCopy(null);
@@ -467,7 +469,10 @@ public class FilterTest {
     a.seek(new Range(), EMPTY_COL_FAMS, false);
     assertEquals(size(a), 32);
     
-    assertFalse(a.validateOptions(EMPTY_OPTS));
+    try {
+      a.validateOptions(EMPTY_OPTS);
+      assertTrue(false);
+    } catch (IllegalArgumentException e) {}
   }
   
   @Test

Modified: accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/combiner/StatsCombiner.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/combiner/StatsCombiner.java?rev=1434751&r1=1434750&r2=1434751&view=diff
==============================================================================
--- accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/combiner/StatsCombiner.java
(original)
+++ accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/combiner/StatsCombiner.java
Thu Jan 17 16:05:12 2013
@@ -92,7 +92,7 @@ public class StatsCombiner extends Combi
       return false;
     
     if (options.containsKey(RADIX_OPTION) && !options.get(RADIX_OPTION).matches("\\d+"))
-      return false;
+      throw new IllegalArgumentException("invalid option " + RADIX_OPTION + ":" + options.get(RADIX_OPTION));
     
     return true;
   }



Mime
View raw message