use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class AlgebricksOptimizationContext method updatePrimaryKeys.
@Override
public void updatePrimaryKeys(Map<LogicalVariable, LogicalVariable> mappedVars) {
for (Map.Entry<LogicalVariable, FunctionalDependency> me : varToPrimaryKey.entrySet()) {
FunctionalDependency fd = me.getValue();
List<LogicalVariable> hd = new ArrayList<>();
for (LogicalVariable v : fd.getHead()) {
LogicalVariable v2 = mappedVars.get(v);
if (v2 == null) {
hd.add(v);
} else {
hd.add(v2);
}
}
List<LogicalVariable> tl = new ArrayList<>();
for (LogicalVariable v : fd.getTail()) {
LogicalVariable v2 = mappedVars.get(v);
if (v2 == null) {
tl.add(v);
} else {
tl.add(v2);
}
}
me.setValue(new FunctionalDependency(hd, tl));
}
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable 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.base.LogicalVariable in project asterixdb by apache.
the class JobGenHelper method projectAllVariables.
public static int[] projectAllVariables(IOperatorSchema opSchema) {
int[] projectionList = new int[opSchema.getSize()];
int k = 0;
for (LogicalVariable v : opSchema) {
projectionList[k++] = opSchema.findVariable(v);
}
return projectionList;
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class JobGenHelper method mkPrinterFactories.
public static IPrinterFactory[] mkPrinterFactories(IOperatorSchema opSchema, IVariableTypeEnvironment env, JobGenContext context, int[] printColumns) throws AlgebricksException {
IPrinterFactory[] pf = new IPrinterFactory[printColumns.length];
IPrinterFactoryProvider pff = context.getPrinterFactoryProvider();
try {
for (int i = 0; i < pf.length; i++) {
LogicalVariable v = opSchema.getVariable(printColumns[i]);
Object t = env.getVarType(v);
pf[i] = pff.getPrinterFactory(t);
}
return pf;
} catch (HyracksDataException e) {
throw new AlgebricksException(e);
}
}
use of org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable in project asterixdb by apache.
the class JobGenHelper method variablesToAscBinaryComparatorFactories.
public static IBinaryComparatorFactory[] variablesToAscBinaryComparatorFactories(Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context) throws AlgebricksException {
IBinaryComparatorFactory[] compFactories = new IBinaryComparatorFactory[varLogical.size()];
IBinaryComparatorFactoryProvider bcfProvider = context.getBinaryComparatorFactoryProvider();
int i = 0;
for (LogicalVariable v : varLogical) {
Object type = env.getVarType(v);
compFactories[i++] = bcfProvider.getBinaryComparatorFactory(type, true);
}
return compFactories;
}
Aggregations