giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject git commit: updated refs/heads/trunk to 62b7145
Date Tue, 28 Oct 2014 18:23:43 GMT
Repository: giraph
Updated Branches:
  refs/heads/trunk 4bb1d3e17 -> 62b714547


Allow vertex/edge/message value to be configurable

Summary: And throw if WritableUtils.createWritable(clazz) is called with GiraphConfigurationSettable.

Test Plan: mvn install

Reviewers: sergey.edunov, pavanka, maja.kabiljo

Reviewed By: maja.kabiljo

Differential Revision: https://reviews.facebook.net/D25353


Project: http://git-wip-us.apache.org/repos/asf/giraph/repo
Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/62b71454
Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/62b71454
Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/62b71454

Branch: refs/heads/trunk
Commit: 62b714547ea082099f673ed2e53a7aa7d47c8b5c
Parents: 4bb1d3e
Author: Igor Kabiljo <ikabiljo@fb.com>
Authored: Tue Oct 28 10:59:37 2014 -0700
Committer: Maja Kabiljo <majakabiljo@fb.com>
Committed: Tue Oct 28 11:03:19 2014 -0700

----------------------------------------------------------------------
 CHANGELOG                                              |  2 ++
 .../giraph/factories/AbstractMessageValueFactory.java  |  5 ++++-
 .../giraph/factories/DefaultEdgeValueFactory.java      |  5 ++++-
 .../giraph/factories/DefaultVertexIdFactory.java       |  5 ++++-
 .../giraph/factories/DefaultVertexValueFactory.java    |  6 ++++--
 .../java/org/apache/giraph/utils/WritableUtils.java    | 13 +++++++------
 6 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/giraph/blob/62b71454/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index d9398e7..cdfd666 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 Giraph Change Log
 
 Release 1.1.0 - unreleased
+  GIRAPH-955: Allow vertex/edge/message value to be configurable (ikabiljo via majakabiljo)
+
   GIRAPH-938: Allow fast working with primitives generically (ikabiljo via pavanka)
 
   GIRAPH-945: Always use job Configuration to create Configuration (majakabiljo)

http://git-wip-us.apache.org/repos/asf/giraph/blob/62b71454/giraph-core/src/main/java/org/apache/giraph/factories/AbstractMessageValueFactory.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/factories/AbstractMessageValueFactory.java
b/giraph-core/src/main/java/org/apache/giraph/factories/AbstractMessageValueFactory.java
index dcc286f..5551439 100644
--- a/giraph-core/src/main/java/org/apache/giraph/factories/AbstractMessageValueFactory.java
+++ b/giraph-core/src/main/java/org/apache/giraph/factories/AbstractMessageValueFactory.java
@@ -32,6 +32,8 @@ public abstract class AbstractMessageValueFactory<M extends Writable>
     implements MessageValueFactory<M> {
   /** Message value class */
   private Class<M> messageValueClass;
+  /** Configuration */
+  private ImmutableClassesGiraphConfiguration conf;
 
   /**
    * Get the message value class from the configuration
@@ -49,11 +51,12 @@ public abstract class AbstractMessageValueFactory<M extends Writable>
 
   @Override
   public void initialize(ImmutableClassesGiraphConfiguration conf) {
+    this.conf = conf;
     messageValueClass = extractMessageValueClass(conf);
   }
 
   @Override public M newInstance() {
-    return WritableUtils.createWritable(messageValueClass);
+    return WritableUtils.createWritable(messageValueClass, conf);
   }
 
   @Override public String toString() {

http://git-wip-us.apache.org/repos/asf/giraph/blob/62b71454/giraph-core/src/main/java/org/apache/giraph/factories/DefaultEdgeValueFactory.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/factories/DefaultEdgeValueFactory.java
b/giraph-core/src/main/java/org/apache/giraph/factories/DefaultEdgeValueFactory.java
index c392c87..998c06f 100644
--- a/giraph-core/src/main/java/org/apache/giraph/factories/DefaultEdgeValueFactory.java
+++ b/giraph-core/src/main/java/org/apache/giraph/factories/DefaultEdgeValueFactory.java
@@ -32,8 +32,11 @@ public class DefaultEdgeValueFactory<E extends Writable>
     implements EdgeValueFactory<E> {
   /** Cached edge value class. */
   private Class<E> edgeValueClass;
+  /** Configuration */
+  private ImmutableClassesGiraphConfiguration conf;
 
   @Override public void initialize(ImmutableClassesGiraphConfiguration conf) {
+    this.conf = conf;
     edgeValueClass = conf.getEdgeValueClass();
   }
 
@@ -42,6 +45,6 @@ public class DefaultEdgeValueFactory<E extends Writable>
   }
 
   @Override public E newInstance() {
-    return WritableUtils.createWritable(edgeValueClass);
+    return WritableUtils.createWritable(edgeValueClass, conf);
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/62b71454/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexIdFactory.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexIdFactory.java
b/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexIdFactory.java
index 6dafc7c..305548c 100644
--- a/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexIdFactory.java
+++ b/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexIdFactory.java
@@ -31,9 +31,12 @@ public class DefaultVertexIdFactory<I extends WritableComparable>
     implements VertexIdFactory<I> {
   /** Cached vertex value class. */
   private Class<I> vertexIdClass;
+  /** Configuration */
+  private ImmutableClassesGiraphConfiguration conf;
 
   @Override
   public void initialize(ImmutableClassesGiraphConfiguration conf) {
+    this.conf = conf;
     vertexIdClass = conf.getVertexIdClass();
   }
 
@@ -44,6 +47,6 @@ public class DefaultVertexIdFactory<I extends WritableComparable>
 
   @Override
   public I newInstance() {
-    return WritableUtils.createWritable(vertexIdClass);
+    return WritableUtils.createWritable(vertexIdClass, conf);
   }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/62b71454/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexValueFactory.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexValueFactory.java
b/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexValueFactory.java
index 2fe61ae..634f0d5 100644
--- a/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexValueFactory.java
+++ b/giraph-core/src/main/java/org/apache/giraph/factories/DefaultVertexValueFactory.java
@@ -32,9 +32,12 @@ public class DefaultVertexValueFactory<V extends Writable>
     implements VertexValueFactory<V> {
   /** Cached vertex value class. */
   private Class<V> vertexValueClass;
+  /** Configuration */
+  private ImmutableClassesGiraphConfiguration conf;
 
   @Override
   public void initialize(ImmutableClassesGiraphConfiguration conf) {
+    this.conf = conf;
     vertexValueClass = conf.getVertexValueClass();
   }
 
@@ -45,7 +48,6 @@ public class DefaultVertexValueFactory<V extends Writable>
 
   @Override
   public V newInstance() {
-    return WritableUtils.createWritable(vertexValueClass);
+    return WritableUtils.createWritable(vertexValueClass, conf);
   }
 }
-

http://git-wip-us.apache.org/repos/asf/giraph/blob/62b71454/giraph-core/src/main/java/org/apache/giraph/utils/WritableUtils.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/utils/WritableUtils.java b/giraph-core/src/main/java/org/apache/giraph/utils/WritableUtils.java
index 0081fc0..3c37bec 100644
--- a/giraph-core/src/main/java/org/apache/giraph/utils/WritableUtils.java
+++ b/giraph-core/src/main/java/org/apache/giraph/utils/WritableUtils.java
@@ -62,11 +62,7 @@ public class WritableUtils {
    * @return new instance of class
    */
   public static <W extends Writable> W createWritable(Class<W> klass) {
-    if (NullWritable.class.equals(klass)) {
-      return (W) NullWritable.get();
-    } else {
-      return ReflectionUtils.newInstance(klass);
-    }
+    return createWritable(klass, null);
   }
 
   /**
@@ -80,7 +76,12 @@ public class WritableUtils {
   public static <W extends Writable> W createWritable(
       Class<W> klass,
       ImmutableClassesGiraphConfiguration configuration) {
-    W result = createWritable(klass);
+    W result;
+    if (NullWritable.class.equals(klass)) {
+      result = (W) NullWritable.get();
+    } else {
+      result = ReflectionUtils.newInstance(klass);
+    }
     ConfigurationUtils.configureIfPossible(result, configuration);
     return result;
   }


Mime
View raw message