@Override public T deserialize(T reuse, DataInputView source) throws IOException { reuse.readFields(source); return reuse; }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { ensureReferenceInstantiated(); ensureTempReferenceInstantiated(); reference.readFields(firstSource); tempReference.readFields(secondSource); int comp = reference.compareTo(tempReference); return ascendingComparison ? comp : -comp; }
private void loadOptimized(MapJoinBytesTableContainer container, ObjectInputStream in, Writable key, Writable value) throws Exception { int numKeys = in.readInt(); for (int keyIndex = 0; keyIndex < numKeys; keyIndex++) { key.readFields(in); long numRows = in.readLong(); for (long rowIndex = 0L; rowIndex < numRows; rowIndex++) { value.readFields(in); container.putRow(key, value); } } }
/** * Deserialization of Hadoop Writable object. * * @param writable Writable object to deserialize to. * @param bytes byte array to deserialize. */ public static void deserialize(Writable writable, byte[] bytes) throws IOException { DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(bytes)); writable.readFields(dataIn); dataIn.close(); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // read the parent fields and the final fields in.defaultReadObject(); try { Class<? extends Writable> writableSplit = splitType.asSubclass(Writable.class); mapreduceInputSplit = (org.apache.hadoop.mapreduce.InputSplit) WritableFactories.newInstance(writableSplit); } catch (Exception e) { throw new RuntimeException("Unable to instantiate the Hadoop InputSplit", e); } ((Writable) mapreduceInputSplit).readFields(in); } }
public static void decodeWritable(Writable w, String idStr) throws IOException { DataInputStream in = new DataInputStream(new ByteArrayInputStream(Base64.decodeBase64(idStr))); w.readFields(in); }
public void read(MapJoinObjectSerDeContext context, ObjectInputStream in, Writable container) throws IOException, SerDeException { container.readFields(in); read(context, container); }
public void read(MapJoinObjectSerDeContext context, ObjectInputStream in, Writable container) throws IOException, SerDeException { long numRows = in.readLong(); for (long rowIndex = 0L; rowIndex < numRows; rowIndex++) { container.readFields(in); read(context, container); } }
@Override public void readFields(DataInput in) throws IOException { values = new Writable[in.readInt()]; // construct values for (int i = 0; i < values.length; i++) { Writable value = WritableFactories.newInstance(valueClass); value.readFields(in); // read a value values[i] = value; // store it in values } }
@Override public void readFields(DataInput in) throws IOException { type = in.readByte(); Class<? extends Writable> clazz = getTypes()[type & 0xff]; try { instance = ReflectionUtils.newInstance(clazz, conf); } catch (Exception e) { e.printStackTrace(); throw new IOException("Cannot initialize the class: " + clazz); } instance.readFields(in); }
@Override public Writable deserialize(Writable w) throws IOException { Writable writable; if (w == null) { writable = (Writable) ReflectionUtils.newInstance(writableClass, getConf()); } else { writable = w; } writable.readFields(dataIn); return writable; }
public void read(MapJoinObjectSerDeContext context, ObjectInputStream in, Writable container) throws IOException, SerDeException { long numRows = in.readLong(); for (long rowIndex = 0L; rowIndex < numRows; rowIndex++) { container.readFields(in); read(context, container); } }
@Override public void copy(DataInputView source, DataOutputView target) throws IOException { ensureInstanceInstantiated(); copyInstance.readFields(source); copyInstance.write(target); }
/** {@inheritDoc} */ @Override public Object read(DataInput in, @Nullable Object obj) throws IgniteCheckedException { Writable w = obj == null ? U.newInstance(cls) : cls.cast(obj); try { w.readFields(in); } catch (IOException e) { throw new IgniteCheckedException(e); } return w; }
@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); }
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); } }
private void read(long ptr, int size, Writable w) { assert size == 4 : size; GridUnsafe.copyOffheapHeap(ptr, buf, GridUnsafe.BYTE_ARR_OFF, size); dataInput.bytes(buf, size); try { w.readFields(dataInput); } catch (IOException e) { throw new RuntimeException(e); } } });
private void read(long ptr, int size, Writable w) { assert size == 4 : size; GridUnsafe.copyOffheapHeap(ptr, buf, GridUnsafe.BYTE_ARR_OFF, size); dataInput.bytes(buf, size); try { w.readFields(dataInput); } catch (IOException e) { throw new RuntimeException(e); } } });