use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.
the class IntersectPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator iop, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
IntersectOperator intersectOp = (IntersectOperator) iop;
StructuralPropertiesVector[] pv = new StructuralPropertiesVector[intersectOp.getNumInput()];
for (int i = 0; i < intersectOp.getNumInput(); i++) {
List<ILocalStructuralProperty> localProps = new ArrayList<>();
List<OrderColumn> orderColumns = new ArrayList<>();
for (LogicalVariable column : intersectOp.getInputVariables(i)) {
orderColumns.add(new OrderColumn(column, OrderOperator.IOrder.OrderKind.ASC));
}
localProps.add(new LocalOrderProperty(orderColumns));
IPartitioningProperty pp = null;
if (intersectOp.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) {
Set<LogicalVariable> partitioningVariables = new HashSet<>(intersectOp.getInputVariables(i));
pp = new UnorderedPartitionedProperty(partitioningVariables, null);
}
pv[i] = new StructuralPropertiesVector(pp, localProps);
}
return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.
the class IntersectPOperator method contributeRuntimeOperator.
@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
// logical op should have checked all the mismatch issues.
IntersectOperator logicalOp = (IntersectOperator) op;
int nInput = logicalOp.getNumInput();
int[][] compareFields = new int[nInput][];
IBinaryComparatorFactory[] comparatorFactories = JobGenHelper.variablesToAscBinaryComparatorFactories(logicalOp.getInputVariables(0), context.getTypeEnvironment(op), context);
INormalizedKeyComputerFactoryProvider nkcfProvider = context.getNormalizedKeyComputerFactoryProvider();
INormalizedKeyComputerFactory nkcf = null;
if (nkcfProvider != null) {
Object type = context.getTypeEnvironment(op).getVarType(logicalOp.getInputVariables(0).get(0));
if (type != null) {
nkcf = nkcfProvider.getNormalizedKeyComputerFactory(type, true);
}
}
for (int i = 0; i < logicalOp.getNumInput(); i++) {
compareFields[i] = JobGenHelper.variablesToFieldIndexes(logicalOp.getInputVariables(i), inputSchemas[i]);
}
IOperatorDescriptorRegistry spec = builder.getJobSpec();
RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
IntersectOperatorDescriptor opDescriptor = null;
try {
opDescriptor = new IntersectOperatorDescriptor(spec, nInput, compareFields, nkcf, comparatorFactories, recordDescriptor);
} catch (HyracksException e) {
throw new AlgebricksException(e);
}
contributeOpDesc(builder, (AbstractLogicalOperator) op, opDescriptor);
for (int i = 0; i < op.getInputs().size(); i++) {
builder.contributeGraphEdge(op.getInputs().get(i).getValue(), 0, op, i);
}
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitIntersectOperator.
@Override
public ILogicalOperator visitIntersectOperator(IntersectOperator op, ILogicalOperator arg) throws AlgebricksException {
List<List<LogicalVariable>> liveVarsInInputs = getLiveVarsInInputs(op);
List<LogicalVariable> outputCopy = new ArrayList<>();
for (LogicalVariable var : op.getOutputVars()) {
outputCopy.add(deepCopyVariable(var));
}
IntersectOperator opCopy = new IntersectOperator(outputCopy, liveVarsInInputs);
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
return opCopy;
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.
the class IsomorphismOperatorVisitor method visitIntersectOperator.
@Override
public Boolean visitIntersectOperator(IntersectOperator op, ILogicalOperator arg) throws AlgebricksException {
if (op.getOperatorTag() != LogicalOperatorTag.INTERSECT) {
return Boolean.FALSE;
}
IntersectOperator intersetOpArg = (IntersectOperator) copyAndSubstituteVar(op, arg);
List<LogicalVariable> variables = op.getOutputVars();
List<LogicalVariable> variablesArg = intersetOpArg.getOutputVars();
if (variables.size() != variablesArg.size()) {
return Boolean.FALSE;
}
if (!VariableUtilities.varListEqualUnordered(variables, variablesArg)) {
return Boolean.FALSE;
}
if (op.getNumInput() != intersetOpArg.getNumInput()) {
return Boolean.FALSE;
}
for (int i = 0; i < op.getNumInput(); i++) {
if (!VariableUtilities.varListEqualUnordered(op.getInputVariables(i), intersetOpArg.getInputVariables(i))) {
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.
the class IsomorphismVariableMappingVisitor method mapVariablesForIntersect.
private void mapVariablesForIntersect(IntersectOperator op, ILogicalOperator arg) {
if (op.getOperatorTag() != arg.getOperatorTag()) {
return;
}
IntersectOperator opArg = (IntersectOperator) arg;
if (op.getNumInput() != opArg.getNumInput()) {
return;
}
for (int i = 0; i < op.getNumInput(); i++) {
for (int j = 0; j < op.getInputVariables(i).size(); j++) {
if (!varEquivalent(op.getInputVariables(i).get(j), opArg.getInputVariables(i).get(j))) {
return;
}
}
}
mapVariables(op.getOutputVars(), opArg.getOutputVars());
}
Aggregations