Package org.apache.pig.data

Examples of org.apache.pig.data.TupleFactory


    static public class MapUDF extends EvalFunc<Map<String, Object>> {
        @Override
        public Map<String, Object> exec(Tuple input) throws IOException {

            TupleFactory tupleFactory = TupleFactory.getInstance();
            ArrayList<Object> objList = new ArrayList<Object>();
            objList.add(new Integer(1));
            objList.add(new Double(1.0));
            objList.add(new Float(1.0));
            objList.add(new String("World!"));
            Tuple tuple = tupleFactory.newTuple(objList);

            BagFactory bagFactory = BagFactory.getInstance();
            DataBag bag = bagFactory.newDefaultBag();
            bag.add(tuple);
View Full Code Here


        String num = s.substring( 0, s.length() - 1 );
        return new BigDecimal( num );
    }

    static Tuple buildTuple(List<Object> objList) {
        TupleFactory tf = TupleFactory.getInstance();
        return tf.newTuple( objList );
    }
View Full Code Here

        conf.set(MRConfiguration.TASK_ID, taskId.toString());

        conf.set(MRConfiguration.INPUT_DIR, Util.encodeEscape(outputDir.getAbsolutePath()));
        storage.initialize(conf);

        TupleFactory tupleFactory = TupleFactory.getInstance();
        Tuple seek = tupleFactory.newTuple(2);
        Integer key;
        Tuple read;

        //Seek to 1,1 (not in index). getNext should return 2
        seek.set(0, new Integer(1));
View Full Code Here

     * @return - Tuple appended with special marker string column, num-rows column
     * @throws ExecException
     */
    private Tuple createNumRowTuple(Tuple sample) throws ExecException {
        int sz = (sample == null) ? 0 : sample.size();
        TupleFactory factory = TupleFactory.getInstance();
        Tuple t = factory.newTuple(sz + 2);

        if (sample != null) {
            for(int i=0; i<sample.size(); i++){
                t.set(i, sample.get(i));
            }
View Full Code Here

      // TupleFactory.newTuple(int size) can only support up to Integer.MAX_VALUE
      if (outputTupleSize > Integer.MAX_VALUE) {
        throw new ExecException("Input bag is too large", 105, PigException.INPUT);
      }

      TupleFactory tupleFactory = TupleFactory.getInstance();
      outputTuple = tupleFactory.newTuple((int) outputTupleSize);

      int fieldNum = 0;
      for (Tuple t : inputBag) {
        if (t != null) {
          for (int i = 0; i < t.size(); i++) {
View Full Code Here

      // TupleFactory.newTuple(int size) can only support up to Integer.MAX_VALUE
      if (outputTupleSize > Integer.MAX_VALUE) {
        throw new ExecException("Input bag is too large", 105, PigException.INPUT);
      }

      TupleFactory tupleFactory = TupleFactory.getInstance();
      outputTuple = tupleFactory.newTuple((int) outputTupleSize);

      int fieldNum = 0;
      for (Tuple t : inputBag) {
        if (t != null) {
          for (int i = 0; i < t.size(); i++) {
View Full Code Here

     * @return - Tuple appended with special marker string column, num-rows column
     * @throws ExecException
     */
    private Tuple createNumRowTuple(Tuple sample) throws ExecException {
        int sz = (sample == null) ? 0 : sample.size();
        TupleFactory factory = TupleFactory.getInstance();      
        Tuple t = factory.newTuple(sz + 2);
        if (sample != null) {
            for(int i=0; i<sample.size(); i++){
                t.set(i, sample.get(i));
            }
View Full Code Here

    }
   
    @Test
    public void testRegexExtractAll() throws IOException {
        String matchRegex = "^(.+)\\b\\s+is a\\s+\\b(.+)$";
        TupleFactory tupleFactory = TupleFactory.getInstance();
        Tuple t1 = tupleFactory.newTuple(2);
        t1.set(0,"this is a match");
        t1.set(1, matchRegex);
       
        Tuple t2 = tupleFactory.newTuple(2);
        t2.set(0, "no match");
        t2.set(1, matchRegex);
       
        Tuple t3 = tupleFactory.newTuple(2);
        t3.set(0, null);
        t3.set(1, matchRegex);
    
        RegexExtractAll func = new RegexExtractAll();
        Tuple r = func.exec(t1);
View Full Code Here

        String num = s.substring( 0, s.length() - 1 );
        return new BigDecimal( num );
    }

    static Tuple buildTuple(List<Object> objList) {
        TupleFactory tf = TupleFactory.getInstance();
        return tf.newTuple( objList );
    }
View Full Code Here

        conf.set("mapred.task.id", taskId.toString());

        conf.set("mapred.input.dir", Util.encodeEscape(outputDir.getAbsolutePath()));
        storage.initialize(conf);

        TupleFactory tupleFactory = TupleFactory.getInstance();
        Tuple seek = tupleFactory.newTuple(2);
        Integer key;
        Tuple read;

        //Seek to 1,1 (not in index). getNext should return 2
        seek.set(0, new Integer(1));
View Full Code Here

TOP

Related Classes of org.apache.pig.data.TupleFactory

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.