You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2016/08/20 06:15:57 UTC
[15/16] asterixdb git commit: Add Asterix Extension Manager
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
index b3e9e09..16ac80d 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
@@ -72,15 +72,15 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
private AqlMetadataProvider metadataProvider;
// Function Identifier sets that retain the original field variable through each function's arguments
- private final ImmutableSet<FunctionIdentifier> funcIDSetThatRetainFieldName = ImmutableSet.of(
- AsterixBuiltinFunctions.WORD_TOKENS, AsterixBuiltinFunctions.GRAM_TOKENS, AsterixBuiltinFunctions.SUBSTRING,
- AsterixBuiltinFunctions.SUBSTRING_BEFORE, AsterixBuiltinFunctions.SUBSTRING_AFTER,
- AsterixBuiltinFunctions.CREATE_POLYGON, AsterixBuiltinFunctions.CREATE_MBR,
- AsterixBuiltinFunctions.CREATE_RECTANGLE, AsterixBuiltinFunctions.CREATE_CIRCLE,
- AsterixBuiltinFunctions.CREATE_LINE, AsterixBuiltinFunctions.CREATE_POINT,
- AsterixBuiltinFunctions.NUMERIC_ADD, AsterixBuiltinFunctions.NUMERIC_SUBTRACT,
- AsterixBuiltinFunctions.NUMERIC_MULTIPLY, AsterixBuiltinFunctions.NUMERIC_DIVIDE,
- AsterixBuiltinFunctions.NUMERIC_MOD);
+ private final ImmutableSet<FunctionIdentifier> funcIDSetThatRetainFieldName =
+ ImmutableSet.of(AsterixBuiltinFunctions.WORD_TOKENS, AsterixBuiltinFunctions.GRAM_TOKENS,
+ AsterixBuiltinFunctions.SUBSTRING, AsterixBuiltinFunctions.SUBSTRING_BEFORE,
+ AsterixBuiltinFunctions.SUBSTRING_AFTER, AsterixBuiltinFunctions.CREATE_POLYGON,
+ AsterixBuiltinFunctions.CREATE_MBR, AsterixBuiltinFunctions.CREATE_RECTANGLE,
+ AsterixBuiltinFunctions.CREATE_CIRCLE, AsterixBuiltinFunctions.CREATE_LINE,
+ AsterixBuiltinFunctions.CREATE_POINT, AsterixBuiltinFunctions.NUMERIC_ADD,
+ AsterixBuiltinFunctions.NUMERIC_SUBTRACT, AsterixBuiltinFunctions.NUMERIC_MULTIPLY,
+ AsterixBuiltinFunctions.NUMERIC_DIVIDE, AsterixBuiltinFunctions.NUMERIC_MOD);
public abstract Map<FunctionIdentifier, List<IAccessMethod>> getAccessMethods();
@@ -145,15 +145,15 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
return list.isEmpty() ? null : list.get(0);
}
- protected List<Pair<IAccessMethod, Index>> chooseAllIndex(
- Map<IAccessMethod, AccessMethodAnalysisContext> analyzedAMs) {
+ protected List<Pair<IAccessMethod, Index>>
+ chooseAllIndex(Map<IAccessMethod, AccessMethodAnalysisContext> analyzedAMs) {
List<Pair<IAccessMethod, Index>> result = new ArrayList<Pair<IAccessMethod, Index>>();
Iterator<Map.Entry<IAccessMethod, AccessMethodAnalysisContext>> amIt = analyzedAMs.entrySet().iterator();
while (amIt.hasNext()) {
Map.Entry<IAccessMethod, AccessMethodAnalysisContext> amEntry = amIt.next();
AccessMethodAnalysisContext analysisCtx = amEntry.getValue();
- Iterator<Map.Entry<Index, List<Pair<Integer, Integer>>>> indexIt = analysisCtx.indexExprsAndVars.entrySet()
- .iterator();
+ Iterator<Map.Entry<Index, List<Pair<Integer, Integer>>>> indexIt =
+ analysisCtx.indexExprsAndVars.entrySet().iterator();
while (indexIt.hasNext()) {
Map.Entry<Index, List<Pair<Integer, Integer>>> indexEntry = indexIt.next();
// To avoid a case where the chosen access method and a chosen
@@ -167,11 +167,11 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
// LENGTH_PARTITIONED_NGRAM_INVIX]
IAccessMethod chosenAccessMethod = amEntry.getKey();
Index chosenIndex = indexEntry.getKey();
- boolean isKeywordOrNgramIndexChosen = chosenIndex
- .getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX
- || chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX
- || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX
- || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX;
+ boolean isKeywordOrNgramIndexChosen =
+ chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_WORD_INVIX
+ || chosenIndex.getIndexType() == IndexType.LENGTH_PARTITIONED_NGRAM_INVIX
+ || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_WORD_INVIX
+ || chosenIndex.getIndexType() == IndexType.SINGLE_PARTITION_NGRAM_INVIX;
if ((chosenAccessMethod == BTreeAccessMethod.INSTANCE && chosenIndex.getIndexType() == IndexType.BTREE)
|| (chosenAccessMethod == RTreeAccessMethod.INSTANCE
@@ -196,8 +196,8 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
*/
public void pruneIndexCandidates(IAccessMethod accessMethod, AccessMethodAnalysisContext analysisCtx,
IOptimizationContext context, IVariableTypeEnvironment typeEnvironment) throws AlgebricksException {
- Iterator<Map.Entry<Index, List<Pair<Integer, Integer>>>> indexExprAndVarIt = analysisCtx.indexExprsAndVars
- .entrySet().iterator();
+ Iterator<Map.Entry<Index, List<Pair<Integer, Integer>>>> indexExprAndVarIt =
+ analysisCtx.indexExprsAndVars.entrySet().iterator();
// Used to keep track of matched expressions (added for prefix search)
int numMatchedKeys = 0;
ArrayList<Integer> matchedExpressions = new ArrayList<Integer>();
@@ -293,8 +293,8 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
// Check if any field name in the optFuncExpr matches.
if (optFuncExpr.findFieldName(keyField) != -1) {
- foundKeyField = typeMatch
- && optFuncExpr.getOperatorSubTree(exprAndVarIdx.second).hasDataSourceScan();
+ foundKeyField =
+ typeMatch && optFuncExpr.getOperatorSubTree(exprAndVarIdx.second).hasDataSourceScan();
if (foundKeyField) {
matchedExpressions.add(exprAndVarIdx.first);
numMatchedKeys++;
@@ -369,8 +369,8 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
continue;
}
AbstractFunctionCallExpression argFuncExpr = (AbstractFunctionCallExpression) argExpr;
- boolean matchFound = analyzeFunctionExpr(argFuncExpr, assignsAndUnnests, analyzedAMs, context,
- typeEnvironment);
+ boolean matchFound =
+ analyzeFunctionExpr(argFuncExpr, assignsAndUnnests, analyzedAMs, context, typeEnvironment);
found = found || matchFound;
}
return found;
@@ -441,14 +441,15 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
// fieldName
for (Index index : datasetIndexes) {
// Need to also verify the index is pending no op
- if (index.getKeyFieldNames().contains(fieldName) && index.getPendingOp() == IMetadataEntity.PENDING_NO_OP) {
+ if (index.getKeyFieldNames().contains(fieldName)
+ && index.getPendingOp() == IMetadataEntity.PENDING_NO_OP) {
indexCandidates.add(index);
if (optFuncExpr.getFieldType(varIdx) == BuiltinType.AMISSING
|| optFuncExpr.getFieldType(varIdx) == BuiltinType.ANY) {
optFuncExpr.setFieldType(varIdx,
index.getKeyFieldTypes().get(index.getKeyFieldNames().indexOf(fieldName)));
}
- analysisCtx.addIndexExpr(matchedSubTree.dataset, index, matchedFuncExprIndex, varIdx);
+ analysisCtx.addIndexExpr(matchedSubTree.getDataset(), index, matchedFuncExprIndex, varIdx);
}
}
// No index candidates for fieldName.
@@ -464,11 +465,11 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
List<Index> datasetIndexes = new ArrayList<Index>();
LogicalVariable datasetMetaVar = null;
LogicalVariable datasetRecordVar = null;
- if (subTree.dataSourceType != DataSourceType.COLLECTION_SCAN) {
- datasetIndexes = metadataProvider.getDatasetIndexes(subTree.dataset.getDataverseName(),
- subTree.dataset.getDatasetName());
+ if (subTree.getDataSourceType() != DataSourceType.COLLECTION_SCAN) {
+ datasetIndexes = metadataProvider.getDatasetIndexes(subTree.getDataset().getDataverseName(),
+ subTree.getDataset().getDatasetName());
List<LogicalVariable> datasetVars = subTree.getDataSourceVariables();
- if (subTree.dataset.hasMetaPart()) {
+ if (subTree.getDataset().hasMetaPart()) {
datasetMetaVar = datasetVars.get(datasetVars.size() - 1);
datasetRecordVar = datasetVars.get(datasetVars.size() - 2);
} else {
@@ -477,9 +478,9 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
}
for (IOptimizableFuncExpr optFuncExpr : analysisCtx.matchedFuncExprs) {
// Try to match variables from optFuncExpr to assigns or unnests.
- for (int assignOrUnnestIndex = 0; assignOrUnnestIndex < subTree.assignsAndUnnests
+ for (int assignOrUnnestIndex = 0; assignOrUnnestIndex < subTree.getAssignsAndUnnests()
.size(); assignOrUnnestIndex++) {
- AbstractLogicalOperator op = subTree.assignsAndUnnests.get(assignOrUnnestIndex);
+ AbstractLogicalOperator op = subTree.getAssignsAndUnnests().get(assignOrUnnestIndex);
if (op.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
analyzeAssignOp((AssignOperator) op, optFuncExpr, subTree, assignOrUnnestIndex, datasetRecordVar,
datasetMetaVar, context, datasetIndexes, optFuncExprIndex, analysisCtx);
@@ -501,7 +502,7 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
if (subTree.hasIxJoinOuterAdditionalDataSource()) {
additionalDsVarList = new ArrayList<LogicalVariable>();
- for (int i = 0; i < subTree.ixJoinOuterAdditionalDataSourceRefs.size(); i++) {
+ for (int i = 0; i < subTree.getIxJoinOuterAdditionalDataSourceRefs().size(); i++) {
additionalDsVarList.addAll(subTree.getIxJoinOuterAdditionalDataSourceVariables(i));
}
@@ -529,18 +530,18 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
// Remember matching subtree.
optFuncExpr.setOptimizableSubTree(funcVarIndex, subTree);
List<String> fieldName = null;
- if (subTree.dataSourceType == DataSourceType.COLLECTION_SCAN) {
+ if (subTree.getDataSourceType() == DataSourceType.COLLECTION_SCAN) {
optFuncExpr.setLogicalExpr(funcVarIndex, new VariableReferenceExpression(var));
} else {
- fieldName = getFieldNameFromSubTree(optFuncExpr, subTree, assignOrUnnestIndex, 0, subTree.recordType,
+ fieldName = getFieldNameFromSubTree(optFuncExpr, subTree, assignOrUnnestIndex, 0, subTree.getRecordType(),
funcVarIndex, optFuncExpr.getFuncExpr().getArguments().get(funcVarIndex).getValue(),
- datasetRecordVar, subTree.metaRecordType, datasetMetaVar);
+ datasetRecordVar, subTree.getMetaRecordType(), datasetMetaVar);
if (fieldName == null) {
return;
}
}
- IAType fieldType = (IAType) context.getOutputTypeEnvironment(unnestOp)
- .getType(optFuncExpr.getLogicalExpr(funcVarIndex));
+ IAType fieldType =
+ (IAType) context.getOutputTypeEnvironment(unnestOp).getType(optFuncExpr.getLogicalExpr(funcVarIndex));
// Set the fieldName in the corresponding matched function
// expression.
optFuncExpr.setFieldName(funcVarIndex, fieldName);
@@ -570,10 +571,11 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
// Remember matching subtree.
optFuncExpr.setOptimizableSubTree(optVarIndex, subTree);
- List<String> fieldName = getFieldNameFromSubTree(optFuncExpr, subTree, assignOrUnnestIndex, varIndex,
- subTree.recordType, optVarIndex,
- optFuncExpr.getFuncExpr().getArguments().get(optVarIndex).getValue(), datasetRecordVar,
- subTree.metaRecordType, datasetMetaVar);
+ List<String> fieldName =
+ getFieldNameFromSubTree(optFuncExpr, subTree, assignOrUnnestIndex, varIndex,
+ subTree.getRecordType(), optVarIndex,
+ optFuncExpr.getFuncExpr().getArguments().get(optVarIndex).getValue(),
+ datasetRecordVar, subTree.getMetaRecordType(), datasetMetaVar);
if (fieldName == null) {
continue;
}
@@ -609,25 +611,27 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
List<List<String>> subTreePKs = null;
if (!fromAdditionalDataSource) {
- subTreePKs = DatasetUtils.getPartitioningKeys(subTree.dataset);
+ subTreePKs = DatasetUtils.getPartitioningKeys(subTree.getDataset());
// Check whether this variable is PK, not a record variable.
if (varIndex <= subTreePKs.size() - 1) {
fieldName = subTreePKs.get(varIndex);
- fieldType = (IAType) context.getOutputTypeEnvironment(subTree.dataSourceRef.getValue())
- .getVarType(var);
+ fieldType =
+ (IAType) context.getOutputTypeEnvironment(
+ subTree.getDataSourceRef().getValue()).getVarType(var);
}
} else {
// Need to check additional dataset one by one
- for (int i = 0; i < subTree.ixJoinOuterAdditionalDatasets.size(); i++) {
- if (subTree.ixJoinOuterAdditionalDatasets.get(i) != null) {
- subTreePKs = DatasetUtils.getPartitioningKeys(subTree.ixJoinOuterAdditionalDatasets.get(i));
+ for (int i = 0; i < subTree.getIxJoinOuterAdditionalDatasets().size(); i++) {
+ if (subTree.getIxJoinOuterAdditionalDatasets().get(i) != null) {
+ subTreePKs = DatasetUtils.getPartitioningKeys(
+ subTree.getIxJoinOuterAdditionalDatasets().get(i));
// Check whether this variable is PK, not a record variable.
if (subTreePKs.contains(var) && varIndex <= subTreePKs.size() - 1) {
fieldName = subTreePKs.get(varIndex);
fieldType = (IAType) context
.getOutputTypeEnvironment(
- subTree.ixJoinOuterAdditionalDataSourceRefs.get(i).getValue())
+ subTree.getIxJoinOuterAdditionalDataSourceRefs().get(i).getValue())
.getVarType(var);
break;
}
@@ -651,7 +655,7 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
private void setTypeTag(IOptimizationContext context, OptimizableOperatorSubTree subTree,
IOptimizableFuncExpr optFuncExpr, int funcVarIndex) throws AlgebricksException {
// Set the typeTag if the type is not null
- IAType type = (IAType) context.getOutputTypeEnvironment(subTree.root)
+ IAType type = (IAType) context.getOutputTypeEnvironment(subTree.getRoot())
.getVarType(optFuncExpr.getLogicalVar(funcVarIndex));
optFuncExpr.setFieldType(funcVarIndex, type);
}
@@ -663,14 +667,15 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
*
* @throws AlgebricksException
*/
- protected List<String> getFieldNameFromSubTree(IOptimizableFuncExpr optFuncExpr, OptimizableOperatorSubTree subTree,
- int opIndex, int assignVarIndex, ARecordType recordType, int funcVarIndex,
- ILogicalExpression parentFuncExpr, LogicalVariable recordVar, ARecordType metaType, LogicalVariable metaVar)
+ protected List<String> getFieldNameFromSubTree(IOptimizableFuncExpr optFuncExpr,
+ OptimizableOperatorSubTree subTree, int opIndex, int assignVarIndex, ARecordType recordType,
+ int funcVarIndex, ILogicalExpression parentFuncExpr, LogicalVariable recordVar,
+ ARecordType metaType, LogicalVariable metaVar)
throws AlgebricksException {
// Get expression corresponding to opVar at varIndex.
AbstractLogicalExpression expr = null;
AbstractFunctionCallExpression childFuncExpr = null;
- AbstractLogicalOperator op = subTree.assignsAndUnnests.get(opIndex);
+ AbstractLogicalOperator op = subTree.getAssignsAndUnnests().get(opIndex);
if (op.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
AssignOperator assignOp = (AssignOperator) op;
expr = (AbstractLogicalExpression) assignOp.getExpressions().get(assignVarIndex).getValue();
@@ -718,8 +723,8 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
return null;
}
ConstantExpression constExpr = (ConstantExpression) nameArg;
- AOrderedList orderedNestedFieldName = (AOrderedList) ((AsterixConstantValue) constExpr.getValue())
- .getObject();
+ AOrderedList orderedNestedFieldName =
+ (AOrderedList) ((AsterixConstantValue) constExpr.getValue()).getObject();
nestedAccessFieldName = new ArrayList<String>();
for (int i = 0; i < orderedNestedFieldName.size(); i++) {
nestedAccessFieldName.add(((AString) orderedNestedFieldName.getItem(i)).getStringValue());
@@ -728,14 +733,14 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
isByName = true;
}
if (isFieldAccess) {
- LogicalVariable sourceVar = ((VariableReferenceExpression) funcExpr.getArguments().get(0).getValue())
- .getVariableReference();
+ LogicalVariable sourceVar =
+ ((VariableReferenceExpression) funcExpr.getArguments().get(0).getValue()).getVariableReference();
optFuncExpr.setLogicalExpr(funcVarIndex, parentFuncExpr);
int[] assignAndExpressionIndexes = null;
//go forward through nested assigns until you find the relevant one
- for (int i = opIndex + 1; i < subTree.assignsAndUnnests.size(); i++) {
- AbstractLogicalOperator subOp = subTree.assignsAndUnnests.get(i);
+ for (int i = opIndex + 1; i < subTree.getAssignsAndUnnests().size(); i++) {
+ AbstractLogicalOperator subOp = subTree.getAssignsAndUnnests().get(i);
List<LogicalVariable> varList;
if (subOp.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
@@ -822,9 +827,9 @@ public abstract class AbstractIntroduceAccessMethodRule implements IAlgebraicRew
LogicalVariable curVar = ((VariableReferenceExpression) argExpr).getVariableReference();
// We look for the assign or unnest operator that produces curVar below
// the current operator
- for (int assignOrUnnestIndex = opIndex + 1; assignOrUnnestIndex < subTree.assignsAndUnnests
+ for (int assignOrUnnestIndex = opIndex + 1; assignOrUnnestIndex < subTree.getAssignsAndUnnests()
.size(); assignOrUnnestIndex++) {
- AbstractLogicalOperator curOp = subTree.assignsAndUnnests.get(assignOrUnnestIndex);
+ AbstractLogicalOperator curOp = subTree.getAssignsAndUnnests().get(assignOrUnnestIndex);
if (curOp.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
AssignOperator assignOp = (AssignOperator) curOp;
List<LogicalVariable> varList = assignOp.getVariables();
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
index 4dc7bf4..eb7d3a4 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
@@ -22,6 +22,7 @@ package org.apache.asterix.optimizer.rules.am;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -80,30 +81,28 @@ public class BTreeAccessMethod implements IAccessMethod {
EQUAL
}
- // TODO: There is some redundancy here, since these are listed in AlgebricksBuiltinFunctions as well.
- private static List<FunctionIdentifier> funcIdents = new ArrayList<FunctionIdentifier>();
+ private static final List<FunctionIdentifier> FUNC_IDENTIFIERS =
+ Collections.unmodifiableList(Arrays.asList(
+ AlgebricksBuiltinFunctions.EQ,
+ AlgebricksBuiltinFunctions.LE,
+ AlgebricksBuiltinFunctions.GE,
+ AlgebricksBuiltinFunctions.LT,
+ AlgebricksBuiltinFunctions.GT));
- static {
- funcIdents.add(AlgebricksBuiltinFunctions.EQ);
- funcIdents.add(AlgebricksBuiltinFunctions.LE);
- funcIdents.add(AlgebricksBuiltinFunctions.GE);
- funcIdents.add(AlgebricksBuiltinFunctions.LT);
- funcIdents.add(AlgebricksBuiltinFunctions.GT);
- }
-
- public static BTreeAccessMethod INSTANCE = new BTreeAccessMethod();
+ public static final BTreeAccessMethod INSTANCE = new BTreeAccessMethod();
@Override
public List<FunctionIdentifier> getOptimizableFunctions() {
- return funcIdents;
+ return FUNC_IDENTIFIERS;
}
@Override
public boolean analyzeFuncExprArgs(AbstractFunctionCallExpression funcExpr,
List<AbstractLogicalOperator> assignsAndUnnests, AccessMethodAnalysisContext analysisCtx,
IOptimizationContext context, IVariableTypeEnvironment typeEnvironment) throws AlgebricksException {
- boolean matches = AccessMethodUtils.analyzeFuncExprArgsForOneConstAndVar(funcExpr, analysisCtx, context,
- typeEnvironment);
+ boolean matches =
+ AccessMethodUtils.analyzeFuncExprArgsForOneConstAndVar(
+ funcExpr, analysisCtx, context, typeEnvironment);
if (!matches) {
matches = AccessMethodUtils.analyzeFuncExprArgsForTwoVars(funcExpr, analysisCtx);
}
@@ -131,8 +130,8 @@ public class BTreeAccessMethod implements IAccessMethod {
if (primaryIndexUnnestOp == null) {
return false;
}
- Mutable<ILogicalOperator> opRef = (subTree.assignsAndUnnestsRefs.isEmpty()) ? null
- : subTree.assignsAndUnnestsRefs.get(0);
+ Mutable<ILogicalOperator> opRef =
+ subTree.getAssignsAndUnnestsRefs().isEmpty() ? null : subTree.getAssignsAndUnnestsRefs().get(0);
ILogicalOperator op = null;
if (opRef != null) {
op = opRef.getValue();
@@ -141,7 +140,7 @@ public class BTreeAccessMethod implements IAccessMethod {
if (conditionRef.getValue() != null) {
select.getInputs().clear();
if (op != null) {
- subTree.dataSourceRef.setValue(primaryIndexUnnestOp);
+ subTree.getDataSourceRef().setValue(primaryIndexUnnestOp);
select.getInputs().add(new MutableObject<ILogicalOperator>(op));
} else {
select.getInputs().add(new MutableObject<ILogicalOperator>(primaryIndexUnnestOp));
@@ -149,7 +148,7 @@ public class BTreeAccessMethod implements IAccessMethod {
} else {
((AbstractLogicalOperator) primaryIndexUnnestOp).setExecutionMode(ExecutionMode.PARTITIONED);
if (op != null) {
- subTree.dataSourceRef.setValue(primaryIndexUnnestOp);
+ subTree.getDataSourceRef().setValue(primaryIndexUnnestOp);
selectRef.setValue(op);
} else {
selectRef.setValue(primaryIndexUnnestOp);
@@ -165,15 +164,16 @@ public class BTreeAccessMethod implements IAccessMethod {
boolean hasGroupBy) throws AlgebricksException {
AbstractBinaryJoinOperator joinOp = (AbstractBinaryJoinOperator) joinRef.getValue();
Mutable<ILogicalExpression> conditionRef = joinOp.getCondition();
- // Determine if the index is applicable on the left or right side (if both, we arbitrarily prefer the left side).
+ // 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);
- OptimizableOperatorSubTree indexSubTree = null;
- OptimizableOperatorSubTree probeSubTree = null;
+ OptimizableOperatorSubTree indexSubTree;
+ OptimizableOperatorSubTree probeSubTree;
// We assume that the left subtree is the outer branch and the right subtree is the inner branch.
// This assumption holds true since we only use an index from the right subtree.
// The following is just a sanity check.
if (rightSubTree.hasDataSourceScan()
- && dataset.getDatasetName().equals(rightSubTree.dataset.getDatasetName())) {
+ && dataset.getDatasetName().equals(rightSubTree.getDataset().getDatasetName())) {
indexSubTree = rightSubTree;
probeSubTree = leftSubTree;
} else {
@@ -199,16 +199,16 @@ public class BTreeAccessMethod implements IAccessMethod {
}
// If there are conditions left, add a new select operator on top.
- indexSubTree.dataSourceRef.setValue(primaryIndexUnnestOp);
+ indexSubTree.getDataSourceRef().setValue(primaryIndexUnnestOp);
if (conditionRef.getValue() != null) {
SelectOperator topSelect = new SelectOperator(conditionRef, isLeftOuterJoin, newNullPlaceHolderVar);
- topSelect.getInputs().add(indexSubTree.rootRef);
+ topSelect.getInputs().add(indexSubTree.getRootRef());
topSelect.setExecutionMode(ExecutionMode.LOCAL);
context.computeAndSetTypeEnvironmentForOperator(topSelect);
// Replace the original join with the new subtree rooted at the select op.
joinRef.setValue(topSelect);
} else {
- joinRef.setValue(indexSubTree.rootRef.getValue());
+ joinRef.setValue(indexSubTree.getRootRef().getValue());
}
return true;
}
@@ -216,19 +216,20 @@ public class BTreeAccessMethod implements IAccessMethod {
@Override
public ILogicalOperator createSecondaryToPrimaryPlan(Mutable<ILogicalExpression> conditionRef,
OptimizableOperatorSubTree indexSubTree, OptimizableOperatorSubTree probeSubTree, Index chosenIndex,
- AccessMethodAnalysisContext analysisCtx, boolean retainInput, boolean retainNull, boolean requiresBroadcast,
- IOptimizationContext context) throws AlgebricksException {
- Dataset dataset = indexSubTree.dataset;
- ARecordType recordType = indexSubTree.recordType;
- ARecordType metaRecordType = indexSubTree.metaRecordType;
+ AccessMethodAnalysisContext analysisCtx, boolean retainInput, boolean retainNull,
+ boolean requiresBroadcast, IOptimizationContext context) throws AlgebricksException {
+ Dataset dataset = indexSubTree.getDataset();
+ ARecordType recordType = indexSubTree.getRecordType();
+ ARecordType metaRecordType = indexSubTree.getMetaRecordType();
// we made sure indexSubTree has datasource scan
- AbstractDataSourceOperator dataSourceOp = (AbstractDataSourceOperator) indexSubTree.dataSourceRef.getValue();
+ AbstractDataSourceOperator dataSourceOp =
+ (AbstractDataSourceOperator) indexSubTree.getDataSourceRef().getValue();
List<Pair<Integer, Integer>> exprAndVarList = analysisCtx.indexExprsAndVars.get(chosenIndex);
List<IOptimizableFuncExpr> matchedFuncExprs = analysisCtx.matchedFuncExprs;
int numSecondaryKeys = analysisCtx.indexNumMatchedKeys.get(chosenIndex);
// List of function expressions that will be replaced by the secondary-index search.
// These func exprs will be removed from the select condition at the very end of this method.
- Set<ILogicalExpression> replacedFuncExprs = new HashSet<ILogicalExpression>();
+ Set<ILogicalExpression> replacedFuncExprs = new HashSet<>();
// Info on high and low keys for the BTree search predicate.
ILogicalExpression[] lowKeyExprs = new ILogicalExpression[numSecondaryKeys];
@@ -240,12 +241,12 @@ public class BTreeAccessMethod implements IAccessMethod {
ILogicalExpression[] constantAtRuntimeExpressions = new ILogicalExpression[numSecondaryKeys];
LogicalVariable[] constAtRuntimeExprVars = new LogicalVariable[numSecondaryKeys];
- // TODO: For now we don't do any sophisticated analysis of the func exprs to come up with "the best" range predicate.
- // If we can't figure out how to integrate a certain funcExpr into the current predicate, we just bail by setting this flag.
+ /* TODO: For now we don't do any sophisticated analysis of the func exprs to come up with "the best" range
+ * predicate. If we can't figure out how to integrate a certain funcExpr into the current predicate,
+ * we just bail by setting this flag.*/
boolean couldntFigureOut = false;
boolean doneWithExprs = false;
boolean isEqCondition = false;
- // TODO: For now don't consider prefix searches.
BitSet setLowKeys = new BitSet(numSecondaryKeys);
BitSet setHighKeys = new BitSet(numSecondaryKeys);
// Go through the func exprs listed as optimizable by the chosen index,
@@ -253,24 +254,22 @@ public class BTreeAccessMethod implements IAccessMethod {
// checks whether a type casting happened from a real (FLOAT, DOUBLE) value to an INT value
// since we have a round issues when dealing with LT(<) OR GT(>) operator.
- boolean realTypeConvertedToIntegerType = false;
+ boolean realTypeConvertedToIntegerType;
for (Pair<Integer, Integer> exprIndex : exprAndVarList) {
// Position of the field of matchedFuncExprs.get(exprIndex) in the chosen index's indexed exprs.
IOptimizableFuncExpr optFuncExpr = matchedFuncExprs.get(exprIndex.first);
int keyPos = indexOf(optFuncExpr.getFieldName(0), chosenIndex.getKeyFieldNames());
- if (keyPos < 0) {
- if (optFuncExpr.getNumLogicalVars() > 1) {
- // If we are optimizing a join, the matching field may be the second field name.
- keyPos = indexOf(optFuncExpr.getFieldName(1), chosenIndex.getKeyFieldNames());
- }
+ if (keyPos < 0 && optFuncExpr.getNumLogicalVars() > 1) {
+ // If we are optimizing a join, the matching field may be the second field name.
+ keyPos = indexOf(optFuncExpr.getFieldName(1), chosenIndex.getKeyFieldNames());
}
if (keyPos < 0) {
throw new AlgebricksException(
"Could not match optimizable function expression to any index field name.");
}
- Pair<ILogicalExpression, Boolean> returnedSearchKeyExpr = AccessMethodUtils.createSearchKeyExpr(optFuncExpr,
- indexSubTree, probeSubTree);
+ Pair<ILogicalExpression, Boolean> returnedSearchKeyExpr =
+ AccessMethodUtils.createSearchKeyExpr(optFuncExpr, indexSubTree, probeSubTree);
ILogicalExpression searchKeyExpr = returnedSearchKeyExpr.first;
if (searchKeyExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
constantAtRuntimeExpressions[keyPos] = searchKeyExpr;
@@ -288,7 +287,7 @@ public class BTreeAccessMethod implements IAccessMethod {
//
// for $emp in dataset empDataset
// where $emp.age > double("2.3") and $emp.age < double("3.3")
- // return $emp.id;
+ // return $emp.id
//
// It should generate a result if there is a tuple that satisfies the condition, which is 3,
// however, it does not generate the desired result since finding candidates
@@ -316,7 +315,8 @@ public class BTreeAccessMethod implements IAccessMethod {
setHighKeys.set(keyPos);
isEqCondition = true;
} else {
- // Has already been set to the identical values. When optimizing join we may encounter the same optimizable expression twice
+ // Has already been set to the identical values.
+ // When optimizing join we may encounter the same optimizable expression twice
// (once from analyzing each side of the join)
if (lowKeyLimits[keyPos] == limit && lowKeyInclusive[keyPos] == true
&& lowKeyExprs[keyPos].equals(searchKeyExpr) && highKeyLimits[keyPos] == limit
@@ -339,7 +339,8 @@ public class BTreeAccessMethod implements IAccessMethod {
highKeyExprs[keyPos] = searchKeyExpr;
highKeyInclusive[keyPos] = false;
} else {
- // Has already been set to the identical values. When optimizing join we may encounter the same optimizable expression twice
+ // Has already been set to the identical values. When optimizing join we may encounter the
+ // same optimizable expression twice
// (once from analyzing each side of the join)
if (highKeyLimits[keyPos] == limit && highKeyInclusive[keyPos] == false
&& highKeyExprs[keyPos].equals(searchKeyExpr)) {
@@ -356,7 +357,8 @@ public class BTreeAccessMethod implements IAccessMethod {
highKeyExprs[keyPos] = searchKeyExpr;
highKeyInclusive[keyPos] = true;
} else {
- // Has already been set to the identical values. When optimizing join we may encounter the same optimizable expression twice
+ // Has already been set to the identical values. When optimizing join we may encounter the
+ // same optimizable expression twice
// (once from analyzing each side of the join)
if (highKeyLimits[keyPos] == limit && highKeyInclusive[keyPos] == true
&& highKeyExprs[keyPos].equals(searchKeyExpr)) {
@@ -373,7 +375,8 @@ public class BTreeAccessMethod implements IAccessMethod {
lowKeyExprs[keyPos] = searchKeyExpr;
lowKeyInclusive[keyPos] = false;
} else {
- // Has already been set to the identical values. When optimizing join we may encounter the same optimizable expression twice
+ // Has already been set to the identical values. When optimizing join we may encounter the
+ // same optimizable expression twice
// (once from analyzing each side of the join)
if (lowKeyLimits[keyPos] == limit && lowKeyInclusive[keyPos] == false
&& lowKeyExprs[keyPos].equals(searchKeyExpr)) {
@@ -390,7 +393,8 @@ public class BTreeAccessMethod implements IAccessMethod {
lowKeyExprs[keyPos] = searchKeyExpr;
lowKeyInclusive[keyPos] = true;
} else {
- // Has already been set to the identical values. When optimizing join we may encounter the same optimizable expression twice
+ // Has already been set to the identical values. When optimizing join we may encounter the
+ // same optimizable expression twice
// (once from analyzing each side of the join)
if (lowKeyLimits[keyPos] == limit && lowKeyInclusive[keyPos] == true
&& lowKeyExprs[keyPos].equals(searchKeyExpr)) {
@@ -417,7 +421,8 @@ public class BTreeAccessMethod implements IAccessMethod {
return null;
}
- // If the select condition contains mixed open/closed intervals on multiple keys, then we make all intervals closed to obtain a superset of answers and leave the original selection in place.
+ // If the select condition contains mixed open/closed intervals on multiple keys, then we make all intervals
+ // closed to obtain a superset of answers and leave the original selection in place.
boolean primaryIndexPostProccessingIsNeeded = false;
for (int i = 1; i < numSecondaryKeys; ++i) {
if (lowKeyInclusive[i] != lowKeyInclusive[0]) {
@@ -450,7 +455,8 @@ public class BTreeAccessMethod implements IAccessMethod {
highKeyInclusive[0] = true;
}
- // Here we generate vars and funcs for assigning the secondary-index keys to be fed into the secondary-index search.
+ // Here we generate vars and funcs for assigning the secondary-index keys to be fed into the secondary-index
+ // search.
// List of variables for the assign.
ArrayList<LogicalVariable> keyVarList = new ArrayList<LogicalVariable>();
// List of variables and expressions for the assign.
@@ -480,7 +486,7 @@ public class BTreeAccessMethod implements IAccessMethod {
inputOp = assignConstantSearchKeys;
} else {
// All index search keys are variables.
- inputOp = probeSubTree.root;
+ inputOp = probeSubTree.getRoot();
}
ILogicalOperator secondaryIndexUnnestOp = AccessMethodUtils.createSecondaryIndexUnnestMap(dataset, recordType,
@@ -494,7 +500,7 @@ public class BTreeAccessMethod implements IAccessMethod {
// External dataset
UnnestMapOperator externalDataAccessOp = AccessMethodUtils.createExternalDataLookupUnnestMap(dataSourceOp,
dataset, recordType, secondaryIndexUnnestOp, context, chosenIndex, retainInput, retainNull);
- indexSubTree.dataSourceRef.setValue(externalDataAccessOp);
+ indexSubTree.getDataSourceRef().setValue(externalDataAccessOp);
return externalDataAccessOp;
} else if (!isPrimaryIndex) {
primaryIndexUnnestOp = AccessMethodUtils.createPrimaryIndexUnnestMap(dataSourceOp, dataset, recordType,
@@ -542,8 +548,8 @@ public class BTreeAccessMethod implements IAccessMethod {
// An index search is expressed as an unnest-map over an
// index-search function.
IFunctionInfo primaryIndexSearch = FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.INDEX_SEARCH);
- UnnestingFunctionCallExpression primaryIndexSearchFunc = new UnnestingFunctionCallExpression(
- primaryIndexSearch, primaryIndexFuncArgs);
+ UnnestingFunctionCallExpression primaryIndexSearchFunc =
+ new UnnestingFunctionCallExpression(primaryIndexSearch, primaryIndexFuncArgs);
primaryIndexSearchFunc.setReturnsUniqueValues(true);
if (!leftOuterUnnestMapRequired) {
primaryIndexUnnestOp = new UnnestMapOperator(scanVariables,
@@ -651,8 +657,8 @@ public class BTreeAccessMethod implements IAccessMethod {
}
private LimitType getLimitType(IOptimizableFuncExpr optFuncExpr, OptimizableOperatorSubTree probeSubTree) {
- ComparisonKind ck = AlgebricksBuiltinFunctions
- .getComparisonType(optFuncExpr.getFuncExpr().getFunctionIdentifier());
+ ComparisonKind ck =
+ AlgebricksBuiltinFunctions.getComparisonType(optFuncExpr.getFuncExpr().getFunctionIdentifier());
LimitType limit = null;
switch (ck) {
case EQ: {
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
index e1cda09..ff4d219 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
@@ -108,11 +108,11 @@ public class IntroduceJoinAccessMethodRule extends AbstractIntroduceAccessMethod
boolean matchInLeftSubTree = false;
boolean matchInRightSubTree = false;
if (leftSubTree.hasDataSource()) {
- matchInLeftSubTree = analyzeCondition(joinCond, leftSubTree.assignsAndUnnests, analyzedAMs, context,
+ matchInLeftSubTree = analyzeCondition(joinCond, leftSubTree.getAssignsAndUnnests(), analyzedAMs, context,
typeEnvironment);
}
if (rightSubTree.hasDataSource()) {
- matchInRightSubTree = analyzeCondition(joinCond, rightSubTree.assignsAndUnnests, analyzedAMs, context,
+ matchInRightSubTree = analyzeCondition(joinCond, rightSubTree.getAssignsAndUnnests(), analyzedAMs, context,
typeEnvironment);
}
if (!matchInLeftSubTree && !matchInRightSubTree) {
@@ -178,8 +178,8 @@ public class IntroduceJoinAccessMethodRule extends AbstractIntroduceAccessMethod
*/
protected void removeIndexCandidatesFromOuterBranch(Map<IAccessMethod, AccessMethodAnalysisContext> analyzedAMs) {
String innerDataset = null;
- if (rightSubTree.dataset != null) {
- innerDataset = rightSubTree.dataset.getDatasetName();
+ if (rightSubTree.getDataset() != null) {
+ innerDataset = rightSubTree.getDataset().getDatasetName();
}
Iterator<Map.Entry<IAccessMethod, AccessMethodAnalysisContext>> amIt = analyzedAMs.entrySet().iterator();
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceLSMComponentFilterRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceLSMComponentFilterRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceLSMComponentFilterRule.java
index 45c5e34..0e54640 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceLSMComponentFilterRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceLSMComponentFilterRule.java
@@ -23,6 +23,7 @@ import java.util.List;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.metadata.declared.AqlDataSource;
+import org.apache.asterix.metadata.declared.AqlDataSource.AqlDataSourceType;
import org.apache.asterix.metadata.declared.AqlMetadataProvider;
import org.apache.asterix.metadata.declared.DatasetDataSource;
import org.apache.asterix.metadata.entities.Dataset;
@@ -102,7 +103,7 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
List<Index> datasetIndexes = ((AqlMetadataProvider) context.getMetadataProvider())
.getDatasetIndexes(dataset.getDataverseName(), dataset.getDatasetName());
- List<IOptimizableFuncExpr> optFuncExprs = new ArrayList<IOptimizableFuncExpr>();
+ List<IOptimizableFuncExpr> optFuncExprs = new ArrayList<>();
for (int i = 0; i < analysisCtx.matchedFuncExprs.size(); i++) {
IOptimizableFuncExpr optFuncExpr = analysisCtx.matchedFuncExprs.get(i);
@@ -123,8 +124,8 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
private AssignOperator createAssignOperator(List<IOptimizableFuncExpr> optFuncExprs,
List<LogicalVariable> minFilterVars, List<LogicalVariable> maxFilterVars, IOptimizationContext context) {
- List<LogicalVariable> assignKeyVarList = new ArrayList<LogicalVariable>();
- List<Mutable<ILogicalExpression>> assignKeyExprList = new ArrayList<Mutable<ILogicalExpression>>();
+ List<LogicalVariable> assignKeyVarList = new ArrayList<>();
+ List<Mutable<ILogicalExpression>> assignKeyExprList = new ArrayList<>();
for (IOptimizableFuncExpr optFuncExpr : optFuncExprs) {
ComparisonKind ck = AlgebricksBuiltinFunctions
@@ -154,15 +155,15 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
DataSourceScanOperator dataSourceScanOp = (DataSourceScanOperator) descendantOp;
AqlDataSource ds = (AqlDataSource) dataSourceScanOp.getDataSource();
if (dataset.getDatasetName().compareTo(((DatasetDataSource) ds).getDataset().getDatasetName()) == 0) {
- List<LogicalVariable> minFilterVars = new ArrayList<LogicalVariable>();
- List<LogicalVariable> maxFilterVars = new ArrayList<LogicalVariable>();
+ List<LogicalVariable> minFilterVars = new ArrayList<>();
+ List<LogicalVariable> maxFilterVars = new ArrayList<>();
AssignOperator assignOp = createAssignOperator(optFuncExprs, minFilterVars, maxFilterVars, context);
dataSourceScanOp.setMinFilterVars(minFilterVars);
dataSourceScanOp.setMaxFilterVars(maxFilterVars);
- List<Mutable<ILogicalExpression>> additionalFilteringExpressions = new ArrayList<Mutable<ILogicalExpression>>();;
+ List<Mutable<ILogicalExpression>> additionalFilteringExpressions = new ArrayList<>();
for (LogicalVariable var : assignOp.getVariables()) {
additionalFilteringExpressions
.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
@@ -186,8 +187,8 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
AccessMethodJobGenParams jobGenParams = new AccessMethodJobGenParams();
jobGenParams.readFromFuncArgs(f.getArguments());
if (dataset.getDatasetName().compareTo(jobGenParams.datasetName) == 0) {
- List<LogicalVariable> minFilterVars = new ArrayList<LogicalVariable>();
- List<LogicalVariable> maxFilterVars = new ArrayList<LogicalVariable>();
+ List<LogicalVariable> minFilterVars = new ArrayList<>();
+ List<LogicalVariable> maxFilterVars = new ArrayList<>();
AssignOperator assignOp = createAssignOperator(optFuncExprs, minFilterVars, maxFilterVars,
context);
@@ -195,7 +196,7 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
unnestMapOp.setMinFilterVars(minFilterVars);
unnestMapOp.setMaxFilterVars(maxFilterVars);
- List<Mutable<ILogicalExpression>> additionalFilteringExpressions = new ArrayList<Mutable<ILogicalExpression>>();;
+ List<Mutable<ILogicalExpression>> additionalFilteringExpressions = new ArrayList<>();
for (LogicalVariable var : assignOp.getVariables()) {
additionalFilteringExpressions
.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
@@ -220,6 +221,9 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
if (descendantOp.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) {
DataSourceScanOperator dataSourceScanOp = (DataSourceScanOperator) descendantOp;
AqlDataSource ds = (AqlDataSource) dataSourceScanOp.getDataSource();
+ if (ds.getDatasourceType() != AqlDataSourceType.INTERNAL_DATASET) {
+ return null;
+ }
return ((DatasetDataSource) ds).getDataset();
} else if (descendantOp.getOperatorTag() == LogicalOperatorTag.UNNEST_MAP) {
UnnestMapOperator unnestMapOp = (UnnestMapOperator) descendantOp;
@@ -227,8 +231,8 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
if (unnestExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) unnestExpr;
FunctionIdentifier fid = f.getFunctionIdentifier();
- String dataverseName = null;
- String datasetName = null;
+ String dataverseName;
+ String datasetName;
if (AsterixBuiltinFunctions.EXTERNAL_LOOKUP.equals(fid)) {
dataverseName = AccessMethodUtils.getStringConstant(f.getArguments().get(0));
datasetName = AccessMethodUtils.getStringConstant(f.getArguments().get(1));
@@ -299,7 +303,7 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
private boolean findMacthedExprFieldName(IOptimizableFuncExpr optFuncExpr, AbstractLogicalOperator op,
Dataset dataset, ARecordType recType, List<Index> datasetIndexes, IOptimizationContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
AbstractLogicalOperator descendantOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
while (descendantOp != null) {
if (descendantOp.getOperatorTag() == LogicalOperatorTag.ASSIGN) {
@@ -346,7 +350,7 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
continue;
}
- String indexName = null;
+ String indexName;
Index index = null;
ILogicalExpression unnestExpr = unnestMapOp.getExpressionRef().getValue();
if (unnestExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
@@ -408,10 +412,10 @@ public class IntroduceLSMComponentFilterRule implements IAlgebraicRewriteRule {
|| funcIdent == AsterixBuiltinFunctions.FIELD_ACCESS_BY_INDEX) {
//get the variable from here. Figure out which input it came from. Go to that input!!!
- ArrayList<LogicalVariable> usedVars = new ArrayList<LogicalVariable>();
+ ArrayList<LogicalVariable> usedVars = new ArrayList<>();
expr.getUsedVariables(usedVars);
LogicalVariable usedVar = usedVars.get(0);
- List<String> returnList = new ArrayList<String>();
+ List<String> returnList = new ArrayList<>();
//Find the input that it came from
for (int varCheck = 0; varCheck < op.getInputs().size(); varCheck++) {
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
index 5b9a9b6..2464c06 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
@@ -106,7 +106,7 @@ public class IntroduceSelectAccessMethodRule extends AbstractIntroduceAccessMeth
// Analyze select condition.
Map<IAccessMethod, AccessMethodAnalysisContext> analyzedAMs = new TreeMap<IAccessMethod, AccessMethodAnalysisContext>();
- if (!analyzeCondition(selectCond, subTree.assignsAndUnnests, analyzedAMs, context, typeEnvironment)) {
+ if (!analyzeCondition(selectCond, subTree.getAssignsAndUnnests(), analyzedAMs, context, typeEnvironment)) {
return false;
}
@@ -164,7 +164,7 @@ public class IntroduceSelectAccessMethodRule extends AbstractIntroduceAccessMeth
}
ILogicalOperator primaryUnnest = connectAll2ndarySearchPlanWithIntersect(subRoots, context);
- subTree.dataSourceRef.setValue(primaryUnnest);
+ subTree.getDataSourceRef().setValue(primaryUnnest);
return primaryUnnest != null;
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
index 58cc32e..1052a72 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
@@ -99,7 +99,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
INVALID
}
- private static List<FunctionIdentifier> funcIdents = new ArrayList<FunctionIdentifier>();
+ private static List<FunctionIdentifier> funcIdents = new ArrayList<>();
static {
funcIdents.add(AsterixBuiltinFunctions.STRING_CONTAINS);
@@ -110,7 +110,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
// These function identifiers are matched in this AM's analyzeFuncExprArgs(),
// and are not visible to the outside driver.
- private static HashSet<FunctionIdentifier> secondLevelFuncIdents = new HashSet<FunctionIdentifier>();
+ private static HashSet<FunctionIdentifier> secondLevelFuncIdents = new HashSet<>();
static {
secondLevelFuncIdents.add(AsterixBuiltinFunctions.SIMILARITY_JACCARD_CHECK);
@@ -276,11 +276,12 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
ILogicalExpression arg1 = funcExpr.getArguments().get(0).getValue();
ILogicalExpression arg2 = funcExpr.getArguments().get(1).getValue();
// Determine whether one arg is constant, and the other is non-constant.
- ILogicalExpression constArg = null;
- ILogicalExpression nonConstArg = null;
+ ILogicalExpression constArg;
+ ILogicalExpression nonConstArg;
if (arg1.getExpressionTag() == LogicalExpressionTag.CONSTANT
&& arg2.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
- // The arguments of edit-distance-contains() function are asymmetrical, we can only use index if it is on the first argument
+ // The arguments of edit-distance-contains() function are asymmetrical, we can only use index if it is on
+ // the first argument
if (funcExpr.getFunctionIdentifier() == AsterixBuiltinFunctions.EDIT_DISTANCE_CONTAINS) {
return false;
}
@@ -368,11 +369,11 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
IOptimizationContext context) throws AlgebricksException {
IOptimizableFuncExpr optFuncExpr = AccessMethodUtils.chooseFirstOptFuncExpr(chosenIndex, analysisCtx);
- Dataset dataset = indexSubTree.dataset;
- ARecordType recordType = indexSubTree.recordType;
- ARecordType metaRecordType = indexSubTree.metaRecordType;
+ Dataset dataset = indexSubTree.getDataset();
+ ARecordType recordType = indexSubTree.getRecordType();
+ ARecordType metaRecordType = indexSubTree.getMetaRecordType();
// we made sure indexSubTree has datasource scan
- DataSourceScanOperator dataSourceScan = (DataSourceScanOperator) indexSubTree.dataSourceRef.getValue();
+ DataSourceScanOperator dataSourceScan = (DataSourceScanOperator) indexSubTree.getDataSourceRef().getValue();
InvertedIndexJobGenParams jobGenParams = new InvertedIndexJobGenParams(chosenIndex.getIndexName(),
chosenIndex.getIndexType(), dataset.getDataverseName(), dataset.getDatasetName(), retainInput,
@@ -403,7 +404,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
// We are optimizing a join. Add the input variable to the secondaryIndexFuncArgs.
LogicalVariable inputSearchVariable = getInputSearchVar(optFuncExpr, indexSubTree);
keyVarList.add(inputSearchVariable);
- inputOp = (AbstractLogicalOperator) probeSubTree.root;
+ inputOp = (AbstractLogicalOperator) probeSubTree.getRoot();
}
jobGenParams.setKeyVarList(keyVarList);
ILogicalOperator secondaryIndexUnnestOp = AccessMethodUtils.createSecondaryIndexUnnestMap(dataset, recordType,
@@ -440,7 +441,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
ILogicalOperator indexPlanRootOp = createSecondaryToPrimaryPlan(null, subTree, null, chosenIndex, analysisCtx,
false, false, false, context);
// Replace the datasource scan with the new plan rooted at primaryIndexUnnestMap.
- subTree.dataSourceRef.setValue(indexPlanRootOp);
+ subTree.getDataSourceRef().setValue(indexPlanRootOp);
return true;
}
@@ -451,14 +452,14 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
boolean hasGroupBy) throws AlgebricksException {
// Figure out 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);
- OptimizableOperatorSubTree indexSubTree = null;
- OptimizableOperatorSubTree probeSubTree = null;
+ OptimizableOperatorSubTree indexSubTree;
+ OptimizableOperatorSubTree probeSubTree;
// We assume that the left subtree is the outer branch and the right subtree is the inner branch.
// This assumption holds true since we only use an index from the right subtree.
// The following is just a sanity check.
if (rightSubTree.hasDataSourceScan()
- && dataset.getDatasetName().equals(rightSubTree.dataset.getDatasetName())) {
+ && dataset.getDatasetName().equals(rightSubTree.getDataset().getDatasetName())) {
indexSubTree = rightSubTree;
probeSubTree = leftSubTree;
} else {
@@ -469,8 +470,8 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
// The arguments of edit-distance-contains() function are asymmetrical, we can only use index
// if the dataset of index subtree and the dataset of first argument's subtree is the same
if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == AsterixBuiltinFunctions.EDIT_DISTANCE_CONTAINS
- && optFuncExpr.getOperatorSubTree(0).dataset != null && !optFuncExpr.getOperatorSubTree(0).dataset
- .getDatasetName().equals(indexSubTree.dataset.getDatasetName())) {
+ && optFuncExpr.getOperatorSubTree(0).getDataset() != null && !optFuncExpr.getOperatorSubTree(0)
+ .getDataset().getDatasetName().equals(indexSubTree.getDataset().getDatasetName())) {
return false;
}
@@ -489,9 +490,9 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
// Remember the original probe subtree, and its primary-key variables,
// so we can later retrieve the missing attributes via an equi join.
- List<LogicalVariable> originalSubTreePKs = new ArrayList<LogicalVariable>();
+ List<LogicalVariable> originalSubTreePKs = new ArrayList<>();
// Remember the primary-keys of the new probe subtree for the top-level equi join.
- List<LogicalVariable> surrogateSubTreePKs = new ArrayList<LogicalVariable>();
+ List<LogicalVariable> surrogateSubTreePKs = new ArrayList<>();
// Copy probe subtree, replacing their variables with new ones. We will use the original variables
// to stitch together a top-level equi join.
@@ -499,8 +500,8 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
join.getCondition().getValue(), optFuncExpr, originalSubTreePKs, surrogateSubTreePKs, context);
// Remember original live variables from the index sub tree.
- List<LogicalVariable> indexSubTreeLiveVars = new ArrayList<LogicalVariable>();
- VariableUtilities.getLiveVariables(indexSubTree.root, indexSubTreeLiveVars);
+ List<LogicalVariable> indexSubTreeLiveVars = new ArrayList<>();
+ VariableUtilities.getLiveVariables(indexSubTree.getRoot(), indexSubTreeLiveVars);
// Clone the original join condition because we may have to modify it (and we also need the original).
ILogicalExpression joinCond = join.getCondition().getValue().cloneExpression();
@@ -510,22 +511,22 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == AsterixBuiltinFunctions.EDIT_DISTANCE_CHECK
|| optFuncExpr.getFuncExpr()
.getFunctionIdentifier() == AsterixBuiltinFunctions.EDIT_DISTANCE_CONTAINS) {
- panicJoinRef = new MutableObject<ILogicalOperator>(joinRef.getValue());
- panicVarMap = new HashMap<LogicalVariable, LogicalVariable>();
+ panicJoinRef = new MutableObject<>(joinRef.getValue());
+ panicVarMap = new HashMap<>();
Mutable<ILogicalOperator> newProbeRootRef = createPanicNestedLoopJoinPlan(panicJoinRef, indexSubTree,
probeSubTree, optFuncExpr, chosenIndex, panicVarMap, context);
- probeSubTree.rootRef.setValue(newProbeRootRef.getValue());
- probeSubTree.root = newProbeRootRef.getValue();
+ probeSubTree.getRootRef().setValue(newProbeRootRef.getValue());
+ probeSubTree.setRoot(newProbeRootRef.getValue());
}
// Create regular indexed-nested loop join path.
ILogicalOperator indexPlanRootOp = createSecondaryToPrimaryPlan(null, indexSubTree, probeSubTree, chosenIndex,
analysisCtx, true, isLeftOuterJoin, true, context);
- indexSubTree.dataSourceRef.setValue(indexPlanRootOp);
+ indexSubTree.getDataSourceRef().setValue(indexPlanRootOp);
// Change join into a select with the same condition.
SelectOperator topSelect = new SelectOperator(new MutableObject<ILogicalExpression>(joinCond), isLeftOuterJoin,
newNullPlaceHolderVar);
- topSelect.getInputs().add(indexSubTree.rootRef);
+ topSelect.getInputs().add(indexSubTree.getRootRef());
topSelect.setExecutionMode(ExecutionMode.LOCAL);
context.computeAndSetTypeEnvironmentForOperator(topSelect);
ILogicalOperator topOp = topSelect;
@@ -535,10 +536,10 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
LogicalVariable inputSearchVar = getInputSearchVar(optFuncExpr, indexSubTree);
indexSubTreeLiveVars.addAll(originalSubTreePKs);
indexSubTreeLiveVars.add(inputSearchVar);
- List<LogicalVariable> panicPlanLiveVars = new ArrayList<LogicalVariable>();
+ List<LogicalVariable> panicPlanLiveVars = new ArrayList<>();
VariableUtilities.getLiveVariables(panicJoinRef.getValue(), panicPlanLiveVars);
// Create variable mapping for union all operator.
- List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>();
+ List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> varMap = new ArrayList<>();
for (int i = 0; i < indexSubTreeLiveVars.size(); i++) {
LogicalVariable indexSubTreeVar = indexSubTreeLiveVars.get(i);
LogicalVariable panicPlanVar = panicVarMap.get(indexSubTreeVar);
@@ -593,7 +594,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
Map<LogicalVariable, LogicalVariable> joinInputSubTreeVarMap = new HashMap<LogicalVariable, LogicalVariable>();
// Init with all live vars.
List<LogicalVariable> liveVars = new ArrayList<LogicalVariable>();
- VariableUtilities.getLiveVariables(probeSubTree.root, liveVars);
+ VariableUtilities.getLiveVariables(probeSubTree.getRoot(), liveVars);
for (LogicalVariable var : liveVars) {
joinInputSubTreeVarMap.put(var, var);
}
@@ -612,25 +613,25 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
// Create first copy.
LogicalOperatorDeepCopyWithNewVariablesVisitor firstDeepCopyVisitor = new LogicalOperatorDeepCopyWithNewVariablesVisitor(
context, context, newProbeSubTreeVarMap);
- ILogicalOperator newProbeSubTree = firstDeepCopyVisitor.deepCopy(probeSubTree.root);
+ ILogicalOperator newProbeSubTree = firstDeepCopyVisitor.deepCopy(probeSubTree.getRoot());
inferTypes(newProbeSubTree, context);
Mutable<ILogicalOperator> newProbeSubTreeRootRef = new MutableObject<ILogicalOperator>(newProbeSubTree);
// Create second copy.
LogicalOperatorDeepCopyWithNewVariablesVisitor secondDeepCopyVisitor = new LogicalOperatorDeepCopyWithNewVariablesVisitor(
context, context, joinInputSubTreeVarMap);
- ILogicalOperator joinInputSubTree = secondDeepCopyVisitor.deepCopy(probeSubTree.root);
+ ILogicalOperator joinInputSubTree = secondDeepCopyVisitor.deepCopy(probeSubTree.getRoot());
inferTypes(joinInputSubTree, context);
- probeSubTree.rootRef.setValue(joinInputSubTree);
+ probeSubTree.getRootRef().setValue(joinInputSubTree);
// Remember the original probe subtree reference so we can return it.
- Mutable<ILogicalOperator> originalProbeSubTreeRootRef = probeSubTree.rootRef;
+ Mutable<ILogicalOperator> originalProbeSubTreeRootRef = probeSubTree.getRootRef();
// Replace the original probe subtree with its copy.
- Dataset origDataset = probeSubTree.dataset;
- ARecordType origRecordType = probeSubTree.recordType;
+ Dataset origDataset = probeSubTree.getDataset();
+ ARecordType origRecordType = probeSubTree.getRecordType();
probeSubTree.initFromSubTree(newProbeSubTreeRootRef);
- probeSubTree.dataset = origDataset;
- probeSubTree.recordType = origRecordType;
+ probeSubTree.setDataset(origDataset);
+ probeSubTree.setRecordType(origRecordType);
// Replace the variables in the join condition based on the mapping of variables
// in the new probe subtree.
@@ -673,12 +674,12 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
// We split the plan into two "branches", and add selections on each side.
AbstractLogicalOperator replicateOp = new ReplicateOperator(2);
- replicateOp.getInputs().add(new MutableObject<ILogicalOperator>(probeSubTree.root));
+ replicateOp.getInputs().add(new MutableObject<ILogicalOperator>(probeSubTree.getRoot()));
replicateOp.setExecutionMode(ExecutionMode.PARTITIONED);
context.computeAndSetTypeEnvironmentForOperator(replicateOp);
// Create select ops for removing tuples that are filterable and not filterable, respectively.
- IVariableTypeEnvironment probeTypeEnv = context.getOutputTypeEnvironment(probeSubTree.root);
+ IVariableTypeEnvironment probeTypeEnv = context.getOutputTypeEnvironment(probeSubTree.getRoot());
IAType inputSearchVarType;
if (chosenIndex.isEnforcingKeyFileds()) {
inputSearchVarType = optFuncExpr.getFieldType(optFuncExpr.findLogicalVar(inputSearchVar));
@@ -691,12 +692,12 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
isFilterableSelectOpRef, isNotFilterableSelectOpRef);
List<LogicalVariable> originalLiveVars = new ArrayList<LogicalVariable>();
- VariableUtilities.getLiveVariables(indexSubTree.root, originalLiveVars);
+ VariableUtilities.getLiveVariables(indexSubTree.getRoot(), originalLiveVars);
// Copy the scan subtree in indexSubTree.
LogicalOperatorDeepCopyWithNewVariablesVisitor deepCopyVisitor = new LogicalOperatorDeepCopyWithNewVariablesVisitor(
context, context);
- ILogicalOperator scanSubTree = deepCopyVisitor.deepCopy(indexSubTree.root);
+ ILogicalOperator scanSubTree = deepCopyVisitor.deepCopy(indexSubTree.getRoot());
Map<LogicalVariable, LogicalVariable> copyVarMap = deepCopyVisitor.getInputToOutputVariableMapping();
panicVarMap.putAll(copyVarMap);
@@ -1020,7 +1021,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
return null;
}
- for (AbstractLogicalOperator op : subTree.assignsAndUnnests) {
+ for (AbstractLogicalOperator op : subTree.getAssignsAndUnnests()) {
if (op.getOperatorTag() != LogicalOperatorTag.ASSIGN) {
continue;
}