/** * 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); }
/** * 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; }
/** * 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; }
public synchronized void afterWorkerBeforeMaster() { broadcastMap.clear(); reducedMap.clear(); for (Entry<String, Reducer<Object, Writable>> entry : reducerMap.entrySet()) { Writable value = entry.getValue().getCurrentValue(); if (runAllChecks) { Writable newValue = entry.getValue().createInitialValue(); WritableUtils.copyInto(value, newValue); value = newValue; } reducedMap.put(entry.getKey(), value); } reducerMap.clear(); } }
for (Vertex<I, V, E> vertex : graph) { V value = conf.createVertexValue(); WritableUtils.copyInto(vertex.getValue(), value); vertex.setValue(value);