private void deepCopyAnnotations(AbstractFunctionCallExpression src, AbstractFunctionCallExpression dest) { Map<Object, IExpressionAnnotation> srcAnnotations = src.getAnnotations(); Map<Object, IExpressionAnnotation> destAnnotations = dest.getAnnotations(); srcAnnotations.forEach((key, value) -> destAnnotations.put(key, value.copy())); }
@Override public boolean exprIsOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) { if (optFuncExpr.getFuncExpr().getAnnotations() .containsKey(SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE)) { return false; } // No additional analysis required. return true; }
private boolean processExpression(Mutable<ILogicalOperator> opRef, Mutable<ILogicalExpression> search) { boolean modified = false; functionList.clear(); ExpressionToolbox.findAllFunctionExpressions(search, functionList); for (Mutable<ILogicalExpression> searchM : functionList) { searchFunction = (AbstractFunctionCallExpression) searchM.getValue(); if (ALGEBRICKS_MAP.containsKey(searchFunction.getFunctionIdentifier())) { FunctionIdentifier fid = searchFunction.getFunctionIdentifier(); if (ALGEBRICKS_MAP.get(fid).first == null) { modified = convertAlgebricksExpression(searchM, ALGEBRICKS_MAP.get(fid).second, false); } else if (ALGEBRICKS_MAP.get(fid).second == null) { modified = convertAlgebricksExpression(searchM, ALGEBRICKS_MAP.get(fid).first, true); } else { IExpressionAnnotation annotate = searchFunction.getAnnotations().get( ALGEBRICKS_CONVERSION_ANNOTATION); if (((FunctionIdentifier) annotate.getObject()).equals(ALGEBRICKS_MAP.get(fid).first .getFunctionIdentifier())) { modified = convertAlgebricksExpression(searchM, ALGEBRICKS_MAP.get(fid).first, true); } else if (((FunctionIdentifier) annotate.getObject()).equals(ALGEBRICKS_MAP.get(fid).second .getFunctionIdentifier())) { modified = convertAlgebricksExpression(searchM, ALGEBRICKS_MAP.get(fid).second, false); } } } } return modified; }
public boolean convertFunctionToAlgebricksExpression(Mutable<ILogicalExpression> searchM, AbstractFunctionCallExpression functionCall, IOptimizationContext context, Map<FunctionIdentifier, FunctionIdentifier> map) { if (map.containsKey(functionCall.getFunctionIdentifier())) { IExpressionAnnotation annotate = new ExpressionAnnotationNoCopyImpl(); annotate.setObject(functionCall.getFunctionIdentifier()); FunctionIdentifier algebricksFid = map.get(functionCall.getFunctionIdentifier()); IFunctionInfo algebricksFunction = context.getMetadataProvider().lookupFunction(algebricksFid); functionCall.setFunctionInfo(algebricksFunction); functionCall.getAnnotations().put(ALGEBRICKS_CONVERSION_ANNOTATION, annotate); searchM.setValue(functionCall); return true; } return false; }
@Override public boolean exprIsOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) throws AlgebricksException { // If we are optimizing a join, check for the indexed nested-loop join hint. if (optFuncExpr.getNumLogicalVars() == 2) { if (optFuncExpr.getOperatorSubTree(0) == optFuncExpr.getOperatorSubTree(1)) { if ((optFuncExpr.getSourceVar(0) == null && optFuncExpr.getFieldType(0) != null) || (optFuncExpr.getSourceVar(1) == null && optFuncExpr.getFieldType(1) != null)) { //We are in the select case (trees are the same, and one field comes from non-scan) //We can do the index search } else { //One of the vars was from an assign rather than a scan //And we were unable to determine its type return false; } } else if (!optFuncExpr.getFuncExpr().getAnnotations() .containsKey(IndexedNLJoinExpressionAnnotation.INSTANCE)) { return false; } } if (!index.isPrimaryIndex() && optFuncExpr.getFuncExpr().getAnnotations() .containsKey(SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE)) { return false; } // No additional analysis required for BTrees. return true; }
BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation(); bcast.setObject(BroadcastSide.LEFT); f.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast); BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation(); bcast.setObject(BroadcastSide.RIGHT); f.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast); BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation(); bcast.setObject(BroadcastSide.RIGHT); currExpr.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast); currExpr.getAnnotations().put(hint, hint);
} else { IExpressionAnnotation ann = fexp.getAnnotations().get(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY); if (ann == null) { return null;
similarityExp.setSourceLocation(sourceLoc); similarityExp.getAnnotations().putAll(funcExp.getAnnotations()); ArrayList<Mutable<ILogicalExpression>> cmpArgs = new ArrayList<Mutable<ILogicalExpression>>(); cmpArgs.add(new MutableObject<ILogicalExpression>(similarityExp));
if (simFuncExpr.getAnnotations().containsKey(IndexedNLJoinExpressionAnnotation.INSTANCE)) { return false;
@Override public boolean exprIsOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) throws AlgebricksException { if (optFuncExpr.getFuncExpr().getAnnotations() .containsKey(SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE)) { return false; } if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == BuiltinFunctions.EDIT_DISTANCE_CHECK || optFuncExpr.getFuncExpr().getFunctionIdentifier() == BuiltinFunctions.EDIT_DISTANCE_CONTAINS) { return isEditDistanceFuncOptimizable(index, optFuncExpr); } if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == BuiltinFunctions.SIMILARITY_JACCARD_CHECK) { return isJaccardFuncOptimizable(index, optFuncExpr); } if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == BuiltinFunctions.STRING_CONTAINS) { return isContainsFuncOptimizable(index, optFuncExpr); } if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == BuiltinFunctions.FULLTEXT_CONTAINS || optFuncExpr.getFuncExpr().getFunctionIdentifier() == BuiltinFunctions.FULLTEXT_CONTAINS_WO_OPTION) { return isFullTextContainsFuncOptimizable(index, optFuncExpr); } return false; }
f.getAnnotations().put(hint, hint);
simCheckFuncExpr.getAnnotations().putAll(funcExpr.getAnnotations());
eqExp.getArguments().add(new MutableObject<>(scanVarRef)); eqExp.getArguments().add(new MutableObject<>(varEx.cloneExpression())); eqExp.getAnnotations().put(IndexedNLJoinExpressionAnnotation.INSTANCE, IndexedNLJoinExpressionAnnotation.INSTANCE); BroadcastExpressionAnnotation bcast = new BroadcastExpressionAnnotation(); eqExp.getAnnotations().put(BroadcastExpressionAnnotation.BROADCAST_ANNOTATION_KEY, bcast);