This project has retired. For details please refer to its Attic page.
MappingInputFormat xref
View Javadoc

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  
19  package org.apache.giraph.io;
20  
21  import org.apache.hadoop.io.Writable;
22  import org.apache.hadoop.io.WritableComparable;
23  import org.apache.hadoop.mapreduce.InputSplit;
24  import org.apache.hadoop.mapreduce.TaskAttemptContext;
25  
26  import java.io.IOException;
27  
28  /**
29   *
30   * Use this to load data for a BSP application.  Note that the InputSplit must
31   * also implement Writable.
32   *
33   * It's guaranteed that whatever parameters are set in the configuration are
34   * also going to be available in all method arguments related to this input
35   * format (context in getSplits and createVertexReader; methods invoked on
36   * MappingReader). So if backing input format relies on some parameters from
37   * configuration, you can safely set them for example in
38   * {@link #setConf(org.apache.giraph.conf.ImmutableClassesGiraphConfiguration)}.
39   *
40   * @param <I> vertexId type
41   * @param <V> vertexValue type
42   * @param <E> edgeValue type
43   * @param <B> mappingTarget type
44   */
45  @SuppressWarnings("unchecked")
46  public abstract class MappingInputFormat<I extends WritableComparable,
47      V extends Writable, E extends Writable, B extends Writable>
48      extends GiraphInputFormat<I, V, E> {
49  
50    /**
51     * Create a vertex reader for a given split. Guaranteed to have been
52     * configured with setConf() prior to use.  The framework will also call
53     * {@link VertexReader#initialize(InputSplit,
54     * org.apache.hadoop.mapreduce.TaskAttemptContext)} before
55     * the split is used.
56     *
57     * @param split the split to be read
58     * @param context the information about the task
59     * @return a new record reader
60     * @throws IOException
61     */
62    public abstract MappingReader<I, V, E, B> createMappingReader(
63        InputSplit split, TaskAttemptContext context) throws IOException;
64  }