asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: reduce code duplication a tiny bit
Date Tue, 13 Dec 2016 02:53:58 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 8216bd88a -> d6181c1e8


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>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/d6181c1e
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/d6181c1e
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/d6181c1e

Branch: refs/heads/master
Commit: d6181c1e8ee7d074346dab807250a01895065620
Parents: 8216bd8
Author: Till Westmann <tillw@apache.org>
Authored: Sat Dec 10 17:47:57 2016 -0800
Committer: Michael Blow <mblow@apache.org>
Committed: Mon Dec 12 18:53:31 2016 -0800

----------------------------------------------------------------------
 .../metadata/declared/DatasetDataSource.java    | 32 +++++++++-----------
 1 file changed, 14 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d6181c1e/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/DatasetDataSource.java
----------------------------------------------------------------------
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 @@ public class DatasetDataSource extends DataSource {
                 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 @@ public class DatasetDataSource extends DataSource {
         }
     }
 
+    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;


Mime
View raw message