Package org.apache.pig.newplan.logical.relational

Examples of org.apache.pig.newplan.logical.relational.LogicalSchema


     * @throws IOException
     */
    public Schema dumpSchema(String alias) throws IOException {
        try {
            LogicalRelationalOperator op = getOperatorForAlias( alias );
            LogicalSchema schema = op.getSchema();
           
            if (schema != null) {
                Schema s = org.apache.pig.newplan.logical.Util.translateSchema(schema);
                System.out.println(alias + ": " + s.toString());
                return s;
View Full Code Here


     * @throws IOException
     */
    public Schema dumpSchemaNested(String alias, String nestedAlias) throws IOException {
        Operator op = getOperatorForAlias( alias );
        if( op instanceof LOForEach ) {
            LogicalSchema nestedSc = ((LOForEach)op).dumpNestedSchema(alias, nestedAlias);
            if (nestedSc!=null) {
                Schema s = org.apache.pig.newplan.logical.Util.translateSchema(nestedSc);
                System.out.println(alias+ "::" + nestedAlias + ": " + s.toString());
                return s;
            }
View Full Code Here

            }
        }

        // check if a relational operator contains all of the specified uids
        private boolean hasAll(LogicalRelationalOperator op, Set<Long> uids) throws FrontendException {
            LogicalSchema schema = op.getSchema();
            if (schema==null)
                return false;
            for(long uid: uids) {
                if (schema.findField(uid) == -1) {
                    return false;
                }
            }

            return true;
View Full Code Here

    @Override
    public LogicalSchema.LogicalFieldSchema getFieldSchema() throws FrontendException {
        if (fieldSchema!=null)
            return fieldSchema;
       
        LogicalSchema inputSchema = new LogicalSchema();
        List<Operator> succs = plan.getSuccessors(this);

        if (succs!=null) {
            for(Operator lo : succs){
                if (((LogicalExpression)lo).getFieldSchema()==null) {
                    inputSchema = null;
                    break;
                }
                inputSchema.addField(((LogicalExpression)lo).getFieldSchema());
            }
        }

        // Since ef only set one time, we never change its value, so we can optimize it by instantiate only once.
        // This significantly optimize the performance of frontend (PIG-1738)
View Full Code Here

    LogicalRelationalOperator join = null;
    LogicalRelationalOperator store = null;   
   
    private void prep() {
        plan = new LogicalPlan();
        LogicalSchema schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("name", null, DataType.CHARARRAY));
        schema.addField(new LogicalSchema.LogicalFieldSchema("age", null, DataType.INTEGER));   
        schema.getField(0).uid = 1;
        schema.getField(1).uid = 2;
        schema.getField(2).uid = 3;
        LogicalRelationalOperator l1 = new LOLoad(null, schema, plan, null);
        l1.setAlias("A");
        plan.add(l1);

        schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("dept", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("salary", null, DataType.FLOAT));   
        schema.getField(0).uid = 4;
        schema.getField(1).uid = 5;
        schema.getField(2).uid = 6;
        LogicalRelationalOperator l2 = new LOLoad(null, schema, plan, null);
        l2.setAlias("B");
        plan.add(l2);
       
        MultiMap<Integer, LogicalExpressionPlan> joinPlans = new MultiMap<Integer, LogicalExpressionPlan>();
View Full Code Here

  // dimensions specified by the user, specified columns will be attached
  // to CubeDimension/RollupDimension UDF and rest will be pushed down
  List<Operator> inpOpers = foreach.getPlan().getPredecessors(foreach);
  List<LogicalExpressionPlan> allExprPlan = new ArrayList<LogicalExpressionPlan>();
  for (Operator oper : inpOpers) {
      LogicalSchema schema = new LogicalSchema();
      schema = ((LogicalRelationalOperator) oper).getSchema();

      if (schema != null) {
    ArrayList<LogicalFieldSchema> fields = (ArrayList<LogicalFieldSchema>) schema
            .getFields();
    for (int i = 0; i < fields.size(); i++) {
        LogicalExpressionPlan lEplan = new LogicalExpressionPlan();
        new ProjectExpression(lEplan, i, fields.get(i).alias, null, gen);
        allExprPlan.add(lEplan);
View Full Code Here

      for (Operator oper : opers) {

    // add a logical schema for dimensions that are pushed from
    // predecessor of cube/rollup
    if (oper instanceof ProjectExpression) {
        LogicalSchema output = new LogicalSchema();
        output.addField(new LogicalFieldSchema(
          ((ProjectExpression) oper).getColAlias(), null, DataType.NULL));
        genOutputSchema.add(output);
    } else if (oper instanceof UserFuncExpression) {
        // add logical schema for dimensions specified in
        // cube/rollup operator
        LogicalSchema output = new LogicalSchema();
        for (Operator op : ((UserFuncExpression) oper).getPlan().getSinks()) {
      output.addField(new LogicalFieldSchema(((ProjectExpression) op)
              .getFieldSchema()));
        }
        genOutputSchema.add(output);
    }
View Full Code Here

        LogicalPlan innerPlan = (LogicalPlan)gen.getPlan();
        ArrayList<Operator> inputs = new ArrayList<Operator>();
        int idx = 0;
        for( LogicalExpressionPlan exprPlan : exprPlans ) {
            LogicalExpression expr = (LogicalExpression)exprPlan.getSources().get(0);
            LogicalSchema userSchema = schemas.get(idx);
            if (userSchema == null && expr.hasFieldSchema()) {
                LogicalSchema ls = new LogicalSchema();
                try {
                    ls.addField(expr.getFieldSchema());
                    schemas.set(idx, ls);
                } catch (FrontendException e) {
                    // if we get an exception, then we have no schema to set
                }
            }
View Full Code Here

        }
    }

    static public void checkQueryOutputsAfterSortRecursive(Iterator<Tuple> actualResultsIt,
            String[] expectedResArray, String schemaString) throws IOException {
        LogicalSchema resultSchema = org.apache.pig.impl.util.Utils.parseSchema(schemaString);
        checkQueryOutputsAfterSortRecursive(actualResultsIt, expectedResArray, resultSchema);
    }
View Full Code Here

    LogicalRelationalOperator join = null;
    LogicalRelationalOperator store = null;   
   
    private void prep() {
        plan = new LogicalPlan();
        LogicalSchema schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("name", null, DataType.CHARARRAY));
        schema.addField(new LogicalSchema.LogicalFieldSchema("age", null, DataType.INTEGER));   
        schema.getField(0).uid = 1;
        schema.getField(1).uid = 2;
        schema.getField(2).uid = 3;
        LogicalRelationalOperator l1 = new LOLoad(schema, plan);
        l1.setAlias("A");
        plan.add(l1);

        schema = new LogicalSchema();
        schema.addField(new LogicalSchema.LogicalFieldSchema("id", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("dept", null, DataType.INTEGER));
        schema.addField(new LogicalSchema.LogicalFieldSchema("salary", null, DataType.FLOAT));   
        schema.getField(0).uid = 4;
        schema.getField(1).uid = 5;
        schema.getField(2).uid = 6;
        LogicalRelationalOperator l2 = new LOLoad(schema, plan);
        l2.setAlias("B");
        plan.add(l2);
       
        MultiMap<Integer, LogicalExpressionPlan> joinPlans = new MultiMap<Integer, LogicalExpressionPlan>();
View Full Code Here

TOP

Related Classes of org.apache.pig.newplan.logical.relational.LogicalSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.