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.block_app.framework.piece.global_comm.internal;
1920import org.apache.giraph.block_app.framework.api.BlockMasterApi;
21import org.apache.giraph.block_app.framework.api.CreateReducersApi;
22import org.apache.giraph.block_app.framework.piece.global_comm.ReducerHandle;
23import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
24import org.apache.giraph.reducers.ReduceOperation;
25import org.apache.hadoop.io.Writable;
2627/**28 * Wrapping masterApi and reducers handler into API for creating reducer29 * handles.30 */31publicclassCreateReducersApiWrapperimplementsCreateReducersApi {
32privatefinalBlockMasterApi masterApi;
33privatefinalReducersForPieceHandler reducersApi;
3435publicCreateReducersApiWrapper(
36BlockMasterApi masterApi, ReducersForPieceHandler reducersApi) {
37this.masterApi = masterApi;
38this.reducersApi = reducersApi;
39 }
4041 @Override
42public <S, R extends Writable> ReducerHandle<S, R> createLocalReducer(
43 ReduceOperation<S, R> reduceOp) {
44return reducersApi.createLocalReducer(
45 masterApi, reduceOp, reduceOp.createInitialValue());
46 }
4748 @Override
49public <S, R extends Writable> ReducerHandle<S, R> createLocalReducer(
50 ReduceOperation<S, R> reduceOp, R globalInitialValue) {
51return reducersApi.createLocalReducer(
52 masterApi, reduceOp, globalInitialValue);
53 }
5455 @Override
56public <S, R extends Writable> ReducerHandle<S, R> createGlobalReducer(
57 ReduceOperation<S, R> reduceOp) {
58return reducersApi.createGlobalReducer(
59 masterApi, reduceOp, reduceOp.createInitialValue());
60 }
6162 @Override
63public <S, R extends Writable> ReducerHandle<S, R> createGlobalReducer(
64 ReduceOperation<S, R> reduceOp, R globalInitialValue) {
65return reducersApi.createGlobalReducer(
66 masterApi, reduceOp, globalInitialValue);
67 }
6869 @Override
70public ImmutableClassesGiraphConfiguration<?, ?, ?> getConf() {
71return masterApi.getConf();
72 }
73 }