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 */1819package org.apache.giraph.examples;
2021import org.apache.giraph.graph.Vertex;
22import org.apache.giraph.io.formats.TextVertexOutputFormat;
23import org.apache.hadoop.io.FloatWritable;
24import org.apache.hadoop.io.IntWritable;
25import org.apache.hadoop.io.LongWritable;
26import org.apache.hadoop.io.Text;
27import org.apache.hadoop.mapreduce.TaskAttemptContext;
2829import java.io.IOException;
3031/**32 * Simple text based vertex output format example.33 */34publicclassSimpleTextVertexOutputFormatextends35 TextVertexOutputFormat<LongWritable, IntWritable, FloatWritable> {
36/**37 * Simple text based vertex writer38 */39privateclassSimpleTextVertexWriterextendsTextVertexWriter {
40 @Override
41publicvoid writeVertex(
42 Vertex<LongWritable, IntWritable, FloatWritable> vertex)
43throws IOException, InterruptedException {
44 getRecordWriter().write(
45new Text(vertex.getId().toString()),
46new Text(vertex.getValue().toString()));
47 }
48 }
4950 @Override
51publicTextVertexWriter createVertexWriter(TaskAttemptContext context)
52throws IOException, InterruptedException {
53returnnewSimpleTextVertexWriter();
54 }
55 }