@Override public void serialize(T record, DataOutputView target) throws IOException { record.write(target); }
private void writeObject(ObjectOutputStream out) throws IOException { // serialize the parent fields and the final fields out.defaultWriteObject(); // write the input split ((Writable) mapreduceInputSplit).write(out); }
@Override public void write(DataOutput out) throws IOException { out.writeInt(values.length); // write values for (int i = 0; i < values.length; i++) { values[i].write(out); } }
@Override public void write(DataOutput out) throws IOException { if (type == NOT_SET || instance == null) throw new IOException("The GenericWritable has NOT been set correctly. type=" + type + ", instance=" + instance); out.writeByte(type); instance.write(out); }
public static String encodeWritable(Writable key) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); key.write(dos); dos.flush(); return Base64.encodeBase64URLSafeString(bos.toByteArray()); }
public static byte[] toBytes(Writable writable) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bout); writable.write(out); out.close(); bout.close(); return bout.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
/** {@inheritDoc} */ @Override public void write(DataOutput out, Object obj) throws IgniteCheckedException { assert cls.isAssignableFrom(obj.getClass()) : cls + " " + obj.getClass(); try { ((Writable)obj).write(out); } catch (IOException e) { throw new IgniteCheckedException(e); } }
@Override public void copy(DataInputView source, DataOutputView target) throws IOException { ensureInstanceInstantiated(); copyInstance.readFields(source); copyInstance.write(target); }
public void writeWritable(Writable w) throws IOException { DataOutputStream dos = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); dos = new DataOutputStream(baos); WritableUtils.writeString(dos, w.getClass().getName()); w.write(dos); out.writeBytes(baos.toByteArray(), Type.WRITABLE.code); dos.close(); dos = null; } finally { IOUtils.closeStream(dos); } }
@Override public void write(DataOutput output) throws IOException { String partitionInfoString = HCatUtil.serialize(partitionInfo); // write partitionInfo into output WritableUtils.writeString(output, partitionInfoString); WritableUtils.writeString(output, baseMapRedSplit.getClass().getName()); Writable baseSplitWritable = (Writable) baseMapRedSplit; //write baseSplit into output baseSplitWritable.write(output); }
@Override public void process(Object row, int tag) throws HiveException { ObjectInspector rowInspector = inputObjInspectors[0]; try { Writable writableRow = serializer.serialize(row, rowInspector); writableRow.write(buffer); } catch (Exception e) { throw new HiveException(e); } }
@Deprecated public static void cloneWritableInto(Writable dst, Writable src) throws IOException { CopyInCopyOutBuffer buffer = CLONE_BUFFERS.get(); buffer.outBuffer.reset(); src.write(buffer.outBuffer); buffer.moveData(); dst.readFields(buffer.inBuffer); }
@Override public void close(boolean abort) throws IOException { if (out == null) { FileSystem fs = finalOutPath.getFileSystem(jc); out = fs.create(finalOutPath); } for (Writable r : records) r.write(out); records.clear(); out.flush(); out.close(); } };
@Override public void write(MapJoinObjectSerDeContext context, ObjectOutputStream out) throws IOException, SerDeException { AbstractSerDe serde = context.getSerDe(); ObjectInspector objectInspector = context.getStandardOI(); Writable container = serde.serialize(key, objectInspector); container.write(out); }
private <T extends Writable> T copy(T oldWritable, T newWritable) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos); oldWritable.write(out); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInputStream in = new DataInputStream(bais); newWritable.readFields(in); return newWritable; }
private static void writeAndRead(Writable toWrite, Writable toRead) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(baos)){ toWrite.write(dos); } ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); try (DataInputStream dis = new DataInputStream(bais)) { toRead.readFields(dis); } } }
private static void writeAndRead(Writable toWrite, Writable toRead) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(baos)){ toWrite.write(dos); } ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); try (DataInputStream dis = new DataInputStream(bais)) { toRead.readFields(dis); } }
@Override public void write(MapJoinObjectSerDeContext context, ObjectOutputStream out) throws IOException, SerDeException { AbstractSerDe serde = context.getSerDe(); ObjectInspector objectInspector = context.getStandardOI(); Writable container = serde.serialize(key, objectInspector); container.write(out); }
@Override public void flush() throws IOException { if (out == null) { FileSystem fs = path.getFileSystem(options.getConfiguration()); out = fs.create(path); } for (Writable r : records) r.write(out); records.clear(); out.flush(); }