@Override public T copy(Kryo kryo, T original) { return WritableUtils.createCopy(original); }
@Override public void readFields(DataInput in) throws IOException { messageClass = WritableUtils.readClass(in); messageValueFactoryClass = WritableUtils.readClass(in); messageCombinerClass = WritableUtils.readClass(in); messageClassModified = in.readBoolean(); messageEncodeAndStoreType = messageEncodeAndStoreType.values()[in.readByte()]; } }
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeClass(aggregatorClass, out); }
@Override public void readFields(DataInput input) throws IOException { computationClass = WritableUtils.readClass(input); incomingMessageClasses = WritableUtils.readWritableObject(input, conf); outgoingMessageClasses = WritableUtils.readWritableObject(input, conf); }
@Override public void write(DataOutput output) throws IOException { WritableUtils.writeClass(computationClass, output); WritableUtils.writeWritableObject(incomingMessageClasses, output); WritableUtils.writeWritableObject(outgoingMessageClasses, output); }
/** * Create a copy of Writable object, by serializing and deserializing it. * * @param original Original value of which to make a copy * @param outputClass Expected copy class, needs to match original * @param conf Configuration * @return Copy of the original value * @param <T> Type of the object */ public static final <T extends Writable> T createCopy(T original, Class<? extends T> outputClass, ImmutableClassesGiraphConfiguration conf) { T result = WritableUtils.createWritable(outputClass, conf); copyInto(original, result); return result; }
@Override public void readFields(DataInput in) throws IOException { reduce1 = WritableUtils.readWritableObject(in, null); reduce2 = WritableUtils.readWritableObject(in, null); } }
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeWritableObject(reduce1, out); WritableUtils.writeWritableObject(reduce2, out); }
String name = input.readUTF(); GlobalCommType type = GlobalCommType.values()[input.readByte()]; Writable value = WritableUtils.readWritableObject(input, conf); if (type == GlobalCommType.SPECIAL_COUNT) { aggregatorData.receivedRequestCountFromMaster( ReduceOperation<Object, Writable> reduceOpCopy = (ReduceOperation<Object, Writable>) WritableUtils.createCopy(reusedOut, reusedIn, value, conf);
for (Vertex<I, V, E> vertex : graph) { V value = conf.createVertexValue(); WritableUtils.copyInto(vertex.getValue(), value); vertex.setValue(value); vertex.setEdges((Iterable) WritableUtils.createCopy( (Writable) vertex.getEdges(), conf.getOutEdgesClass(), conf)); blockMasterLogic = (BlockMasterLogic) WritableUtils.createCopy( new KryoWritableWrapper<>(blockMasterLogic), KryoWritableWrapper.class,
/** * Copy {@code from} into {@code to}, by serializing and deserializing it. * Since it is creating streams inside, it's mostly useful for * tests/non-performant code. * * @param from Object to copy from * @param to Object to copy into * @param <T> Type of the object */ public static <T extends Writable> void copyInto(T from, T to) { copyInto(from, to, false); }
/** * Instantiate a new Writable, checking for NullWritable along the way. * * @param klass Class * @param <W> type * @return new instance of class */ public static <W extends Writable> W createWritable(Class<W> klass) { return createWritable(klass, null); }
/** * Set object in a conf option using kryo * * @param object Object to set * @param confOption Conf option * @param conf Configuration * @param <T> Type of the object */ public static <T> void setObjectKryo(T object, String confOption, Configuration conf) { setByteArray(WritableUtils.toByteArrayUnsafe( new KryoWritableWrapper<>(object)), confOption, conf); }
WritableUtils.fromByteArrayUnsafe( merged, wrapper, new UnsafeReusableByteArrayInput()); return wrapper.get();
@Override public void readFields(DataInput in) throws IOException { fixedSize = in.readInt(); elementReduceOp = WritableUtils.readWritableObject(in, null); init(); }
@Override public void write(DataOutput out) throws IOException { out.writeInt(fixedSize); WritableUtils.writeWritableObject(elementReduceOp, out); }
/** * Create a copy of Writable object, by serializing and deserializing it. * * @param original Original value of which to make a copy * @param classFactory Factory to create new empty object from * @param conf Configuration * @return Copy of the original value * @param <T> Type of the object */ public static final <T extends Writable> T createCopy(T original, ValueFactory<T> classFactory, ImmutableClassesGiraphConfiguration conf) { T result = classFactory.newInstance(); copyInto(original, result); return result; }
@Override public I newInstance() { return WritableUtils.createWritable(vertexIdClass, conf); } }
MasterCompute master, BlockWorkerPieces<S> nextWorkerPieces) { Writable toBroadcast = new KryoWritableWrapper<>(nextWorkerPieces); byte[] data = WritableUtils.toByteArrayUnsafe(toBroadcast);
/** * Get object from a conf option using kryo * * @param confOption Conf option * @param conf Configuration * @return Object from conf * @param <T> Type of the object */ public static <T> T getObjectKryo(String confOption, Configuration conf) { KryoWritableWrapper<T> wrapper = new KryoWritableWrapper<>(); WritableUtils.fromByteArrayUnsafe( getByteArray(confOption, conf), wrapper, new UnsafeReusableByteArrayInput()); return wrapper.get(); } }