Repository: asterixdb Updated Branches: refs/heads/master d8b5972ec -> c4eb65649
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4eb6564/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java index 3d7e959..7eae931 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/OptimizableOperatorSubTree.java @@ -21,6 +21,8 @@ package org.apache.asterix.optimizer.rules.am; import java.util.ArrayList; import java.util.List; +import org.apache.asterix.common.exceptions.CompilationException; +import org.apache.asterix.common.exceptions.ErrorCode; import org.apache.asterix.metadata.declared.DataSource; import org.apache.asterix.metadata.declared.MetadataProvider; import org.apache.asterix.metadata.entities.Dataset; @@ -43,6 +45,7 @@ import org.apache.hyracks.algebricks.core.algebra.metadata.IDataSource; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator.ExecutionMode; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractScanOperator; +import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractUnnestMapOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractUnnestOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestMapOperator; @@ -81,7 +84,8 @@ public class OptimizableOperatorSubTree { private List<Dataset> ixJoinOuterAdditionalDatasets = null; private List<ARecordType> ixJoinOuterAdditionalRecordTypes = null; - public boolean initFromSubTree(Mutable<ILogicalOperator> subTreeOpRef) throws AlgebricksException { + public boolean initFromSubTree(Mutable<ILogicalOperator> subTreeOpRef) + throws AlgebricksException { reset(); rootRef = subTreeOpRef; root = subTreeOpRef.getValue(); @@ -96,7 +100,7 @@ public class OptimizableOperatorSubTree { searchOpRef = subTreeOp.getInputs().get(0); subTreeOp = (AbstractLogicalOperator) searchOpRef.getValue(); } - // Check primary-index pattern. + // Match datasource information if there are no (assign | unnest)* if (subTreeOp.getOperatorTag() != LogicalOperatorTag.ASSIGN && subTreeOp.getOperatorTag() != LogicalOperatorTag.UNNEST) { // Pattern may still match if we are looking for primary index matches as well. @@ -283,7 +287,7 @@ public class OptimizableOperatorSubTree { // Find the dataset corresponding to the datasource in the metadata. ds = metadataProvider.findDataset(dataverseName, datasetName); if (ds == null) { - throw new AlgebricksException("No metadata for dataset " + datasetName); + throw CompilationException.create(ErrorCode.NO_METADATA_FOR_DATASET, datasetName); } // Get the record type for that dataset. IAType itemType = metadataProvider.findType(ds.getItemTypeDataverseName(), ds.getItemTypeName()); @@ -367,8 +371,14 @@ public class OptimizableOperatorSubTree { setIxJoinOuterAdditionalRecordTypes(null); } - public void getPrimaryKeyVars(List<LogicalVariable> target) throws AlgebricksException { - switch (getDataSourceType()) { + /** + * Get primary key variables from the given data-source. + */ + public void getPrimaryKeyVars(Mutable<ILogicalOperator> dataSourceRefToFetch, List<LogicalVariable> target) + throws AlgebricksException { + Mutable<ILogicalOperator> dataSourceRefToFetchKey = (dataSourceRefToFetch == null) ? dataSourceRef + : dataSourceRefToFetch; + switch (dataSourceType) { case DATASOURCE_SCAN: DataSourceScanOperator dataSourceScan = (DataSourceScanOperator) getDataSourceRef().getValue(); int numPrimaryKeys = DatasetUtil.getPartitioningKeys(getDataset()).size(); @@ -377,17 +387,19 @@ public class OptimizableOperatorSubTree { } break; case PRIMARY_INDEX_LOOKUP: - UnnestMapOperator unnestMapOp = (UnnestMapOperator) getDataSourceRef().getValue(); + AbstractUnnestMapOperator unnestMapOp = (AbstractUnnestMapOperator) dataSourceRefToFetchKey.getValue(); List<LogicalVariable> primaryKeys = null; - primaryKeys = AccessMethodUtils.getPrimaryKeyVarsFromPrimaryUnnestMap(getDataset(), unnestMapOp); + primaryKeys = AccessMethodUtils.getPrimaryKeyVarsFromPrimaryUnnestMap(dataset, unnestMapOp); target.addAll(primaryKeys); break; + case EXTERNAL_SCAN: + break; case NO_DATASOURCE: default: - throw new AlgebricksException("The subtree does not have any data source."); + throw CompilationException.create(ErrorCode.SUBTREE_HAS_NO_DATA_SOURCE); + } } - public List<LogicalVariable> getDataSourceVariables() throws AlgebricksException { switch (getDataSourceType()) { case DATASOURCE_SCAN: @@ -399,7 +411,7 @@ public class OptimizableOperatorSubTree { return new ArrayList<>(); case NO_DATASOURCE: default: - throw new AlgebricksException("The subtree does not have any data source."); + throw CompilationException.create(ErrorCode.SUBTREE_HAS_NO_DATA_SOURCE); } } @@ -416,7 +428,7 @@ public class OptimizableOperatorSubTree { return new ArrayList<>(); case NO_DATASOURCE: default: - throw new AlgebricksException("The subtree does not have any additional data sources."); + throw CompilationException.create(ErrorCode.SUBTREE_HAS_NO_ADDTIONAL_DATA_SOURCE); } } else { return null; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4eb6564/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java index 44a53e1..fe2827e 100644 --- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java +++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/RTreeAccessMethod.java @@ -73,13 +73,13 @@ public class RTreeAccessMethod implements IAccessMethod { } @Override - public boolean analyzeFuncExprArgs(AbstractFunctionCallExpression funcExpr, + public boolean analyzeFuncExprArgsAndUpdateAnalysisCtx(AbstractFunctionCallExpression funcExpr, List<AbstractLogicalOperator> assignsAndUnnests, AccessMethodAnalysisContext analysisCtx, IOptimizationContext context, IVariableTypeEnvironment typeEnvironment) throws AlgebricksException { - boolean matches = AccessMethodUtils.analyzeFuncExprArgsForOneConstAndVar(funcExpr, analysisCtx, context, - typeEnvironment); + boolean matches = AccessMethodUtils.analyzeFuncExprArgsForOneConstAndVarAndUpdateAnalysisCtx(funcExpr, + analysisCtx, context, typeEnvironment); if (!matches) { - matches = AccessMethodUtils.analyzeFuncExprArgsForTwoVars(funcExpr, analysisCtx); + matches = AccessMethodUtils.analyzeFuncExprArgsForTwoVarsAndUpdateAnalysisCtx(funcExpr, analysisCtx); } return matches; } @@ -127,7 +127,7 @@ public class RTreeAccessMethod implements IAccessMethod { boolean hasGroupBy) throws AlgebricksException { // Determine if the index is applicable on the left or right side (if both, we arbitrarily prefer the left // side). - Dataset dataset = analysisCtx.indexDatasetMap.get(chosenIndex); + Dataset dataset = analysisCtx.getDatasetFromIndexDatasetMap(chosenIndex); OptimizableOperatorSubTree indexSubTree; OptimizableOperatorSubTree probeSubTree; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4eb6564/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java index ad9b4af..28fd3d2 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java @@ -86,6 +86,14 @@ public class ErrorCode { public static final int COMPILATION_FUNC_EXPRESSION_CANNOT_UTILIZE_INDEX = 1026; public static final int COMPILATION_DATASET_TYPE_DOES_NOT_HAVE_PRIMARY_INDEX = 1027; public static final int COMPILATION_UNSUPPORTED_QUERY_PARAMETER = 1028; + public static final int NO_METADATA_FOR_DATASET = 1029; + public static final int SUBTREE_HAS_NO_DATA_SOURCE = 1030; + public static final int SUBTREE_HAS_NO_ADDTIONAL_DATA_SOURCE = 1031; + public static final int NO_INDEX_FIELD_NAME_FOR_GIVEN_FUNC_EXPR = 1032; + public static final int NO_SUPPORTED_TYPE = 1033; + public static final int NO_TOKENIZER_FOR_TYPE = 1034; + public static final int INCOMPATIBLE_SEARCH_MODIFIER = 1035; + public static final int UNKNOWN_SEARCH_MODIFIER = 1036; // Feed errors public static final int DATAFLOW_ILLEGAL_STATE = 3001; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4eb6564/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties index 7e439dd..80a7981 100644 --- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties +++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties @@ -72,6 +72,14 @@ 1026 = The given function expression %1$s cannot utilize index 1027 = Dataset of type %1$s doesn't have a primary index 1028 = Query parameter %1$s is not supported +1029 = No metadata exists for dataset %1$s +1030 = The subtree does not have any data source +1031 = The subtree does not have any additional data source +1032 = Could not match the given optimizable function expression to any index field name +1033 = Only strings, ordered and unordered list types are supported +1034 = Tokenizer is not applicable to the given index kind %1$s +1035 = Incompatible search modifier %1$s for index type %2$s +1036 = Unknown search modifier type %1$s # Feed Errors 3001 = Illegal state. http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c4eb6564/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java index 7a65d80..11b8109 100644 --- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java +++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java @@ -68,7 +68,7 @@ public class ErrorCode { public static final int RESULT_NO_RECORD = 32; // Compilation error codes. - public static final int RULECOLLECTION_NOT_INSTANCE_OF_LIST = 10001; + public static final int RULECOLLECTION_NOT_INSTANCE_OF_LIST = 10000; private static class Holder { private static final Map<Integer, String> errorMessageMap;