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

Examples of org.apache.pig.impl.logicalLayer.schema.Schema


    return Math.abs(d);
  }
 
  @Override
  public Schema outputSchema(Schema input) {
        return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
  }
View Full Code Here


     * @see org.apache.pig.EvalFunc#getArgToFuncMapping()
     */
    @Override
    public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
        List<FuncSpec> funcList = new ArrayList<FuncSpec>();
        funcList.add(new FuncSpec(this.getClass().getName(), new Schema(new Schema.FieldSchema(null, DataType.BYTEARRAY))));
        funcList.add(new FuncSpec(DoubleAbs.class.getName()new Schema(new Schema.FieldSchema(null, DataType.DOUBLE))));
        funcList.add(new FuncSpec(FloatAbs.class.getName(),   new Schema(new Schema.FieldSchema(null, DataType.FLOAT))));
        funcList.add(new FuncSpec(IntAbs.class.getName()new Schema(new Schema.FieldSchema(null, DataType.INTEGER))));
        funcList.add(new FuncSpec(LongAbs.class.getName()new Schema(new Schema.FieldSchema(null, DataType.LONG))));
        return funcList;
    }
View Full Code Here

        return sum;
    }

    @Override
    public Schema outputSchema(Schema input) {
        return new Schema(new Schema.FieldSchema(null, DataType.LONG));
    }
View Full Code Here

    String mExpression = null;
    Pattern mPattern = null;
    @Override
    public Schema outputSchema(Schema input) {
        try {
            return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input),
                    DataType.TUPLE));
        } catch (Exception e) {
            return null;
        }
    }
View Full Code Here

    }

    @Override
    public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
        List<FuncSpec> funcList = new ArrayList<FuncSpec>();
        Schema s = new Schema();
        s.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
        s.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
        funcList.add(new FuncSpec(this.getClass().getName(), s));
        return funcList;
    }
View Full Code Here

        }
    }

    @Override
    public Schema outputSchema(Schema input) {
        return new Schema(new Schema.FieldSchema(null, DataType.INTEGER));
    }
View Full Code Here

        }
    }

    @Override
    public Schema outputSchema(Schema input) {
        return new Schema(new Schema.FieldSchema(null, DataType.LONG));
    }
View Full Code Here

        }
    }

    @Override
    public Schema outputSchema(Schema input) {
        return new Schema(new Schema.FieldSchema(null, DataType.INTEGER));
    }
View Full Code Here

     * @see org.apache.pig.EvalFunc#getArgToFuncMapping()
     */
    @Override
    public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
        List<FuncSpec> funcList = new ArrayList<FuncSpec>();
        Schema s = new Schema();
        s.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
        s.add(new Schema.FieldSchema(null, DataType.CHARARRAY));
        funcList.add(new FuncSpec(this.getClass().getName(), s));
        return funcList;
    }
View Full Code Here

     
      for (int i=0; i < inputs.size(); i++) {
        LogicalOperator op = inputs.get(i);
        if (!innerFlags[i]) {
          try {
            Schema s = op.getSchema();
            // if the schema cannot be determined
            if (s == null) {
              throw new FrontendException();
            }
            skj.addSchema(s);
          } catch (FrontendException e) {
            int errCode = 2015;
            String msg = "Couldn't set the schema for outer join" ;
            throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG, e);
          }
        } else {
            // This will never be retrieved. It just guarantees that the index will be valid when
            // MRCompiler is trying to read the schema
            skj.addSchema(null);
        }
      }
     
      currentPlan.add(skj);

      for (LogicalOperator op : inputs) {
        try {
          currentPlan.connect(logToPhyMap.get(op), skj);
        } catch (PlanException e) {
          int errCode = 2015;
          String msg = "Invalid physical operators in the physical plan" ;
          throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG, e);
        }
      }
      logToPhyMap.put(loj, skj);
    }
    else if(loj.getJoinType() == LOJoin.JOINTYPE.REPLICATED) {
         
          int fragment = 0;
          POFRJoin pfrj;
          try {
              boolean isLeftOuter = false;
              // We dont check for bounds issue as we assume that a join
              // involves atleast two inputs
              isLeftOuter = !innerFlags[1];
             
              Tuple nullTuple = null;
              if( isLeftOuter ) {
                  try {
                      // We know that in a Left outer join its only a two way
                      // join, so we assume index of 1 for the right input                     
                      Schema inputSchema = inputs.get(1).getSchema();                     
                     
                      // We check if we have a schema before the join
                      if(inputSchema == null) {
                          int errCode = 1109;
                          String msg = "Input (" + inputs.get(1).getAlias() + ") " +
                          "on which outer join is desired should have a valid schema";
                          throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.INPUT);
                      }
                     
                      // Using the schema we decide the number of columns/fields
                      // in the nullTuple
                      nullTuple = TupleFactory.getInstance().newTuple(inputSchema.size());
                      for(int j = 0; j < inputSchema.size(); j++) {
                          nullTuple.set(j, null);
                      }
                     
                  } catch( FrontendException e ) {
                      int errCode = 2104;
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.logicalLayer.schema.Schema

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.