reduce code duplication a tiny bit
Change-Id: I3f3bf5fb423cd55bd7fc168ac7a9014a24bc516c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1365
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/DatasetDataSource.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/DatasetDataSource.java
index 6a13979..973651f 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/DatasetDataSource.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/DatasetDataSource.java
@@ -116,24 +116,8 @@
Index primaryIndex = MetadataManager.INSTANCE.getIndex(metadataProvider.getMetadataTxnContext(),
dataverseName, datasetName, datasetName);
- int[] minFilterFieldIndexes = null;
- if (minFilterVars != null && !minFilterVars.isEmpty()) {
- minFilterFieldIndexes = new int[minFilterVars.size()];
- int i = 0;
- for (LogicalVariable v : minFilterVars) {
- minFilterFieldIndexes[i] = opSchema.findVariable(v);
- i++;
- }
- }
- int[] maxFilterFieldIndexes = null;
- if (maxFilterVars != null && !maxFilterVars.isEmpty()) {
- maxFilterFieldIndexes = new int[maxFilterVars.size()];
- int i = 0;
- for (LogicalVariable v : maxFilterVars) {
- maxFilterFieldIndexes[i] = opSchema.findVariable(v);
- i++;
- }
- }
+ int[] minFilterFieldIndexes = createFilterIndexes(minFilterVars, opSchema);
+ int[] maxFilterFieldIndexes = createFilterIndexes(maxFilterVars, opSchema);
return metadataProvider.buildBtreeRuntime(jobSpec, scanVariables, opSchema, typeEnv, context, true,
false, ((DatasetDataSource) dataSource).getDataset(), primaryIndex.getIndexName(), null, null,
true, true, implConfig, minFilterFieldIndexes, maxFilterFieldIndexes);
@@ -142,6 +126,18 @@
}
}
+ private int[] createFilterIndexes(List<LogicalVariable> filterVars, IOperatorSchema opSchema) {
+ if (filterVars != null && !filterVars.isEmpty()) {
+ final int size = filterVars.size();
+ int[] result = new int[size];
+ for (int i = 0; i < size; ++i) {
+ result[i] = opSchema.findVariable(filterVars.get(i));
+ }
+ return result;
+ }
+ return null;
+ }
+
@Override
public boolean isScanAccessPathALeaf() {
return dataset.getDatasetType() == DatasetType.EXTERNAL;