1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18package org.apache.giraph.reducers.impl;
1920import java.io.DataInput;
21import java.io.DataOutput;
22import java.io.IOException;
2324import org.apache.giraph.reducers.ReduceOperation;
25import org.apache.giraph.writable.kryo.KryoWritableWrapper;
2627/**28 * Reduce operation which wraps reduced value in KryoWritableWrapper,29 * so we don't need to worry about it being writable30 *31 * @param <S> Single value type32 * @param <R> Reduced value type33 */34publicabstractclass KryoWrappedReduceOperation<S, R>
35implements ReduceOperation<S, KryoWritableWrapper<R>> {
36/**37 * Look at ReduceOperation.reduce.38 *39 * @param reduceInto Partial value into which to reduce and store the result40 * @param valueToReduce Single value to be reduced41 */42publicabstractvoid reduce(R reduceInto, S valueToReduce);
4344/**45 * Look at ReduceOperation.reduceMerge.46 *47 * @param reduceInto Partial value into which to reduce and store the result48 * @param valueToReduce Partial value to be reduced49 */50publicabstractvoid reduceMerge(R reduceInto, R valueToReduce);
5152/**53 * Look at ReduceOperation.createValue.54 *55 * @return Neutral value56 */57publicabstract R createValue();
5859 @Override
60publicfinal KryoWritableWrapper<R> createInitialValue() {
61returnnew KryoWritableWrapper<>(createValue());
62 }
6364 @Override
65publicfinal KryoWritableWrapper<R> reduce(
66 KryoWritableWrapper<R> wrapper, S value) {
67 reduce(wrapper.get(), value);
68return wrapper;
69 }
7071 @Override
72publicfinal KryoWritableWrapper<R> reduceMerge(
73 KryoWritableWrapper<R> wrapper,
74 KryoWritableWrapper<R> wrapperToReduce) {
75 reduceMerge(wrapper.get(), wrapperToReduce.get());
76return wrapper;
77 }
7879 @Override
80publicvoid write(DataOutput dataOutput) throws IOException {
81 }
8283 @Override
84publicvoid readFields(DataInput dataInput) throws IOException {
85 }
86 }