use of org.apache.hyracks.algebricks.core.algebra.operators.logical.WriteOperator in project asterixdb by apache.
the class PigletCompiler method translate.
private ILogicalPlan translate(List<ASTNode> ast) throws PigletException {
Map<String, Relation> symMap = new HashMap<String, Relation>();
List<Mutable<ILogicalOperator>> roots = new ArrayList<Mutable<ILogicalOperator>>();
previousOp = null;
for (ASTNode an : ast) {
switch(an.getTag()) {
case DUMP:
{
DumpNode dn = (DumpNode) an;
Relation input = symMap.get(dn.getAlias());
List<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>();
for (LogicalVariable v : input.schema.values()) {
expressions.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(v)));
}
PigletFileDataSink dataSink = new PigletFileDataSink(dn.getFile());
ILogicalOperator op = new WriteOperator(expressions, dataSink);
op.getInputs().add(new MutableObject<ILogicalOperator>(input.op));
roots.add(new MutableObject<ILogicalOperator>(op));
}
break;
case ASSIGNMENT:
{
AssignmentNode asn = (AssignmentNode) an;
String alias = asn.getAlias();
RelationNode rn = asn.getRelation();
Relation rel = translate(rn, symMap);
previousOp = rel.op;
rel.alias = alias;
symMap.put(alias, rel);
}
break;
}
}
return new ALogicalPlanImpl(roots);
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.WriteOperator in project asterixdb by apache.
the class SinkWritePOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
WriteOperator write = (WriteOperator) op;
IDataSink sink = write.getDataSink();
IPartitioningProperty pp = sink.getPartitioningProperty();
StructuralPropertiesVector[] r = new StructuralPropertiesVector[] { new StructuralPropertiesVector(pp, null) };
return new PhysicalRequirements(r, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.WriteOperator in project asterixdb by apache.
the class IsomorphismOperatorVisitor method visitWriteOperator.
@Override
public Boolean visitWriteOperator(WriteOperator op, ILogicalOperator arg) throws AlgebricksException {
AbstractLogicalOperator aop = (AbstractLogicalOperator) arg;
if (aop.getOperatorTag() != LogicalOperatorTag.WRITE) {
return Boolean.FALSE;
}
WriteOperator writeOpArg = (WriteOperator) copyAndSubstituteVar(op, arg);
boolean isomorphic = VariableUtilities.varListEqualUnordered(op.getSchema(), writeOpArg.getSchema());
return isomorphic;
}
use of org.apache.hyracks.algebricks.core.algebra.operators.logical.WriteOperator in project asterixdb by apache.
the class SinkWritePOperator method contributeRuntimeOperator.
@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
WriteOperator write = (WriteOperator) op;
int[] columns = new int[write.getExpressions().size()];
int i = 0;
for (Mutable<ILogicalExpression> exprRef : write.getExpressions()) {
ILogicalExpression expr = exprRef.getValue();
if (expr.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
throw new NotImplementedException("Only writing variable expressions is supported.");
}
VariableReferenceExpression varRef = (VariableReferenceExpression) expr;
LogicalVariable v = varRef.getVariableReference();
columns[i++] = inputSchemas[0].findVariable(v);
}
RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema, context);
RecordDescriptor inputDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context);
IPrinterFactory[] pf = JobGenHelper.mkPrinterFactories(inputSchemas[0], context.getTypeEnvironment(op), context, columns);
IMetadataProvider<?, ?> mp = context.getMetadataProvider();
Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> runtime = mp.getWriteFileRuntime(write.getDataSink(), columns, pf, inputDesc);
builder.contributeMicroOperator(write, runtime.first, recDesc, runtime.second);
ILogicalOperator src = write.getInputs().get(0).getValue();
builder.contributeGraphEdge(src, 0, write, 0);
}
Aggregations