@Override public void write(DataOutput out) throws IOException { DataReaderWriter.writeDatum(out, filename); DataReaderWriter.writeDatum(out, offset); }
@Override public void write(WritableComparable wc, Tuple t) throws IOException, InterruptedException { // we really only want to write the tuple (value) out here out.write(RECORD_1); out.write(RECORD_2); out.write(RECORD_3); DataReaderWriter.writeDatum(out, t); }
public byte[] toBytes(Double d) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, d); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting double to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Float f) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, f); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting float to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Long l) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, l); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting long to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(DateTime dt) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, dt); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting datetime to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
@Override public void write(DataOutput out) throws IOException { out.writeByte(DataType.TUPLE); int sz = size(); out.writeInt(sz); for (int i = 0; i < sz; i++) { DataReaderWriter.writeDatum(out, mFields.get(i)); } }
public byte[] toBytes(String s) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, s); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting chararray to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Boolean b) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, b); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting boolean to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Map<String, Object> m) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, m); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting map to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(DataBag bag) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, bag); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting bag to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Integer i) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, i); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting int to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Tuple t) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, t); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting tuple to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
out.writeInt(sz); for (int i = 0; i < sz; i++) { DataReaderWriter.writeDatum(out, t.get(i)); Iterator<Tuple> it = bag.iterator(); while (it.hasNext()) { DataReaderWriter.writeDatum(out, it.next()); while (i.hasNext()) { Map.Entry<String, Object> entry = i.next(); writeDatum(out, entry.getKey()); writeDatum(out, entry.getValue()); while (i.hasNext()) { Map.Entry<Object, Object> entry = i.next(); writeDatum(out, entry.getKey()); writeDatum(out, entry.getValue()); out.writeByte(DataType.GENERIC_WRITABLECOMPARABLE); writeDatum(out, val.getClass().getName()); Writable writable = (Writable)val; writable.write(out);