@SuppressWarnings("unchecked") protected static Map<String, Object> read(DataInput in, Map<String, Object> v) throws IOException { return (Map<String, Object>) bis.readDatum(in); }
protected static BigDecimal read(DataInput in, BigDecimal v) throws IOException { return (BigDecimal) bis.readDatum(in); }
@Override public void readFields(DataInput in) throws IOException { value = (BigDecimal)bis.readDatum(in); }
protected static BigInteger read(DataInput in, BigInteger v) throws IOException { return (BigInteger) bis.readDatum(in); }
@Override public void readFields(DataInput in) throws IOException { value = (BigInteger)bis.readDatum(in); }
protected static DataBag read(DataInput in, DataBag v) throws IOException { return (DataBag) bis.readDatum(in); }
@Override public Object readDatum(DataInput in) throws IOException, ExecException { // Read the data type byte b = in.readByte(); return readDatum(in, b); }
private Object readBigInteger(DataInput in) throws IOException { return new BigInteger((String)readDatum(in)); }
private Object readBigDecimal(DataInput in) throws IOException { return new BigDecimal((String)readDatum(in)); }
private Map<String, Object> readMap(DataInput in, byte type) throws IOException { int size; switch (type) { case TINYMAP: size = in.readUnsignedByte(); break; case SMALLMAP: size = in.readUnsignedShort(); break; case MAP: size = in.readInt(); break; default: { int errCode = 2220; String msg = "Unexpected data while reading map" + "from binary file."; throw new ExecException(msg, errCode, PigException.BUG); } } Map<String, Object> m = new HashMap<String, Object>(size); for (int i = 0; i < size; i++) { String key = (String) readDatum(in); m.put(key, readDatum(in)); } return m; }
private WritableComparable readWritable(DataInput in) throws IOException { String className = (String) readDatum(in); // create the writeable class . It needs to have a default constructor Class<?> objClass = null; try { objClass = Class.forName(className); } catch (ClassNotFoundException e) { throw new IOException("Could not find class " + className + ", while attempting to de-serialize it ", e); } WritableComparable writable = null; try { writable = (WritableComparable) objClass.newInstance(); } catch (Exception e) { String msg = "Could create instance of class " + className + ", while attempting to de-serialize it. (no default constructor ?)"; throw new IOException(msg, e); } // read the fields of the object from DataInput writable.readFields(in); return writable; }
@Override public void addColsToTuple(DataInput in, Tuple t) throws IOException { byte type = in.readByte(); int sz = getTupleSize(in, type); for (int i = 0; i < sz; i++) { t.append(readDatum(in)); } }
public static Tuple readGenericTuple(DataInput in, byte type) throws IOException { int sz = pigSerializer.getTupleSize(in, type); Tuple t = mTupleFactory.newTuple(sz); for (int i = 0; i < sz; i++) { t.set(i, pigSerializer.readDatum(in)); } return t; }
private DataBag readBag(DataInput in, byte type) throws IOException { DataBag bag = mBagFactory.newDefaultBag(); long size; // determine size of bag switch (type) { case TINYBAG: size = in.readUnsignedByte(); break; case SMALLBAG: size = in.readUnsignedShort(); break; case BAG: size = in.readLong(); break; default: int errCode = 2219; String msg = "Unexpected data while reading bag " + "from binary file."; throw new ExecException(msg, errCode, PigException.BUG); } for (long i = 0; i < size; i++) { try { Object o = readDatum(in); bag.add((Tuple) o); } catch (ExecException ee) { throw ee; } } return bag; }