@Override public T copy(Kryo kryo, T original) { return WritableUtils.createCopy(original); }
/** * Create a copy of Writable object, by serializing and deserializing it. * * @param original Original value of which to make a copy * @return Copy of the original value * @param <T> Type of the object */ public static final <T extends Writable> T createCopy(T original) { return (T) createCopy(original, original.getClass(), null); }
private M maybeMessageCopy(M message) { M messageCopy = WritableUtils.createCopy( message, messageFactory, conf); return ThreadLocalRandom.current().nextBoolean() ? messageCopy : message; }
private void checkIdCopy(I id) { WritableUtils.createCopy(id, conf.getVertexIdFactory(), conf); }
public List<Writable> takeWorkerMessages() { if (previousWorkerMessages != null) { List<Writable> ret = new ArrayList<>(previousWorkerMessages.size()); for (Writable message : previousWorkerMessages) { // Use message copies probabilistically, to catch both not serializing // some fields, and storing references from message object itself // (which can be reusable). ret.add(runAllChecks && ThreadLocalRandom.current().nextBoolean() ? WritableUtils.createCopy(message) : message); } previousWorkerMessages = null; if (runAllChecks) { Collections.shuffle(ret); } return ret; } return Collections.emptyList(); }
private <W extends Writable> W copyWritable(W writable) { if (reusedOut == null) { reusedOut = new UnsafeByteArrayOutputStream(); } if (reusedIn == null) { reusedIn = new UnsafeReusableByteArrayInput(); } return WritableUtils.createCopy(reusedOut, reusedIn, writable, null); }
/** * Wrap object with KryoWritableWrapper, create a writable copy of it, * and then unwrap it, allowing any object to be copied. * * @param object Object to copy * @return copy of the object * @param <T> Type of the object */ public static <T> T wrapAndCopy(T object) { return WritableUtils.createCopy(new KryoWritableWrapper<>(object)).get(); } }
/** * Constructor * * Creates new instances of all reducers from * {@link WorkerAggregatorHandler} */ public ThreadLocalWorkerGlobalCommUsage() { threadReducerMap = Maps.newHashMapWithExpectedSize( WorkerAggregatorHandler.this.reducerMap.size()); UnsafeByteArrayOutputStream out = new UnsafeByteArrayOutputStream(); UnsafeReusableByteArrayInput in = new UnsafeReusableByteArrayInput(); for (Entry<String, Reducer<Object, Writable>> entry : reducerMap.entrySet()) { ReduceOperation<Object, Writable> globalReduceOp = entry.getValue().getReduceOp(); ReduceOperation<Object, Writable> threadLocalCopy = WritableUtils.createCopy(out, in, globalReduceOp, conf); threadReducerMap.put(entry.getKey(), new Reducer<>(threadLocalCopy)); } }
ReduceOperation<Object, Writable> reduceOpCopy = (ReduceOperation<Object, Writable>) WritableUtils.createCopy(reusedOut, reusedIn, value, conf);
vertex.setValue(value); vertex.setEdges((Iterable) WritableUtils.createCopy( (Writable) vertex.getEdges(), conf.getOutEdgesClass(), conf)); blockMasterLogic = (BlockMasterLogic) WritableUtils.createCopy( new KryoWritableWrapper<>(blockMasterLogic), KryoWritableWrapper.class,
if (getPartition(target).getVertex(target) == null) { I copyId = WritableUtils.createCopy(target);