/** * * @param messageValueFactory message value factory * @param pointers pointers to messages in buffer * @param msgBuffer holds the byte arrays of serialized messages */ public PointerListMessagesIterable(MessageValueFactory<M> messageValueFactory, LongArrayList pointers, ExtendedByteArrayOutputBuffer msgBuffer) { this.messageValueFactory = messageValueFactory; this.pointers = pointers; this.msgBuffer = msgBuffer; // TODO - if needed implement same for Safe as well messageReader = new UnsafeReusableByteArrayInput(); }
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); }
/** * 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)); } }
new KryoWritableWrapper<>(); WritableUtils.fromByteArrayUnsafe( merged, wrapper, new UnsafeReusableByteArrayInput()); return wrapper.get();
/** * 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(); } }
@Override public void doRequest(ServerData serverData) { UnsafeByteArrayOutputStream reusedOut = new UnsafeByteArrayOutputStream(); UnsafeReusableByteArrayInput reusedIn = new UnsafeReusableByteArrayInput();