incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1208490 - in /incubator/accumulo/trunk: ./ src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java src/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
Date Wed, 30 Nov 2011 16:25:58 GMT
Author: billie
Date: Wed Nov 30 16:25:57 2011
New Revision: 1208490

URL: http://svn.apache.org/viewvc?rev=1208490&view=rev
Log:
ACCUMULO-153 merged to trunk

Modified:
    incubator/accumulo/trunk/   (props changed)
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
    incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java

Propchange: incubator/accumulo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 30 16:25:57 2011
@@ -1,2 +1,2 @@
 /incubator/accumulo/branches/1.3:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031
-/incubator/accumulo/branches/1.4:1201902-1208117
+/incubator/accumulo/branches/1.4:1201902-1208489

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java?rev=1208490&r1=1208489&r2=1208490&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
Wed Nov 30 16:25:57 2011
@@ -335,7 +335,7 @@ public abstract class InputFormatBase<K,
    * @deprecated since 1.4, see {@link #addIterator(JobContext, IteratorSetting)}
    */
   public static void setIteratorOption(JobContext job, String iteratorName, String key, String
value) {
-    if (value == null)
+    if (iteratorName == null || key == null || value == null)
       return;
     
     String iteratorOptions = job.getConfiguration().get(ITERATORS_OPTIONS);
@@ -836,8 +836,8 @@ public abstract class InputFormatBase<K,
     public AccumuloIteratorOption(String iteratorOption) {
       StringTokenizer tokenizer = new StringTokenizer(iteratorOption, FIELD_SEP);
       this.iteratorName = tokenizer.nextToken();
-      this.key = tokenizer.nextToken();
       try {
+        this.key = URLDecoder.decode(tokenizer.nextToken(), "UTF-8");
         this.value = URLDecoder.decode(tokenizer.nextToken(), "UTF-8");
       } catch (UnsupportedEncodingException e) {
         throw new RuntimeException(e);
@@ -859,7 +859,7 @@ public abstract class InputFormatBase<K,
     @Override
     public String toString() {
       try {
-        return new String(iteratorName + FIELD_SEP + key + FIELD_SEP + URLEncoder.encode(value,
"UTF-8"));
+        return new String(iteratorName + FIELD_SEP + URLEncoder.encode(key, "UTF-8") + FIELD_SEP
+ URLEncoder.encode(value, "UTF-8"));
       } catch (UnsupportedEncodingException e) {
         throw new RuntimeException(e);
       }

Modified: incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java?rev=1208490&r1=1208489&r2=1208490&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
(original)
+++ incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
Wed Nov 30 16:25:57 2011
@@ -144,6 +144,42 @@ public class AccumuloInputFormatTest {
   }
   
   /**
+   * Test adding iterator options where the keys and values contain both the FIELD_SEPARATOR
character (':') and ITERATOR_SEPARATOR (',') characters. There
+   * should be no exceptions thrown when trying to parse these types of option entries.
+   * 
+   * This test makes sure that the expected raw values, as appears in the Job, are equal
to what's expected.
+   */
+  @Test
+  public void testIteratorOptionEncoding() throws Throwable {
+    String key = "colon:delimited:key";
+    String value = "comma,delimited,value";
+    IteratorSetting someSetting = new IteratorSetting(1, "iterator", "Iterator.class");
+    someSetting.addOption(key, value);
+    Job job = new Job();
+    AccumuloInputFormat.addIterator(job, someSetting);
+    
+    final String rawConfigOpt = new AccumuloIteratorOption("iterator", key, value).toString();
+    
+    assertEquals(rawConfigOpt, job.getConfiguration().get("AccumuloInputFormat.iterators.options"));
+    
+    List<AccumuloIteratorOption> opts = AccumuloInputFormat.getIteratorOptions(job);
+    assertEquals(1, opts.size());
+    assertEquals(opts.get(0).getKey(), key);
+    assertEquals(opts.get(0).getValue(), value);
+    
+    someSetting.addOption(key + "2", value);
+    someSetting.setPriority(2);
+    someSetting.setName("it2");
+    AccumuloInputFormat.addIterator(job, someSetting);
+    opts = AccumuloInputFormat.getIteratorOptions(job);
+    assertEquals(3, opts.size());
+    for (AccumuloIteratorOption opt : opts) {
+      assertEquals(opt.getKey().substring(0, key.length()), key);
+      assertEquals(opt.getValue(), value);
+    }
+  }
+  
+  /**
    * Test getting iterator settings for multiple iterators set
    */
   @Test



Mime
View raw message