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.io.formats;
1920import com.google.common.collect.ImmutableList;
21import org.apache.giraph.edge.Edge;
22import org.apache.hadoop.io.IntWritable;
23import org.apache.hadoop.io.NullWritable;
24import org.apache.hadoop.io.Text;
25import org.apache.hadoop.mapreduce.InputSplit;
26import org.apache.hadoop.mapreduce.TaskAttemptContext;
2728import java.io.IOException;
2930/**31 * Simple text-based {@link org.apache.giraph.io.VertexInputFormat} for32 * unweighted graphs without edges or values, just vertices with ids.33 *34 * Each line is just simply the vertex id.35 */36publicclassIntNullNullTextInputFormatextends TextVertexInputFormat<
37 IntWritable, NullWritable, NullWritable> {
38 @Override
39publicTextVertexReader createVertexReader(
40 InputSplit split, TaskAttemptContext context) throws IOException {
41returnnewIntNullNullNullVertexReader();
42 }
4344/**45 * Reader for this InputFormat.46 */47publicclassIntNullNullNullVertexReaderextends48 TextVertexReaderFromEachLineProcessed<String> {
49/** Cached vertex id */50private IntWritable id;
5152 @Override
53protected String preprocessLine(Text line) throws IOException {
54 id = new IntWritable(Integer.parseInt(line.toString()));
55return line.toString();
56 }
5758 @Override
59protected IntWritable getId(String line) throws IOException {
60return id;
61 }
6263 @Override
64protected NullWritable getValue(String line) throws IOException {
65return NullWritable.get();
66 }
6768 @Override
69protected Iterable<Edge<IntWritable, NullWritable>> getEdges(String line)
70throws IOException {
71return ImmutableList.of();
72 }
73 }
74 }