@Test public void testCopy() { Random rnd = new Random(); KVOperation<Integer, Integer>[] ops = gen.generate(1000); KVOperationSerializer<Integer, Integer> serializer = gen.getSerializer(); for (KVOperation<Integer, Integer> op : ops) { assertEquals(op, serializer.copy(op)); } for (KVOperation<Integer, Integer> op : ops) { assertEquals(op, serializer.copy(op, ops[rnd.nextInt(ops.length)])); } }
@SuppressWarnings("unchecked") @Override public KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to) { KVOperationType type = from.type; to.type = from.type; to.queryID = from.queryID; to.isPartOfTransaction = from.isPartOfTransaction; if (to.isPartOfTransaction) { to.transactionID = from.transactionID; to.dependentKey = copyWithReuse(from.dependentKey, to.dependentKey, keySerializer); to.inputOperationIDs = Arrays.copyOf(from.inputOperationIDs, from.inputOperationIDs.length); } to.hasOpId = from.hasOpId; to.operationID = from.operationID; to.numOpsForKey = from.numOpsForKey; switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case GET: case REMOVE: case MGET: case LOCK: to.key = copyWithReuse(from.key, to.key, keySerializer); break; case SGET: case SMGET: case SGETRES: case SKVRES: case SUPDATE: to.record = copyWithReuse(from.record, to.record, selectors.get(from.queryID).f0); break; default: throw new UnsupportedOperationException(); } switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case SGETRES: case SKVRES: case SUPDATE: to.value = copyWithReuse(from.value, to.value, valueSerializer); break; default: break; } switch (type) { case MGET: case MGETRES: case SMGET: case SKVRES: to.numKeys = from.numKeys; to.index = from.index; break; default: break; } to.keySelector = from.keySelector; to.reducer = from.reducer; return to; }
KVOperationSerializer extends TypeSerializer<KVOperation<K, V>> { @SuppressWarnings("unchecked") @Override public KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to) { KVOperationType type = from.type; to.type = from.type; to.queryID = from.queryID; to.isPartOfTransaction = from.isPartOfTransaction; if (to.isPartOfTransaction) { to.transactionID = from.transactionID; to.dependentKey = copyWithReuse(from.dependentKey, to.dependentKey, keySerializer); to.inputOperationIDs = Arrays.copyOf(from.inputOperationIDs, from.inputOperationIDs.length); } to.hasOpId = from.hasOpId; to.operationID = from.operationID; to.numOpsForKey = from.numOpsForKey; switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case GET: case REMOVE: case MGET: case LOCK: to.key = copyWithReuse(from.key, to.key, keySerializer); break; case SGET: case SMGET: case SGETRES: case SKVRES: case SUPDATE: to.record = copyWithReuse(from.record, to.record, selectors.get(from.queryID).f0); break; default: throw new UnsupportedOperationException(); } switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case SGETRES: case SKVRES: case SUPDATE: to.value = copyWithReuse(from.value, to.value, valueSerializer); break; default: break; } switch (type) { case MGET: case MGETRES: case SMGET: case SKVRES: to.numKeys = from.numKeys; to.index = from.index; break; default: break; } to.keySelector = from.keySelector; to.reducer = from.reducer; return to; } }
KVOperationSerializer extends TypeSerializer<KVOperation<K, V>> { @SuppressWarnings("unchecked") @Override public KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to) { KVOperationType type = from.type; to.type = from.type; to.queryID = from.queryID; to.isPartOfTransaction = from.isPartOfTransaction; if (to.isPartOfTransaction) { to.transactionID = from.transactionID; to.dependentKey = copyWithReuse(from.dependentKey, to.dependentKey, keySerializer); to.inputOperationIDs = Arrays.copyOf(from.inputOperationIDs, from.inputOperationIDs.length); } to.hasOpId = from.hasOpId; to.operationID = from.operationID; to.numOpsForKey = from.numOpsForKey; switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case GET: case REMOVE: case MGET: case LOCK: to.key = copyWithReuse(from.key, to.key, keySerializer); break; case SGET: case SMGET: case SGETRES: case SKVRES: case SUPDATE: to.record = copyWithReuse(from.record, to.record, selectors.get(from.queryID).f0); break; default: throw new UnsupportedOperationException(); } switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case SGETRES: case SKVRES: case SUPDATE: to.value = copyWithReuse(from.value, to.value, valueSerializer); break; default: break; } switch (type) { case MGET: case MGETRES: case SMGET: case SKVRES: to.numKeys = from.numKeys; to.index = from.index; break; default: break; } to.keySelector = from.keySelector; to.reducer = from.reducer; return to; } KVOperationSerializer(TypeSerializer<K> keySerializer, TypeSerializer<V> valueSerializer,
			Map<Short, ReduceFunction<V>> reducers, Map<Short, Tuple2<TypeSerializer, KeySelector>> selectors,
			ExecutionConfig config); }
KVOperationSerializer extends TypeSerializer<KVOperation<K, V>> { @SuppressWarnings("unchecked") @Override public KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to) { KVOperationType type = from.type; to.type = from.type; to.queryID = from.queryID; to.isPartOfTransaction = from.isPartOfTransaction; if (to.isPartOfTransaction) { to.transactionID = from.transactionID; to.dependentKey = copyWithReuse(from.dependentKey, to.dependentKey, keySerializer); to.inputOperationIDs = Arrays.copyOf(from.inputOperationIDs, from.inputOperationIDs.length); } to.hasOpId = from.hasOpId; to.operationID = from.operationID; to.numOpsForKey = from.numOpsForKey; switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case GET: case REMOVE: case MGET: case LOCK: to.key = copyWithReuse(from.key, to.key, keySerializer); break; case SGET: case SMGET: case SGETRES: case SKVRES: case SUPDATE: to.record = copyWithReuse(from.record, to.record, selectors.get(from.queryID).f0); break; default: throw new UnsupportedOperationException(); } switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case SGETRES: case SKVRES: case SUPDATE: to.value = copyWithReuse(from.value, to.value, valueSerializer); break; default: break; } switch (type) { case MGET: case MGETRES: case SMGET: case SKVRES: to.numKeys = from.numKeys; to.index = from.index; break; default: break; } to.keySelector = from.keySelector; to.reducer = from.reducer; return to; } KVOperationSerializer(TypeSerializer<K> keySerializer, TypeSerializer<V> valueSerializer,
			Map<Short, ReduceFunction<V>> reducers, Map<Short, Tuple2<TypeSerializer, KeySelector>> selectors,
			ExecutionConfig config); @SuppressWarnings("unchecked") @Override KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to); @SuppressWarnings("unchecked") @Override void serialize(KVOperation<K, V> op, DataOutputView target); @SuppressWarnings("unchecked") @Override KVOperation<K, V> deserialize(KVOperation<K, V> op, DataInputView source); @Override void copy(DataInputView source, DataOutputView target); @Override KVOperation<K, V> deserialize(DataInputView source); @Override boolean isImmutableType(); @Override TypeSerializer<KVOperation<K, V>> duplicate(); @Override KVOperation<K, V> createInstance(); @Override KVOperation<K, V> copy(KVOperation<K, V> from); @Override int getLength(); @Override boolean equals(Object o); @Override boolean canEqual(Object obj); @Override int hashCode(); }
KVOperationSerializer extends TypeSerializer<KVOperation<K, V>> { @SuppressWarnings("unchecked") @Override public KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to) { KVOperationType type = from.type; to.type = from.type; to.queryID = from.queryID; to.isPartOfTransaction = from.isPartOfTransaction; if (to.isPartOfTransaction) { to.transactionID = from.transactionID; to.dependentKey = copyWithReuse(from.dependentKey, to.dependentKey, keySerializer); to.inputOperationIDs = Arrays.copyOf(from.inputOperationIDs, from.inputOperationIDs.length); } to.hasOpId = from.hasOpId; to.operationID = from.operationID; to.numOpsForKey = from.numOpsForKey; switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case GET: case REMOVE: case MGET: case LOCK: to.key = copyWithReuse(from.key, to.key, keySerializer); break; case SGET: case SMGET: case SGETRES: case SKVRES: case SUPDATE: to.record = copyWithReuse(from.record, to.record, selectors.get(from.queryID).f0); break; default: throw new UnsupportedOperationException(); } switch (type) { case PUT: case KVRES: case UPDATE: case MGETRES: case SGETRES: case SKVRES: case SUPDATE: to.value = copyWithReuse(from.value, to.value, valueSerializer); break; default: break; } switch (type) { case MGET: case MGETRES: case SMGET: case SKVRES: to.numKeys = from.numKeys; to.index = from.index; break; default: break; } to.keySelector = from.keySelector; to.reducer = from.reducer; return to; } KVOperationSerializer(TypeSerializer<K> keySerializer, TypeSerializer<V> valueSerializer,
			Map<Short, ReduceFunction<V>> reducers, Map<Short, Tuple2<TypeSerializer, KeySelector>> selectors,
			ExecutionConfig config); @SuppressWarnings("unchecked") @Override KVOperation<K, V> copy(KVOperation<K, V> from, KVOperation<K, V> to); @SuppressWarnings("unchecked") @Override void serialize(KVOperation<K, V> op, DataOutputView target); @SuppressWarnings("unchecked") @Override KVOperation<K, V> deserialize(KVOperation<K, V> op, DataInputView source); @Override void copy(DataInputView source, DataOutputView target); @Override KVOperation<K, V> deserialize(DataInputView source); @Override boolean isImmutableType(); @Override TypeSerializer<KVOperation<K, V>> duplicate(); @Override KVOperation<K, V> createInstance(); @Override KVOperation<K, V> copy(KVOperation<K, V> from); @Override int getLength(); @Override boolean equals(Object o); @Override boolean canEqual(Object obj); @Override int hashCode(); public TypeSerializer<K> keySerializer; public TypeSerializer<V> valueSerializer; }