accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjno...@apache.org
Subject [1/2] ACCUMULO-391 Performing refactor to the legacy mapred InputFormatBase
Date Wed, 16 Oct 2013 01:30:30 GMT
Updated Branches:
  refs/heads/master 9a63ff4ec -> cb97e82a4


http://git-wip-us.apache.org/repos/asf/accumulo/blob/cb97e82a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloMultiTableInputFormatTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloMultiTableInputFormatTest.java
b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloMultiTableInputFormatTest.java
index 6bbb1d6..27149eb 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloMultiTableInputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloMultiTableInputFormatTest.java
@@ -1,5 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.accumulo.core.client.mapreduce;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.accumulo.core.client.Connector;
@@ -21,30 +45,22 @@ import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 import org.junit.Test;
 
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
 public class AccumuloMultiTableInputFormatTest {
 
   private static final String PREFIX = AccumuloMultiTableInputFormatTest.class.getSimpleName();
   private static final String INSTANCE_NAME = PREFIX + "_mapreduce_instance";
   private static final String TEST_TABLE_1 = PREFIX + "_mapreduce_table_1";
   private static final String TEST_TABLE_2 = PREFIX + "_mapreduce_table_2";
-  
+
   private static AssertionError e1 = null;
   private static AssertionError e2 = null;
-  
+
   private static class MRTester extends Configured implements Tool {
-    
+
     private static class TestMapper extends Mapper<Key,Value,Key,Value> {
       Key key = null;
       int count = 0;
-      
+
       @Override
       protected void map(Key k, Value v, Context context) throws IOException, InterruptedException
{
         try {
@@ -59,7 +75,7 @@ public class AccumuloMultiTableInputFormatTest {
         key = new Key(k);
         count++;
       }
-      
+
       @Override
       protected void cleanup(Context context) throws IOException, InterruptedException {
         try {
@@ -69,53 +85,53 @@ public class AccumuloMultiTableInputFormatTest {
         }
       }
     }
-    
+
     @Override
     public int run(String[] args) throws Exception {
-      
+
       if (args.length != 4) {
         throw new IllegalArgumentException("Usage : " + MRTester.class.getName() + " <user>
<pass> <table1> <table2>");
       }
-      
+
       String user = args[0];
       String pass = args[1];
       String table1 = args[2];
       String table2 = args[3];
-      
+
       Job job = new Job(getConf(), this.getClass().getSimpleName() + "_" + System.currentTimeMillis());
       job.setJarByClass(this.getClass());
-      
+
       job.setInputFormatClass(AccumuloMultiTableInputFormat.class);
-      
+
       AccumuloMultiTableInputFormat.setConnectorInfo(job, user, new PasswordToken(pass));
-      
+
       BatchScanConfig tableConfig1 = new BatchScanConfig();
       BatchScanConfig tableConfig2 = new BatchScanConfig();
-      
-      Map<String, BatchScanConfig> configMap = new HashMap<String, BatchScanConfig>();
+
+      Map<String,BatchScanConfig> configMap = new HashMap<String,BatchScanConfig>();
       configMap.put(table1, tableConfig1);
       configMap.put(table2, tableConfig2);
-      
+
       AccumuloMultiTableInputFormat.setBatchScanConfigs(job, configMap);
       AccumuloMultiTableInputFormat.setMockInstance(job, INSTANCE_NAME);
-      
+
       job.setMapperClass(TestMapper.class);
       job.setMapOutputKeyClass(Key.class);
       job.setMapOutputValueClass(Value.class);
       job.setOutputFormatClass(NullOutputFormat.class);
-      
+
       job.setNumReduceTasks(0);
-      
+
       job.waitForCompletion(true);
-      
+
       return job.isSuccessful() ? 0 : 1;
     }
-    
+
     public static void main(String[] args) throws Exception {
       assertEquals(0, ToolRunner.run(CachedConfiguration.getInstance(), new MRTester(), args));
     }
   }
-  
+
   /**
    * Generate incrementing counts and attach table name to the key/value so that order and
multi-table data can be verified.
    */
@@ -137,34 +153,32 @@ public class AccumuloMultiTableInputFormatTest {
     }
     bw.close();
     bw2.close();
-    
+
     MRTester.main(new String[] {"root", "", TEST_TABLE_1, TEST_TABLE_2});
     assertNull(e1);
     assertNull(e2);
   }
-  
+
   /**
    * Verify {@link BatchScanConfig} objects get correctly serialized in the JobContext.
    */
   @Test
-  public void testTableQueryConfigSerialization() throws IOException {
-    
+  public void testBatchScanConfigSerialization() throws IOException {
+
     Job job = new Job();
-    
-    
-    
-    BatchScanConfig tableConfig= new BatchScanConfig().setRanges(Collections.singletonList(new
Range("a", "b")))
-        .fetchColumns(Collections.singleton(new Pair<Text, Text>(new Text("CF1"), new
Text("CQ1"))))
+
+    BatchScanConfig tableConfig = new BatchScanConfig().setRanges(Collections.singletonList(new
Range("a", "b")))
+        .fetchColumns(Collections.singleton(new Pair<Text,Text>(new Text("CF1"), new
Text("CQ1"))))
         .setIterators(Collections.singletonList(new IteratorSetting(50, "iter1", "iterclass1")));
 
-    Map<String, BatchScanConfig> configMap = new HashMap<String, BatchScanConfig>();
+    Map<String,BatchScanConfig> configMap = new HashMap<String,BatchScanConfig>();
     configMap.put(TEST_TABLE_1, tableConfig);
     configMap.put(TEST_TABLE_2, tableConfig);
-    
+
     AccumuloMultiTableInputFormat.setBatchScanConfigs(job, configMap);
-    
+
     assertEquals(tableConfig, AccumuloMultiTableInputFormat.getBatchScanConfig(job, TEST_TABLE_1));
     assertEquals(tableConfig, AccumuloMultiTableInputFormat.getBatchScanConfig(job, TEST_TABLE_2));
   }
-  
+
 }


Mime
View raw message