1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * 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 and 16 * limitations under the License. 17 */ 18 package org.apache.giraph.block_app.framework.api; 19 20 import org.apache.giraph.block_app.framework.piece.global_comm.ReducerHandle; 21 import org.apache.giraph.reducers.ReduceOperation; 22 import org.apache.hadoop.io.Writable; 23 24 /** 25 * Api for creating reducer handles. 26 */ 27 public interface CreateReducersApi extends BlockConfApi { 28 29 /** 30 * Create local reducer, returning a handle to it. 31 * 32 * Local reducer means that each worker thread has it's own local partially 33 * reduced value, which are at the end reduced all together. 34 * Preferable, unless it cannot be used, because all copies of the object 35 * do not fit the memory. 36 */ 37 <S, R extends Writable> ReducerHandle<S, R> createLocalReducer( 38 ReduceOperation<S, R> reduceOp); 39 40 /** 41 * Create local reducer, returning a handle to it. 42 * 43 * Local reducer means that each worker thread has it's own local partially 44 * reduced value, which are at the end reduced all together. 45 * Preferable, unless it cannot be used, because all copies of the object 46 * do not fit the memory. 47 */ 48 <S, R extends Writable> ReducerHandle<S, R> createLocalReducer( 49 ReduceOperation<S, R> reduceOp, R globalInitialValue); 50 51 /** 52 * Create global reducer, returning a handle to it. 53 * 54 * Global reducer means that there is only one value for each worker, 55 * and each call to reduce will have to obtain a global lock, and incur 56 * synchronization costs. 57 * Use only when objects are so large, that having many copies cannot 58 * fit into memory. 59 */ 60 <S, R extends Writable> ReducerHandle<S, R> createGlobalReducer( 61 ReduceOperation<S, R> reduceOp); 62 63 /** 64 * Create global reducer, returning a handle to it. 65 * 66 * Global reducer means that there is only one value for each worker, 67 * and each call to reduce will have to obtain a global lock, and incur 68 * synchronization costs. 69 * Use only when objects are so large, that having many copies cannot 70 * fit into memory. 71 */ 72 <S, R extends Writable> ReducerHandle<S, R> createGlobalReducer( 73 ReduceOperation<S, R> reduceOp, R globalInitialValue); 74 75 /** 76 * Function that creates a reducer - abstracting away whether it is 77 * local or global reducer 78 */ 79 public interface CreateReducerFunctionApi { 80 <S, R extends Writable> ReducerHandle<S, R> createReducer( 81 ReduceOperation<S, R> reduceOp); 82 } 83 }