Return-Path: X-Original-To: apmail-giraph-commits-archive@www.apache.org Delivered-To: apmail-giraph-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E3973F07D for ; Wed, 27 Mar 2013 16:44:30 +0000 (UTC) Received: (qmail 68830 invoked by uid 500); 27 Mar 2013 16:44:30 -0000 Delivered-To: apmail-giraph-commits-archive@giraph.apache.org Received: (qmail 68787 invoked by uid 500); 27 Mar 2013 16:44:30 -0000 Mailing-List: contact commits-help@giraph.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@giraph.apache.org Delivered-To: mailing list commits@giraph.apache.org Received: (qmail 68757 invoked by uid 99); 27 Mar 2013 16:44:29 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Mar 2013 16:44:29 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1947D828104; Wed, 27 Mar 2013 16:44:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: maja@apache.org To: commits@giraph.apache.org Message-Id: <7e821d77b45c420caa39702898bfd842@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: GIRAPH-581: More flexible Hive output (majakabiljo) Date: Wed, 27 Mar 2013 16:44:29 +0000 (UTC) Updated Branches: refs/heads/trunk 9cbbf99a3 -> 460198af9 GIRAPH-581: More flexible Hive output (majakabiljo) Project: http://git-wip-us.apache.org/repos/asf/giraph/repo Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/460198af Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/460198af Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/460198af Branch: refs/heads/trunk Commit: 460198af9da68e0e723ae9237031cfae2cf8bfc0 Parents: 9cbbf99 Author: Maja Kabiljo Authored: Wed Mar 27 09:43:26 2013 -0700 Committer: Maja Kabiljo Committed: Wed Mar 27 09:43:26 2013 -0700 ---------------------------------------------------------------------- CHANGELOG | 2 + .../giraph/hive/output/AbstractVertexToHive.java | 16 ++++- .../apache/giraph/hive/output/HiveRecordSaver.java | 37 +++++++++ .../giraph/hive/output/HiveVertexWriter.java | 17 +++- .../giraph/hive/output/SimpleVertexToHive.java | 60 +++++++++++++++ .../apache/giraph/hive/output/VertexToHive.java | 24 +++++-- pom.xml | 2 +- 7 files changed, 144 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/giraph/blob/460198af/CHANGELOG ---------------------------------------------------------------------- diff --git a/CHANGELOG b/CHANGELOG index 674d15e..530d9ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ Giraph Change Log Release 0.2.0 - unreleased + GIRAPH-581: More flexible Hive output (majakabiljo) + GIRAPH-579: Make it possible to use different out-edges data structures for input and computation (apresta) http://git-wip-us.apache.org/repos/asf/giraph/blob/460198af/giraph-hive/src/main/java/org/apache/giraph/hive/output/AbstractVertexToHive.java ---------------------------------------------------------------------- diff --git a/giraph-hive/src/main/java/org/apache/giraph/hive/output/AbstractVertexToHive.java b/giraph-hive/src/main/java/org/apache/giraph/hive/output/AbstractVertexToHive.java index 8e3f1ca..fe0771d 100644 --- a/giraph-hive/src/main/java/org/apache/giraph/hive/output/AbstractVertexToHive.java +++ b/giraph-hive/src/main/java/org/apache/giraph/hive/output/AbstractVertexToHive.java @@ -21,10 +21,11 @@ import org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; +import com.facebook.giraph.hive.HiveTableSchema; import com.facebook.giraph.hive.HiveTableSchemaAware; /** - * Base class for HiveToVertexEdges implementations + * Base class for VertexToHive implementations * * @param Vertex ID * @param Vertex Value @@ -34,4 +35,15 @@ import com.facebook.giraph.hive.HiveTableSchemaAware; public abstract class AbstractVertexToHive extends DefaultImmutableClassesGiraphConfigurable - implements HiveTableSchemaAware, VertexToHive { } + implements HiveTableSchemaAware, VertexToHive { + /** Schema stored here */ + private HiveTableSchema tableSchema; + + @Override public void setTableSchema(HiveTableSchema tableSchema) { + this.tableSchema = tableSchema; + } + + @Override public HiveTableSchema getTableSchema() { + return tableSchema; + } +} http://git-wip-us.apache.org/repos/asf/giraph/blob/460198af/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveRecordSaver.java ---------------------------------------------------------------------- diff --git a/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveRecordSaver.java b/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveRecordSaver.java new file mode 100644 index 0000000..70de517 --- /dev/null +++ b/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveRecordSaver.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.giraph.hive.output; + +import com.facebook.giraph.hive.HiveRecord; + +import java.io.IOException; + +/** + * Interface which can save {@link HiveRecord}s. + */ +public interface HiveRecordSaver { + /** + * Save the record. + * + * @param record Record to save. + * @throws IOException + * @throws InterruptedException + */ + void save(HiveRecord record) throws IOException, InterruptedException; +} http://git-wip-us.apache.org/repos/asf/giraph/blob/460198af/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveVertexWriter.java ---------------------------------------------------------------------- diff --git a/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveVertexWriter.java b/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveVertexWriter.java index a97d40a..3eef1f4 100644 --- a/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveVertexWriter.java +++ b/giraph-hive/src/main/java/org/apache/giraph/hive/output/HiveVertexWriter.java @@ -45,7 +45,7 @@ import java.util.Collections; * @param Edge Value */ public class HiveVertexWriter implements VertexWriter { + E extends Writable> implements VertexWriter, HiveRecordSaver { /** Key in configuration for VertexToHive class */ public static final String VERTEX_TO_HIVE_KEY = "giraph.vertex.to.hive.class"; @@ -57,6 +57,9 @@ public class HiveVertexWriter conf; @@ -98,6 +101,8 @@ public class HiveVertexWriteremptyList()); } @Override @@ -125,10 +130,7 @@ public class HiveVertexWriter vertex) throws IOException, InterruptedException { - HiveRecord record = new HiveApiRecord(tableSchema.numColumns(), - Collections.emptyList()); - vertexToHive.fillRecord(vertex, record); - hiveRecordWriter.write(NullWritable.get(), record); + vertexToHive.saveVertex(vertex, reusableRecord, this); } @Override @@ -136,4 +138,9 @@ public class HiveVertexWriter Vertex ID + * @param Vertex Value + * @param Edge Value + * @param Message Value + */ +public abstract class SimpleVertexToHive extends + AbstractVertexToHive { + + /** + * Fill the HiveRecord from the Vertex given. + * + * @param vertex Vertex to read from. + * @param record HiveRecord to write to. + */ + public abstract void fillRecord(Vertex vertex, + HiveWritableRecord record); + + @Override + public final void saveVertex( + Vertex vertex, + HiveRecord reusableRecord, + HiveRecordSaver recordSaver) throws IOException, InterruptedException { + fillRecord(vertex, reusableRecord); + recordSaver.save(reusableRecord); + } +} http://git-wip-us.apache.org/repos/asf/giraph/blob/460198af/giraph-hive/src/main/java/org/apache/giraph/hive/output/VertexToHive.java ---------------------------------------------------------------------- diff --git a/giraph-hive/src/main/java/org/apache/giraph/hive/output/VertexToHive.java b/giraph-hive/src/main/java/org/apache/giraph/hive/output/VertexToHive.java index 6d323bd..ff5869d 100644 --- a/giraph-hive/src/main/java/org/apache/giraph/hive/output/VertexToHive.java +++ b/giraph-hive/src/main/java/org/apache/giraph/hive/output/VertexToHive.java @@ -22,10 +22,12 @@ import org.apache.giraph.graph.Vertex; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; -import com.facebook.giraph.hive.HiveWritableRecord; +import com.facebook.giraph.hive.HiveRecord; + +import java.io.IOException; /** - * Interface for writing vertices to a Hive record. + * Interface for writing vertices to Hive. * * @param Vertex ID * @param Vertex Value @@ -34,10 +36,20 @@ import com.facebook.giraph.hive.HiveWritableRecord; public interface VertexToHive { /** - * Fill the HiveRecord from the Vertex given. + * Save vertex to the output. One vertex can be stored to multiple rows in + * the output. + * + * Record you get here is reusable, and the protocol to follow is: + * - fill the reusableRecord with your data + * - call recordSaver.save(reusableRecord) + * - repeat + * If you don't call save() at all then there won't be any output for this + * vertex. * - * @param vertex Vertex to read from. - * @param record HiveRecord to write to. + * @param vertex Vertex which we want to save. + * @param reusableRecord Record to use for writing data to it. + * @param recordSaver Saver of records */ - void fillRecord(Vertex vertex, HiveWritableRecord record); + void saveVertex(Vertex vertex, HiveRecord reusableRecord, + HiveRecordSaver recordSaver) throws IOException, InterruptedException; } http://git-wip-us.apache.org/repos/asf/giraph/blob/460198af/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index e576e4b..799bb0a 100644 --- a/pom.xml +++ b/pom.xml @@ -881,7 +881,7 @@ under the License. com.facebook.giraph.hive hive-io-experimental - 0.4-SNAPSHOT + 0.4 com.google.guava