You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by cj...@apache.org on 2013/10/02 05:22:43 UTC
[07/11] git commit: Fixing some more formatting. Adding license
headers. ACCUMULO-391
Fixing some more formatting. Adding license headers. ACCUMULO-391
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/6648e8a1
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/6648e8a1
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/6648e8a1
Branch: refs/heads/ACCUMULO-391
Commit: 6648e8a1c97939f740b24f9368ecda9f7072cbd2
Parents: 53bcc85
Author: Corey J. Nolet <cj...@gmail.com>
Authored: Tue Oct 1 21:45:37 2013 -0400
Committer: Corey J. Nolet <cj...@gmail.com>
Committed: Tue Oct 1 21:46:17 2013 -0400
----------------------------------------------------------------------
.../mapreduce/lib/util/InputConfigurator.java | 88 +++++------
.../accumulo/core/conf/TableQueryConfig.java | 147 +++++++++++--------
.../mapreduce/AccumuloInputFormatTest.java | 44 +++---
.../core/conf/TableQueryConfigTest.java | 5 +-
4 files changed, 158 insertions(+), 126 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6648e8a1/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
index b235e13..42097f1 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
@@ -60,7 +60,7 @@ import org.apache.hadoop.util.StringUtils;
* @since 1.5.0
*/
public class InputConfigurator extends ConfiguratorBase {
-
+
/**
* Configuration keys for {@link Scanner}.
*
@@ -69,7 +69,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static enum ScanOpts {
TABLE_NAME, AUTHORIZATIONS, RANGES, COLUMNS, ITERATORS, TABLE_CONFIGS
}
-
+
/**
* Configuration keys for various features.
*
@@ -78,7 +78,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static enum Features {
AUTO_ADJUST_RANGES, SCAN_ISOLATION, USE_LOCAL_ITERATORS, SCAN_OFFLINE
}
-
+
/**
* Sets the name of the input table, over which this job will scan.
*
@@ -94,7 +94,7 @@ public class InputConfigurator extends ConfiguratorBase {
notNull(tableName);
conf.set(enumToConfKey(implementingClass, ScanOpts.TABLE_NAME), tableName);
}
-
+
/**
* Sets the name of the input table, over which this job will scan.
*
@@ -107,7 +107,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static String getInputTableName(Class<?> implementingClass, Configuration conf) {
return conf.get(enumToConfKey(implementingClass, ScanOpts.TABLE_NAME));
}
-
+
/**
* Sets the {@link Authorizations} used to scan. Must be a subset of the user's authorization. Defaults to the empty set.
*
@@ -123,7 +123,7 @@ public class InputConfigurator extends ConfiguratorBase {
if (auths != null && !auths.isEmpty())
conf.set(enumToConfKey(implementingClass, ScanOpts.AUTHORIZATIONS), auths.serialize());
}
-
+
/**
* Gets the authorizations to set for the scans from the configuration.
*
@@ -139,7 +139,7 @@ public class InputConfigurator extends ConfiguratorBase {
String authString = conf.get(enumToConfKey(implementingClass, ScanOpts.AUTHORIZATIONS));
return authString == null ? Authorizations.EMPTY : new Authorizations(authString.getBytes());
}
-
+
/**
* Sets the input ranges to scan on all input tables for this job. If not set, the entire table will be scanned.
*
@@ -155,7 +155,7 @@ public class InputConfigurator extends ConfiguratorBase {
*/
public static void setRanges(Class<?> implementingClass, Configuration conf, Collection<Range> ranges) {
notNull(ranges);
-
+
ArrayList<String> rangeStrings = new ArrayList<String>(ranges.size());
try {
for (Range r : ranges) {
@@ -168,7 +168,7 @@ public class InputConfigurator extends ConfiguratorBase {
throw new IllegalArgumentException("Unable to encode ranges to Base64", ex);
}
}
-
+
/**
* Gets the ranges to scan over from a job.
*
@@ -183,7 +183,7 @@ public class InputConfigurator extends ConfiguratorBase {
* @see #setRanges(Class, Configuration, Collection)
*/
public static List<Range> getRanges(Class<?> implementingClass, Configuration conf) throws IOException {
-
+
Collection<String> encodedRanges = conf.getStringCollection(enumToConfKey(implementingClass, ScanOpts.RANGES));
List<Range> ranges = new ArrayList<Range>();
for (String rangeString : encodedRanges) {
@@ -194,7 +194,7 @@ public class InputConfigurator extends ConfiguratorBase {
}
return ranges;
}
-
+
/**
* Gets a list of the iterator settings (for iterators to apply to a scanner) from this configuration.
*
@@ -207,12 +207,12 @@ public class InputConfigurator extends ConfiguratorBase {
* @see #addIterator(Class, Configuration, IteratorSetting)
*/
public static List<IteratorSetting> getIterators(Class<?> implementingClass, Configuration conf) {
- String iterators = conf.get(enumToConfKey(implementingClass,ScanOpts.ITERATORS));
-
+ String iterators = conf.get(enumToConfKey(implementingClass, ScanOpts.ITERATORS));
+
// If no iterators are present, return an empty list
if (iterators == null || iterators.isEmpty())
return new ArrayList<IteratorSetting>();
-
+
// Compose the set of iterators encoded in the job configuration
StringTokenizer tokens = new StringTokenizer(iterators, StringUtils.COMMA_STR);
List<IteratorSetting> list = new ArrayList<IteratorSetting>();
@@ -228,7 +228,7 @@ public class InputConfigurator extends ConfiguratorBase {
}
return list;
}
-
+
/**
* Restricts the columns that will be mapped over for this job. This applies the columns to all tables that have been set on the job.
*
@@ -247,10 +247,10 @@ public class InputConfigurator extends ConfiguratorBase {
notNull(columnFamilyColumnQualifierPairs);
ArrayList<String> columnStrings = new ArrayList<String>();
for (Pair<Text,Text> column : columnFamilyColumnQualifierPairs) {
-
+
if (column.getFirst() == null)
throw new IllegalArgumentException("Column family can not be null");
-
+
String col = new String(Base64.encodeBase64(TextUtil.getBytes(column.getFirst())), Constants.UTF8);
if (column.getSecond() != null)
col += ":" + new String(Base64.encodeBase64(TextUtil.getBytes(column.getSecond())), Constants.UTF8);
@@ -258,7 +258,7 @@ public class InputConfigurator extends ConfiguratorBase {
}
conf.setStrings(enumToConfKey(implementingClass, ScanOpts.COLUMNS), columnStrings.toArray(new String[0]));
}
-
+
/**
* Gets the columns to be mapped over from this job.
*
@@ -280,7 +280,7 @@ public class InputConfigurator extends ConfiguratorBase {
}
return columns;
}
-
+
/**
* Encode an iterator on the input for all tables associated with this job.
*
@@ -304,7 +304,7 @@ public class InputConfigurator extends ConfiguratorBase {
} catch (IOException e) {
throw new IllegalArgumentException("unable to serialize IteratorSetting");
}
-
+
String confKey = enumToConfKey(implementingClass, ScanOpts.ITERATORS);
String iterators = conf.get(confKey);
// No iterators specified yet, create a new string
@@ -317,7 +317,7 @@ public class InputConfigurator extends ConfiguratorBase {
// Store the iterators w/ the job
conf.set(confKey, iterators);
}
-
+
/**
* Controls the automatic adjustment of ranges for this job. This feature merges overlapping ranges, then splits them to align with tablet boundaries.
* Disabling this feature will cause exactly one Map task to be created for each specified range. The default setting is enabled. *
@@ -335,9 +335,9 @@ public class InputConfigurator extends ConfiguratorBase {
* @since 1.5.0
*/
public static void setAutoAdjustRanges(Class<?> implementingClass, Configuration conf, boolean enableFeature) {
- conf.setBoolean(enumToConfKey(implementingClass,Features.AUTO_ADJUST_RANGES),enableFeature);
+ conf.setBoolean(enumToConfKey(implementingClass, Features.AUTO_ADJUST_RANGES), enableFeature);
}
-
+
/**
* Determines whether a configuration has auto-adjust ranges enabled.
*
@@ -352,7 +352,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static Boolean getAutoAdjustRanges(Class<?> implementingClass, Configuration conf) {
return conf.getBoolean(enumToConfKey(implementingClass, Features.AUTO_ADJUST_RANGES), true);
}
-
+
/**
* Controls the use of the {@link IsolatedScanner} in this job.
*
@@ -370,7 +370,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static void setScanIsolation(Class<?> implementingClass, Configuration conf, boolean enableFeature) {
conf.setBoolean(enumToConfKey(implementingClass, Features.SCAN_ISOLATION), enableFeature);
}
-
+
/**
* Determines whether a configuration has isolation enabled.
*
@@ -385,7 +385,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static Boolean isIsolated(Class<?> implementingClass, Configuration conf) {
return conf.getBoolean(enumToConfKey(implementingClass, Features.SCAN_ISOLATION), false);
}
-
+
/**
* Controls the use of the {@link ClientSideIteratorScanner} in this job. Enabling this feature will cause the iterator stack to be constructed within the Map
* task, rather than within the Accumulo TServer. To use this feature, all classes needed for those iterators must be available on the classpath for the task.
@@ -404,7 +404,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static void setLocalIterators(Class<?> implementingClass, Configuration conf, boolean enableFeature) {
conf.setBoolean(enumToConfKey(implementingClass, Features.USE_LOCAL_ITERATORS), enableFeature);
}
-
+
/**
* Determines whether a configuration uses local iterators.
*
@@ -419,7 +419,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static Boolean usesLocalIterators(Class<?> implementingClass, Configuration conf) {
return conf.getBoolean(enumToConfKey(implementingClass, Features.USE_LOCAL_ITERATORS), false);
}
-
+
/**
* <p>
* Enable reading offline tables. By default, this feature is disabled and only online tables are scanned. This will make the map reduce job directly read the
@@ -456,7 +456,7 @@ public class InputConfigurator extends ConfiguratorBase {
public static void setOfflineTableScan(Class<?> implementingClass, Configuration conf, boolean enableFeature) {
conf.setBoolean(enumToConfKey(implementingClass, Features.SCAN_OFFLINE), enableFeature);
}
-
+
/**
* Determines whether a configuration has the offline table scan feature enabled.
*
@@ -471,9 +471,10 @@ public class InputConfigurator extends ConfiguratorBase {
public static Boolean isOfflineScan(Class<?> implementingClass, Configuration conf) {
return conf.getBoolean(enumToConfKey(implementingClass, Features.SCAN_OFFLINE), false);
}
-
+
/**
* Sets configurations for multiple tables at a time.
+ *
* @param implementingClass
* the class whose name will be used as a prefix for the property configuration key
* @param conf
@@ -495,9 +496,10 @@ public class InputConfigurator extends ConfiguratorBase {
String confKey = enumToConfKey(implementingClass, ScanOpts.TABLE_CONFIGS);
conf.setStrings(confKey, tableQueryConfigStrings.toArray(new String[0]));
}
-
+
/**
* Returns all {@link TableQueryConfig} objects associated with this job.
+ *
* @param implementingClass
* the class whose name will be used as a prefix for the property configuration key
* @param conf
@@ -527,12 +529,13 @@ public class InputConfigurator extends ConfiguratorBase {
}
if (defaultQueryConfig != null)
configs.add(defaultQueryConfig);
-
+
return configs;
}
-
+
/**
* Returns the {@link TableQueryConfig} for the given table
+ *
* @param implementingClass
* the class whose name will be used as a prefix for the property configuration key
* @param conf
@@ -550,7 +553,7 @@ public class InputConfigurator extends ConfiguratorBase {
}
return null;
}
-
+
/**
* Initializes an Accumulo {@link TabletLocator} based on the configuration.
*
@@ -572,7 +575,7 @@ public class InputConfigurator extends ConfiguratorBase {
Instance instance = getInstance(implementingClass, conf);
return TabletLocator.getLocator(instance, new Text(Tables.getTableId(instance, tableName)));
}
-
+
// InputFormat doesn't have the equivalent of OutputFormat's checkOutputSpecs(JobContext job)
/**
* Check whether a configuration is fully configured to be used with an Accumulo {@link org.apache.hadoop.mapreduce.InputFormat}.
@@ -598,19 +601,19 @@ public class InputConfigurator extends ConfiguratorBase {
Connector c = getInstance(implementingClass, conf).getConnector(principal, token);
if (!c.securityOperations().authenticateUser(principal, token))
throw new IOException("Unable to authenticate user");
-
+
for (TableQueryConfig tableConfig : getTableQueryConfigs(implementingClass, conf)) {
if (!c.securityOperations().hasTablePermission(getPrincipal(implementingClass, conf), tableConfig.getTableName(), TablePermission.READ))
throw new IOException("Unable to access table");
}
-
+
for (TableQueryConfig tableConfig : getTableQueryConfigs(implementingClass, conf)) {
if (!tableConfig.shouldUseLocalIterators()) {
if (tableConfig.getIterators() != null) {
for (IteratorSetting iter : tableConfig.getIterators()) {
if (!c.tableOperations().testClassLoad(tableConfig.getTableName(), iter.getIteratorClass(), SortedKeyValueIterator.class.getName()))
throw new AccumuloException("Servers are unable to load " + iter.getIteratorClass() + " as a " + SortedKeyValueIterator.class.getName());
-
+
}
}
}
@@ -623,7 +626,7 @@ public class InputConfigurator extends ConfiguratorBase {
throw new IOException(e);
}
}
-
+
/**
* Returns the {@link TableQueryConfig} for the configuration based on the properties set using the single-table input methods.
*
@@ -647,10 +650,9 @@ public class InputConfigurator extends ConfiguratorBase {
List<Range> ranges = getRanges(implementingClass, conf);
if (ranges != null)
queryConfig.setRanges(ranges);
-
- queryConfig.setAutoAdjustRanges(getAutoAdjustRanges(implementingClass, conf)).setUseIsolatedScanners( isIsolated
- ( implementingClass,conf ) )
- .setUseLocalIterators( usesLocalIterators( implementingClass,conf ) ).setOfflineScan( isOfflineScan( implementingClass,conf ) );
+
+ queryConfig.setAutoAdjustRanges(getAutoAdjustRanges(implementingClass, conf)).setUseIsolatedScanners(isIsolated(implementingClass, conf))
+ .setUseLocalIterators(usesLocalIterators(implementingClass, conf)).setOfflineScan(isOfflineScan(implementingClass, conf));
return queryConfig;
}
return null;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6648e8a1/core/src/main/java/org/apache/accumulo/core/conf/TableQueryConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/TableQueryConfig.java b/core/src/main/java/org/apache/accumulo/core/conf/TableQueryConfig.java
index d6476da..26feca3 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/TableQueryConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/TableQueryConfig.java
@@ -1,3 +1,19 @@
+/*
+ * 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.conf;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -9,7 +25,6 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.TreeSet;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.Range;
@@ -33,78 +48,78 @@ public class TableQueryConfig implements Writable {
checkNotNull(tableName);
this.tableName = tableName;
}
-
- public TableQueryConfig(DataInput input) throws IOException{
+
+ public TableQueryConfig(DataInput input) throws IOException {
readFields(input);
}
-
+
public TableQueryConfig setRanges(List<Range> ranges) {
this.ranges = ranges;
return this;
}
-
+
public TableQueryConfig setColumns(Set<Pair<Text,Text>> columns) {
this.columns = columns;
return this;
}
-
+
public TableQueryConfig setIterators(List<IteratorSetting> iterators) {
this.iterators = iterators;
return this;
}
-
- public TableQueryConfig setAutoAdjustRanges(boolean autoAdjustRanges){
- this.autoAdjustRanges=autoAdjustRanges;
+
+ public TableQueryConfig setAutoAdjustRanges(boolean autoAdjustRanges) {
+ this.autoAdjustRanges = autoAdjustRanges;
return this;
}
-
- public TableQueryConfig setUseLocalIterators(boolean useLocalIterators){
- this.useLocalIterators=useLocalIterators;
+
+ public TableQueryConfig setUseLocalIterators(boolean useLocalIterators) {
+ this.useLocalIterators = useLocalIterators;
return this;
}
-
- public TableQueryConfig setUseIsolatedScanners(boolean useIsolatedScanners){
- this.useIsolatedScanners=useIsolatedScanners;
+
+ public TableQueryConfig setUseIsolatedScanners(boolean useIsolatedScanners) {
+ this.useIsolatedScanners = useIsolatedScanners;
return this;
}
-
- public boolean isOfflineScan(){
+
+ public boolean isOfflineScan() {
return offlineScan;
}
-
- public TableQueryConfig setOfflineScan(boolean offlineScan){
- this.offlineScan=offlineScan;
+
+ public TableQueryConfig setOfflineScan(boolean offlineScan) {
+ this.offlineScan = offlineScan;
return this;
}
-
- public String getTableName(){
+
+ public String getTableName() {
return tableName;
}
-
- public List<IteratorSetting> getIterators(){
+
+ public List<IteratorSetting> getIterators() {
return iterators != null ? iterators : new ArrayList<IteratorSetting>();
}
-
- public List<Range> getRanges(){
+
+ public List<Range> getRanges() {
return ranges != null ? ranges : new ArrayList<Range>();
}
-
- public Set<Pair<Text,Text>> getColumns(){
+
+ public Set<Pair<Text,Text>> getColumns() {
return columns != null ? columns : new HashSet<Pair<Text,Text>>();
}
-
- public boolean shouldAutoAdjustRanges(){
+
+ public boolean shouldAutoAdjustRanges() {
return autoAdjustRanges;
}
-
- public boolean shouldUseLocalIterators(){
+
+ public boolean shouldUseLocalIterators() {
return useLocalIterators;
}
-
- public boolean shouldUseIsolatedScanners(){
+
+ public boolean shouldUseIsolatedScanners() {
return useIsolatedScanners;
}
-
+
@Override
public void write(DataOutput dataOutput) throws IOException {
dataOutput.writeUTF(tableName);
@@ -180,36 +195,46 @@ public class TableQueryConfig implements Writable {
useLocalIterators = dataInput.readBoolean();
useIsolatedScanners = dataInput.readBoolean();
}
-
+
@Override
- public boolean equals(Object o){
- if(this==o) return true;
- if(o==null||getClass()!=o.getClass()) return false;
-
- TableQueryConfig that=(TableQueryConfig)o;
-
- if(autoAdjustRanges!=that.autoAdjustRanges) return false;
- if(offlineScan!=that.offlineScan) return false;
- if(useIsolatedScanners!=that.useIsolatedScanners) return false;
- if(useLocalIterators!=that.useLocalIterators) return false;
- if(columns!=null?!columns.equals(that.columns):that.columns!=null) return false;
- if(iterators!=null?!iterators.equals(that.iterators):that.iterators!=null) return false;
- if(ranges!=null?!ranges.equals(that.ranges):that.ranges!=null) return false;
- if(tableName!=null?!tableName.equals(that.tableName):that.tableName!=null) return false;
-
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ TableQueryConfig that = (TableQueryConfig) o;
+
+ if (autoAdjustRanges != that.autoAdjustRanges)
+ return false;
+ if (offlineScan != that.offlineScan)
+ return false;
+ if (useIsolatedScanners != that.useIsolatedScanners)
+ return false;
+ if (useLocalIterators != that.useLocalIterators)
+ return false;
+ if (columns != null ? !columns.equals(that.columns) : that.columns != null)
+ return false;
+ if (iterators != null ? !iterators.equals(that.iterators) : that.iterators != null)
+ return false;
+ if (ranges != null ? !ranges.equals(that.ranges) : that.ranges != null)
+ return false;
+ if (tableName != null ? !tableName.equals(that.tableName) : that.tableName != null)
+ return false;
+
return true;
}
-
+
@Override
- public int hashCode(){
- int result=tableName!=null?tableName.hashCode():0;
- result=31*result+(iterators!=null?iterators.hashCode():0);
- result=31*result+(ranges!=null?ranges.hashCode():0);
- result=31*result+(columns!=null?columns.hashCode():0);
- result=31*result+(autoAdjustRanges?1:0);
- result=31*result+(useLocalIterators?1:0);
- result=31*result+(useIsolatedScanners?1:0);
- result=31*result+(offlineScan?1:0);
+ public int hashCode() {
+ int result = tableName != null ? tableName.hashCode() : 0;
+ result = 31 * result + (iterators != null ? iterators.hashCode() : 0);
+ result = 31 * result + (ranges != null ? ranges.hashCode() : 0);
+ result = 31 * result + (columns != null ? columns.hashCode() : 0);
+ result = 31 * result + (autoAdjustRanges ? 1 : 0);
+ result = 31 * result + (useLocalIterators ? 1 : 0);
+ result = 31 * result + (useIsolatedScanners ? 1 : 0);
+ result = 31 * result + (offlineScan ? 1 : 0);
return result;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6648e8a1/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
index c5361b9..e7603c4 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java
@@ -301,44 +301,50 @@ public class AccumuloInputFormatTest {
assertNull(e2);
}
+ /**
+ * Verify {@link TableQueryConfig} objects get correctly serialized in the JobContext.
+ */
@Test
public void testTableQueryConfigSerialization() throws IOException {
Job job = new Job();
- TableQueryConfig table1 = new TableQueryConfig(TEST_TABLE_1).setRanges(Collections.singletonList(new Range("a","b")))
- .setColumns(Collections.singleton(new Pair<Text, Text>(new Text("CF1"),new Text("CQ1"))))
- .setIterators(Collections.singletonList(new IteratorSetting(50,"iter1","iterclass1")));
+ TableQueryConfig table1 = new TableQueryConfig(TEST_TABLE_1).setRanges(Collections.singletonList(new Range("a", "b")))
+ .setColumns(Collections.singleton(new Pair<Text,Text>(new Text("CF1"), new Text("CQ1"))))
+ .setIterators(Collections.singletonList(new IteratorSetting(50, "iter1", "iterclass1")));
- TableQueryConfig table2 = new TableQueryConfig(TEST_TABLE_2).setRanges(Collections.singletonList(new Range("a","b")))
- .setColumns(Collections.singleton(new Pair<Text, Text>(new Text("CF1"),new Text("CQ1"))))
- .setIterators(Collections.singletonList(new IteratorSetting(50,"iter1","iterclass1")));
+ TableQueryConfig table2 = new TableQueryConfig(TEST_TABLE_2).setRanges(Collections.singletonList(new Range("a", "b")))
+ .setColumns(Collections.singleton(new Pair<Text,Text>(new Text("CF1"), new Text("CQ1"))))
+ .setIterators(Collections.singletonList(new IteratorSetting(50, "iter1", "iterclass1")));
AccumuloInputFormat.setTableQueryConfigs(job, table1, table2);
assertEquals(table1, AccumuloInputFormat.getTableQueryConfig(job, TEST_TABLE_1));
assertEquals(table2, AccumuloInputFormat.getTableQueryConfig(job, TEST_TABLE_2));
}
-
+
+ /**
+ * Verify that union of legacy input and new multi-table input get returned for backwards compatibility.
+ */
@Test
- public void testTableQueryConfigBackwardsCompatibility() throws IOException {
-
+ public void testTableQueryConfigSingleAndMultitableMethods() throws IOException {
+
Job job = new Job();
-
- TableQueryConfig table1 = new TableQueryConfig(TEST_TABLE_1).setRanges(Collections.singletonList(new Range("a","b")))
- .setColumns(Collections.singleton(new Pair<Text, Text>(new Text("CF1"),new Text("CQ1"))))
- .setIterators(Collections.singletonList(new IteratorSetting(50,"iter1","iterclass1")));
-
- TableQueryConfig table2 = new TableQueryConfig(TEST_TABLE_2).setRanges(Collections.singletonList(new Range("a","b")))
- .setColumns(Collections.singleton(new Pair<Text, Text>(new Text("CF1"),new Text("CQ1"))))
- .setIterators(Collections.singletonList(new IteratorSetting(50,"iter1","iterclass1")));
-
+
+ TableQueryConfig table1 = new TableQueryConfig(TEST_TABLE_1).setRanges(Collections.singletonList(new Range("a", "b")))
+ .setColumns(Collections.singleton(new Pair<Text,Text>(new Text("CF1"), new Text("CQ1"))))
+ .setIterators(Collections.singletonList(new IteratorSetting(50, "iter1", "iterclass1")));
+
+ TableQueryConfig table2 = new TableQueryConfig(TEST_TABLE_2).setRanges(Collections.singletonList(new Range("a", "b")))
+ .setColumns(Collections.singleton(new Pair<Text,Text>(new Text("CF1"), new Text("CQ1"))))
+ .setIterators(Collections.singletonList(new IteratorSetting(50, "iter1", "iterclass1")));
+
AccumuloInputFormat.setTableQueryConfigs(job, table1);
AccumuloInputFormat.setInputTableName(job, table2.getTableName());
AccumuloInputFormat.setRanges(job, table2.getRanges());
AccumuloInputFormat.fetchColumns(job, table2.getColumns());
AccumuloInputFormat.addIterator(job, table2.getIterators().get(0));
-
+
assertEquals(table1, AccumuloInputFormat.getTableQueryConfig(job, TEST_TABLE_1));
assertEquals(table2, AccumuloInputFormat.getTableQueryConfig(job, TEST_TABLE_2));
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6648e8a1/core/src/test/java/org/apache/accumulo/core/conf/TableQueryConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/TableQueryConfigTest.java b/core/src/test/java/org/apache/accumulo/core/conf/TableQueryConfigTest.java
index d3fbd3c..3c26a07 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/TableQueryConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/TableQueryConfigTest.java
@@ -72,17 +72,16 @@ public class TableQueryConfigTest {
byte[] serialized = serialize(tableQueryConfig);
TableQueryConfig actualConfig = deserialize(serialized);
assertEquals(actualConfig.getIterators(), settings);
-
+
}
private byte[] serialize(TableQueryConfig tableQueryConfig) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
tableQueryConfig.write(new DataOutputStream(baos));
baos.close();
-
return baos.toByteArray();
}
-
+
private TableQueryConfig deserialize(byte[] bytes) throws IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
TableQueryConfig actualConfig = new TableQueryConfig(new DataInputStream(bais));