asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wangs...@apache.org
Subject incubator-asterixdb git commit: ASTERIXDB-1115 fixed: Incorrect comparators are given for a secondary btree index when AsterixDB instance with a preloaded/inserted data stop/starts and sends a query without having any dml operation
Date Mon, 28 Sep 2015 18:28:09 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 6b65eb536 -> af95e4117


ASTERIXDB-1115 fixed: Incorrect comparators are given for a secondary btree index when AsterixDB
instance with a preloaded/inserted data stop/starts and sends a query without having any dml
operation

Note: this fix is created by Young-Seok Kim and submitted by Taewoo Kim on behalf of him.

Change-Id: I648d808b77910582a6b52a0e730d7271f9d2c213
Reviewed-on: https://asterix-gerrit.ics.uci.edu/412
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Taewoo Kim <wangsaeu@gmail.com>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Reviewed-by: Pouria Pirzadeh <pouria.pirzadeh@gmail.com>


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

Branch: refs/heads/master
Commit: af95e4117d39a335bf9c3860eac6d75827766ff8
Parents: 6b65eb5
Author: Taewoo Kim <wangsaeu@yahoo.com>
Authored: Sun Sep 27 10:10:56 2015 -0700
Committer: Pouria Pirzadeh <pouria.pirzadeh@gmail.com>
Committed: Mon Sep 28 09:15:53 2015 -0700

----------------------------------------------------------------------
 .../metadata/declared/AqlMetadataProvider.java  | 47 +++++++++++++++++---
 1 file changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/af95e411/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
----------------------------------------------------------------------
diff --git a/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
b/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
index d68a159..2478dc7 100644
--- a/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
@@ -584,7 +584,7 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId,
Strin
                         iterator.remove();
                     }
                 }
-                // TODO Check this call, result of merge from master! 
+                // TODO Check this call, result of merge from master!
                 //  ((IGenericAdapterFactory) adapterFactory).setFiles(files);
             }
 
@@ -706,10 +706,11 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId,
Strin
                 for (int i = 0; i < numSecondaryKeys; i++) {
                     bloomFilterKeyFields[i] = i;
                 }
-                typeTraits = JobGenHelper.variablesToTypeTraits(outputVars, 0, outputVars.size(),
typeEnv, context);
-                comparatorFactories = JobGenHelper.variablesToAscBinaryComparatorFactories(outputVars,
0,
-                        outputVars.size(), typeEnv, context);
-
+                Pair<IBinaryComparatorFactory[], ITypeTraits[]> comparatorFactoriesAndTypeTraits
= getComparatorFactoriesAndTypeTraitsOfSecondaryBTreeIndex(
+                        secondaryIndex.getIndexType(), secondaryIndex.getKeyFieldNames(),
+                        secondaryIndex.getKeyFieldTypes(), DatasetUtils.getPartitioningKeys(dataset),
itemType);
+                comparatorFactories = comparatorFactoriesAndTypeTraits.first;
+                typeTraits = comparatorFactoriesAndTypeTraits.second;
                 if (filterTypeTraits != null) {
                     filterFields = new int[1];
                     filterFields[0] = numSecondaryKeys + numPrimaryKeys;
@@ -807,6 +808,42 @@ public class AqlMetadataProvider implements IMetadataProvider<AqlSourceId,
Strin
         }
     }
 
+    private Pair<IBinaryComparatorFactory[], ITypeTraits[]> getComparatorFactoriesAndTypeTraitsOfSecondaryBTreeIndex(
+            IndexType indexType, List<List<String>> sidxKeyFieldNames, List<IAType>
sidxKeyFieldTypes,
+            List<List<String>> pidxKeyFieldNames, ARecordType recType) throws
AlgebricksException {
+
+        IBinaryComparatorFactory[] comparatorFactories;
+        ITypeTraits[] typeTraits;
+        int sidxKeyFieldCount = sidxKeyFieldNames.size();
+        int pidxKeyFieldCount = pidxKeyFieldNames.size();
+        typeTraits = new ITypeTraits[sidxKeyFieldCount + pidxKeyFieldCount];
+        comparatorFactories = new IBinaryComparatorFactory[sidxKeyFieldCount + pidxKeyFieldCount];
+
+        int i = 0;
+        for (; i < sidxKeyFieldCount; ++i) {
+            Pair<IAType, Boolean> keyPairType = Index.getNonNullableOpenFieldType(sidxKeyFieldTypes.get(i),
+                    sidxKeyFieldNames.get(i), recType);
+            IAType keyType = keyPairType.first;
+            comparatorFactories[i] = AqlBinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(keyType,
+                    true);
+            typeTraits[i] = AqlTypeTraitProvider.INSTANCE.getTypeTrait(keyType);
+        }
+
+        for (int j = 0; j < pidxKeyFieldCount; ++j, ++i) {
+            IAType keyType = null;
+            try {
+                keyType = recType.getSubFieldType(pidxKeyFieldNames.get(j));
+            } catch (IOException e) {
+                throw new AlgebricksException(e);
+            }
+            comparatorFactories[i] = AqlBinaryComparatorFactoryProvider.INSTANCE.getBinaryComparatorFactory(keyType,
+                    true);
+            typeTraits[i] = AqlTypeTraitProvider.INSTANCE.getTypeTrait(keyType);
+        }
+
+        return new Pair<IBinaryComparatorFactory[], ITypeTraits[]>(comparatorFactories,
typeTraits);
+    }
+
     public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> buildRtreeRuntime(JobSpecification
jobSpec,
             List<LogicalVariable> outputVars, IOperatorSchema opSchema, IVariableTypeEnvironment
typeEnv,
             JobGenContext context, boolean retainInput, boolean retainNull, Dataset dataset,
String indexName,


Mime
View raw message