Package org.apache.pig.impl.logicalLayer.schema

Examples of org.apache.pig.impl.logicalLayer.schema.TupleSchema.numFields()


        }
        TupleSchema schema = op.outputSchema();
       
        // first of all, we are required to guarantee that there is at least one output tuple
        if (outputConstraints.cardinality() == 0 && inputData.cardinality() == 0) {
            outputConstraints.add(new Tuple(schema.numFields()));   // add an output constraint for one tuple
        }
       
        // create example tuple to steal values from when we encounter "don't care" fields (i.e. null fields)
        Tuple exampleTuple;
        if (inputData.cardinality() > 0) {
View Full Code Here


        if (inputData.cardinality() > 0) {
            // select first tuple from input data
            exampleTuple = inputData.iterator().next();
        } else {
            // input data is empty, so make up a tuple
            Tuple exampleT = new Tuple(schema.numFields());
            exampleTuple = new ExampleTuple();
            exampleTuple.copyFrom(exampleT);
            for (int i = 0; i < exampleTuple.arity(); i++) exampleTuple.setField(i, "0");
        }
       
View Full Code Here

        // (while synthesizing individual fields, try to match fields that exist in the real data)
        for (Iterator<Tuple> it = outputConstraints.iterator(); it.hasNext(); ) {
            Tuple outputConstraint = it.next();
           
            // sanity check:
            if (outputConstraint.arity() != schema.numFields()) throw new RuntimeException("Internal error: incorrect number of fields in constraint tuple.");
           
            Tuple inputT = new Tuple(outputConstraint.arity());
            ExampleTuple inputTuple = new ExampleTuple();
            inputTuple.copyFrom(inputT);
            for (int i = 0; i < inputTuple.arity(); i++) {
View Full Code Here

              LogicalOperator lo = opTable.get(opKey);
             
              if (lo != null && lo.outputSchema() != null &&
                  lo.outputSchema().numFields() > current) {
                  longest = lo.outputSchema();
                  current = longest.numFields();
                }
            }
            schema = longest.copy();
        }
View Full Code Here

            if (a == null) mStream.print("$" + pos);
            else mStream.print(a);
        } else if (schema instanceof TupleSchema) {
            mStream.print("(");
            TupleSchema ts = (TupleSchema)schema;
            int sz = ts.numFields();
            for (int j = 0; j < sz; j++) {
                if (j != 0) mStream.print(", ");
                Schema s = ts.schemaFor(j);
                if (s == null) mStream.print("$" + j);
                else printSchema(s, j);
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.