Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
Expand Down Expand Up @@ -47,7 +46,7 @@
* After
*
* plan__parent
* ASSIGN( $v2 : $v1 )
* ASSIGN( $v2 : $v1 )
* DATASCAN( $source : $v1 )
* plan__child
*
Expand All @@ -61,12 +60,12 @@ boolean updateDataSource(IVXQueryDataSource datasource, Mutable<ILogicalExpressi
AbstractVXQueryDataSource ds = (AbstractVXQueryDataSource) datasource;
boolean added = false;
BooleanPointable bp = (BooleanPointable) BooleanPointable.FACTORY.createPointable();
List<Mutable<ILogicalExpression>> findkeys = new ArrayList<Mutable<ILogicalExpression>>();
List<Mutable<ILogicalExpression>> findkeys = new ArrayList<>();
ExpressionToolbox.findAllFunctionExpressions(expression,
BuiltinOperators.KEYS_OR_MEMBERS.getFunctionIdentifier(), findkeys);
for (int i = findkeys.size(); i > 0; --i) {
XDMConstants.setTrue(bp);
ds.addValueSeq(ArrayUtils.toObject(bp.getByteArray()));
ds.appendValueSequence(bp);
added = true;
}
return added;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
import org.apache.vxquery.compiler.rewriter.rules.util.ExpressionToolbox;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.functions.BuiltinFunctions;
import org.apache.vxquery.functions.BuiltinOperators;
import org.apache.vxquery.metadata.IVXQueryDataSource;
Expand Down Expand Up @@ -56,6 +57,7 @@
*/

public class PushValueIntoDatascanRule extends AbstractPushExpressionIntoDatascanRule {
TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();

@Override
boolean updateDataSource(IVXQueryDataSource datasource, Mutable<ILogicalExpression> expression) {
Expand All @@ -64,7 +66,7 @@ boolean updateDataSource(IVXQueryDataSource datasource, Mutable<ILogicalExpressi
}
VXQueryCollectionDataSource ds = (VXQueryCollectionDataSource) datasource;
boolean added = false;
List<Mutable<ILogicalExpression>> finds = new ArrayList<Mutable<ILogicalExpression>>();
List<Mutable<ILogicalExpression>> finds = new ArrayList<>();
ILogicalExpression le = expression.getValue();
if (le.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
AbstractFunctionCallExpression afce = (AbstractFunctionCallExpression) le;
Expand All @@ -75,11 +77,10 @@ boolean updateDataSource(IVXQueryDataSource datasource, Mutable<ILogicalExpressi
ExpressionToolbox.findAllFunctionExpressions(expression, BuiltinOperators.VALUE.getFunctionIdentifier(), finds);

for (int i = finds.size(); i > 0; --i) {
Byte[] value = null;
List<ILogicalExpression> values = ExpressionToolbox.getFullArguments(finds.get(i - 1));
if (values.size() > 1) {
value = ExpressionToolbox.getConstantArgument(finds.get(i - 1), 1);
ds.addValueSeq(value);
ExpressionToolbox.getConstantArgument(finds.get(i - 1), 1, tvp);
ds.appendValueSequence(tvp);
added = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.vxquery.compiler.algebricks.VXQueryConstantValue;
import org.apache.vxquery.context.StaticContext;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.functions.BuiltinFunctions;
import org.apache.vxquery.functions.BuiltinOperators;
import org.apache.vxquery.functions.Function;
import org.apache.vxquery.types.AnyNodeType;
import org.apache.vxquery.types.Quantifier;
import org.apache.vxquery.types.SequenceType;

import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
Expand All @@ -43,6 +32,15 @@
import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
import org.apache.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator;
import org.apache.hyracks.data.std.primitive.IntegerPointable;
import org.apache.vxquery.compiler.algebricks.VXQueryConstantValue;
import org.apache.vxquery.context.StaticContext;
import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
import org.apache.vxquery.functions.BuiltinFunctions;
import org.apache.vxquery.functions.BuiltinOperators;
import org.apache.vxquery.functions.Function;
import org.apache.vxquery.types.AnyNodeType;
import org.apache.vxquery.types.Quantifier;
import org.apache.vxquery.types.SequenceType;

public class ExpressionToolbox {
public static Mutable<ILogicalExpression> findVariableExpression(Mutable<ILogicalExpression> mutableLe,
Expand Down Expand Up @@ -213,16 +211,14 @@ public static int getTypeExpressionTypeArgument(Mutable<ILogicalExpression> sear
return pTypeCode.getInteger();
}

public static Byte[] getConstantArgument(Mutable<ILogicalExpression> searchM, int arg) {
public static void getConstantArgument(Mutable<ILogicalExpression> searchM, int arg, TaggedValuePointable tvp) {
AbstractFunctionCallExpression searchFunction = (AbstractFunctionCallExpression) searchM.getValue();
ILogicalExpression argType = searchFunction.getArguments().get(arg).getValue();
searchFunction.getArguments().size();
if (argType.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
return null;
return;
}
TaggedValuePointable tvp = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
ExpressionToolbox.getConstantAsPointable((ConstantExpression) argType, tvp);
return ArrayUtils.toObject(tvp.getByteArray());
}

public static List<ILogicalExpression> getFullArguments(Mutable<ILogicalExpression> searchM) {
Expand Down
Loading