Examples of LogicalFieldSchema


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

        @Override
        public void visit(LOLoad load) throws FrontendException {
            if( load.getSchema() != null ) {
                Map<Integer,Set<String>> annotation = new HashMap<Integer,Set<String>>();
                for( int i=0; i<load.getSchema().size(); i++) {
                    LogicalFieldSchema field = load.getSchema().getField(i);
                    if( inputUids.containsKey( field.uid ) ) {
                        annotation.put(i, inputUids.get( field.uid ) );
                    }
                }
                load.annotate(REQUIRED_MAPKEYS, annotation);
View Full Code Here

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

    // 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

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

                            projExpr.setAttachedRelationalOp( op );
                        }
                    }
                }
                LogicalExpression root = (LogicalExpression)planCopy.getSources().get( 0 );// get the root of the plan
                LogicalFieldSchema schema;
                try {
                    schema = root.getFieldSchema();
                    if (schema.alias == null) {
                        schema.alias = colAlias;
                    }
View Full Code Here

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

     * @param fs fieldSchema of expecteResArray
     * @throws IOException
     */
    static public void checkQueryOutputsAfterSortRecursive(Iterator<Tuple> actualResultsIt,
            String[] expectedResArray, LogicalSchema schema) throws IOException {
        LogicalFieldSchema fs = new LogicalFieldSchema("tuple", schema, DataType.TUPLE);
        ResourceFieldSchema rfs = new ResourceFieldSchema(fs);

        LoadCaster caster = new Utf8StorageConverter();
        List<Tuple> actualResList = new ArrayList<Tuple>();
        while(actualResultsIt.hasNext()){
View Full Code Here

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

                for (LogicalSchema.LogicalFieldSchema fs : mUserDefinedSchema.get(i).getFields()) {
                    mUserDefinedSchemaCopy.addField(fs.deepCopy());
                }
            }
           
            LogicalFieldSchema fieldSchema = null;
           
            // schema of the expression after flatten
            LogicalSchema expSchema = null;
           
            if (exp.getFieldSchema()!=null) {
           
                fieldSchema = exp.getFieldSchema().deepCopy();
               
                expSchema = new LogicalSchema();
                if ((fieldSchema.type != DataType.TUPLE && fieldSchema.type != DataType.BAG)||!flattenFlags[i]) {
                    // if type is primitive, just add to schema
                    if (fieldSchema!=null)
                        expSchema.addField(fieldSchema);
                    else
                        expSchema = null;
                } else {
                    // if bag/tuple don't have inner schema, after flatten, we don't have schema for the entire operator
                    if (fieldSchema.schema==null) {
                        expSchema = null;
                    }
                    else {
                     // if we come here, we get a BAG/Tuple with flatten, extract inner schema of the tuple as expSchema
                        List<LogicalSchema.LogicalFieldSchema> innerFieldSchemas = new ArrayList<LogicalSchema.LogicalFieldSchema>();
                        if (flattenFlags[i]) {
                            if (fieldSchema.type == DataType.BAG) {
                                // if it is bag, get the schema of tuples
                                if (fieldSchema.schema!=null) {
                                    if (fieldSchema.schema.getField(0).schema!=null)
                                        innerFieldSchemas = fieldSchema.schema.getField(0).schema.getFields();
                                    for (LogicalSchema.LogicalFieldSchema fs : innerFieldSchemas) {
                                        fs.alias = fs.alias == null ? null : fieldSchema.alias + "::" + fs.alias;
                                    }
                                }
                            } else { // DataType.TUPLE
                                innerFieldSchemas = fieldSchema.schema.getFields();
                                for (LogicalSchema.LogicalFieldSchema fs : innerFieldSchemas) {
                                    fs.alias = fs.alias == null ? null : fieldSchema.alias + "::" + fs.alias;
                                }
                            }
                           
                            for (LogicalSchema.LogicalFieldSchema fs : innerFieldSchemas)
                                expSchema.addField(fs);
                        }
                        else
                            expSchema.addField(fieldSchema);
                    }
                }
            }
           
            // Merge with user defined schema
            if (expSchema!=null && expSchema.size()==0)
                expSchema = null;
            LogicalSchema planSchema = new LogicalSchema();
            if (mUserDefinedSchemaCopy!=null) {
                LogicalSchema mergedSchema = new LogicalSchema();
                // merge with userDefinedSchema
                if (expSchema==null) {
                    // Use user defined schema
                    for (LogicalFieldSchema fs : mUserDefinedSchemaCopy.getFields()) {
                        fs.stampFieldSchema();
                        mergedSchema.addField(new LogicalFieldSchema(fs));
                    }
                    if(mergedSchema.size() == 1 && mergedSchema.getField(0).type == DataType.NULL){
                        //this is the use case where a new alias has been specified by user
                        mergedSchema.getField(0).type = DataType.BYTEARRAY;
                    }
View Full Code Here

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

                // 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

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

                            projExpr.setAttachedRelationalOp( op );
                        }
                    }
                }
                LogicalExpression root = (LogicalExpression)planCopy.getSources().get( 0 );// get the root of the plan
                LogicalFieldSchema schema;
                try {
                    schema = root.getFieldSchema();
                    if (schema.alias == null) {
                        schema.alias = colAlias;
                    }
View Full Code Here

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

            // No cached uid. Allocate one, and locate and cache all inputs.
            if (uid==-1) {
                uid = LogicalExpression.getNextUid();
                for (LogicalSchema inputSchema : inputSchemas) {
                    long inputUid;
                    LogicalFieldSchema matchedInputFieldSchema;
                  if (onSchema) {
                      matchedInputFieldSchema = inputSchema.getFieldSubNameMatch(mergedSchema.getField(i).alias);
                        if (matchedInputFieldSchema!=null) {
                            inputUid = matchedInputFieldSchema.uid;
                            uidMapping.add(new Pair<Long, Long>(uid, inputUid));
View Full Code Here

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

            if(schema.size() == 0)
                return null;
            funcSpec = uid2LoadFuncMap.get(schema.getField(0).uid);
            if(funcSpec != null) {
                for(int i=1; i<schema.size(); i++){
                    LogicalFieldSchema fs = schema.getField(i);
                    if(! haveIdenticalCasters(funcSpec,
                            uid2LoadFuncMap.get(fs.uid))){
                        //all uid are not associated with same func spec, there is no
                        // single func spec that represents all the fields
                        funcSpec = null;
View Full Code Here

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

                + split;
            throw new VisitorException(split, msg,2261, PigException.BUG) ;
        }

        for(int i=0; i<inputSch.size(); i++){
            LogicalFieldSchema inField = inputSch.getField(i);
            LogicalFieldSchema outField = outSchema.getField(i);
            if(uid2LoadFuncMap.get(inField.uid) != null){
                addUidLoadFuncToMap(outField.uid, uid2LoadFuncMap.get(inField.uid));
            }
        }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.