source: proiecte/HadoopJUnit/hadoop-0.20.1/c++/Linux-i386-32/include/hadoop/TemplateFactory.hh @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 3.2 KB
Line 
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#ifndef HADOOP_PIPES_TEMPLATE_FACTORY_HH
19#define HADOOP_PIPES_TEMPLATE_FACTORY_HH
20
21namespace HadoopPipes {
22
23  template <class mapper, class reducer>
24  class TemplateFactory2: public Factory {
25  public:
26    Mapper* createMapper(MapContext& context) const {
27      return new mapper(context);
28    }
29    Reducer* createReducer(ReduceContext& context) const {
30      return new reducer(context);
31    }
32  };
33
34  template <class mapper, class reducer, class partitioner>
35  class TemplateFactory3: public TemplateFactory2<mapper,reducer> {
36  public:
37    Partitioner* createPartitioner(MapContext& context) const {
38      return new partitioner(context);
39    }
40  };
41
42  template <class mapper, class reducer>
43  class TemplateFactory3<mapper, reducer, void>
44      : public TemplateFactory2<mapper,reducer> {
45  };
46
47  template <class mapper, class reducer, class partitioner, class combiner>
48  class TemplateFactory4
49   : public TemplateFactory3<mapper,reducer,partitioner>{
50  public:
51    Reducer* createCombiner(MapContext& context) const {
52      return new combiner(context);
53    }
54  };
55
56  template <class mapper, class reducer, class partitioner>
57  class TemplateFactory4<mapper,reducer,partitioner,void>
58   : public TemplateFactory3<mapper,reducer,partitioner>{
59  };
60
61  template <class mapper, class reducer, class partitioner, 
62            class combiner, class recordReader>
63  class TemplateFactory5
64   : public TemplateFactory4<mapper,reducer,partitioner,combiner>{
65  public:
66    RecordReader* createRecordReader(MapContext& context) const {
67      return new recordReader(context);
68    }
69  };
70
71  template <class mapper, class reducer, class partitioner,class combiner>
72  class TemplateFactory5<mapper,reducer,partitioner,combiner,void>
73   : public TemplateFactory4<mapper,reducer,partitioner,combiner>{
74  };
75
76  template <class mapper, class reducer, class partitioner=void, 
77            class combiner=void, class recordReader=void, 
78            class recordWriter=void> 
79  class TemplateFactory
80   : public TemplateFactory5<mapper,reducer,partitioner,combiner,recordReader>{
81  public:
82    RecordWriter* createRecordWriter(ReduceContext& context) const {
83      return new recordWriter(context);
84    }
85  };
86
87  template <class mapper, class reducer, class partitioner, 
88            class combiner, class recordReader>
89  class TemplateFactory<mapper, reducer, partitioner, combiner, recordReader, 
90                        void>
91   : public TemplateFactory5<mapper,reducer,partitioner,combiner,recordReader>{
92  };
93
94}
95
96#endif
Note: See TracBrowser for help on using the repository browser.