Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2620 vikas 1
/*
2
 * Copyright 2010 Google Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
package in.shop2020.web.mappers;
18
 
19
import java.util.logging.Logger;
20
 
21
import org.apache.hadoop.io.NullWritable;
22
 
23
import com.google.appengine.api.datastore.Entity;
24
import com.google.appengine.api.datastore.Key;
25
import com.google.appengine.tools.mapreduce.AppEngineMapper;
26
 
27
/**
28
 * A sample AppEngine mapper.
29
 * 
30
 * @author frew@google.com (Fred Wulff)
31
 */
32
public class TestMapper extends
33
        AppEngineMapper<Key, Entity, NullWritable, NullWritable> {
34
    private static final Logger log = Logger.getLogger(TestMapper.class
35
            .getName());
36
 
37
    public TestMapper() {
38
    }
39
 
40
    @Override
41
    public void taskSetup(Context context) {
42
        log.warning("Doing per-task setup");
43
    }
44
 
45
    @Override
46
    public void taskCleanup(Context context) {
47
        log.warning("Doing per-task cleanup");
48
    }
49
 
50
    @Override
51
    public void setup(Context context) {
52
        log.warning("Doing per-worker setup");
53
    }
54
 
55
    @Override
56
    public void cleanup(Context context) {
57
        log.warning("Doing per-worker cleanup");
58
    }
59
 
60
    // This is a silly mapper that's intended to show some of the capabilities
61
    // of the API.
62
    @Override
63
    public void map(Key key, Entity value, Context context) {
64
        log.warning("Mapping key: " + key);
65
        context.getCounter("event", "count").increment(1);
66
        if (value.hasProperty("eventType") && value.getProperty("eventType")!=null) {
67
            context.getCounter("eventType", value.getProperty("eventType").toString()).increment(1);
68
        }
69
    }
70
}