Package org.apache.pig.data

Examples of org.apache.pig.data.DataAtom


        public boolean next (Tuple value)
            throws IOException
        {
            if (!read) {
                value.appendField(new DataAtom(val));
                read = true;
                return true;
            }
            return false;
        }
View Full Code Here


    }
   
    static Datum GetUnequalValue(Datum v, boolean stringOp) {
        if (!(v instanceof DataAtom)) return null;
       
        DataAtom zero = new DataAtom("0");
        if (v.equals(zero)) return new DataAtom("1");
        else return zero;
    }
View Full Code Here

    static Datum GetSmallerValue(Datum v, boolean stringOp) {
        if (!(v instanceof DataAtom)) return null;

        if (stringOp) {
            String val = ((DataAtom) v).strval();
            if (val.length() > 0) return new DataAtom(val.substring(0, val.length()-1));
            else return null;   // don't know how to make a string smaller than the empty string
        } else {
            double val = ((DataAtom) v).numval();
            return new DataAtom(val-1);
        }
    }
View Full Code Here

    static Datum GetLargerValue(Datum v, boolean stringOp) {
        if (!(v instanceof DataAtom)) return null;

        if (stringOp) {
            String val = ((DataAtom) v).strval();
            return new DataAtom(val + "0");
        } else {
            double val = ((DataAtom) v).numval();
            return new DataAtom(val+1);
        }
    }
View Full Code Here

        if ((line = in.readLine(utf8, (byte)'\n')) != null) {
            if (line.length()>0 && line.charAt(line.length()-1)=='\r')
                line = line.substring(0, line.length()-1);

            Tuple t = new Tuple(1);
            t.setField(0, new DataAtom(line));
            return t;
        }
        return null;
    }
View Full Code Here

        }

        // Create a new Tuple with one DataAtom field and return it,
        // ensure that we return 'null' if we didn't get any data
        if (off > 0) {
            return new Tuple(new DataAtom(buffer));
        }
       
        return null;
    }
View Full Code Here

    public void finish() throws IOException {}

    public void putNext(Tuple f) throws IOException {
        // Pick up the first field of the Tuple, then it's
        // raw-bytes and send it out
        DataAtom dAtom = (DataAtom)(f.getAtomField(0));
        byte[] data = dAtom.getValueBytes();
        if (data.length > 0) {
            out.write(dAtom.getValueBytes());
            out.flush();
        }
    }
View Full Code Here

    }

    static public class Initial extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException {
            output.appendField(new DataAtom(max(input)));
        }
View Full Code Here

            Iterator<Tuple> it1 = field1.iterator();
            checkInBag(field2, it1, output);
            Iterator<Tuple> it2 = field2.iterator();
            checkInBag(field1, it2, output);
        } else {
            DataAtom d1 = input.getAtomField(0);
            DataAtom d2 = input.getAtomField(1);
            if (!d1.equals(d2)) {
                output.add(new Tuple(d1));
                output.add(new Tuple(d2));
            }
        }
View Full Code Here

    }

    static public class Initial extends EvalFunc<Tuple> {
        @Override
        public void exec(Tuple input, Tuple output) throws IOException {
            output.appendField(new DataAtom(min(input)));
        }
View Full Code Here

TOP

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

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.