[GIRAPH-1041] Generate primitive type specific code for functions
Summary:
- Use FreeMarker library to generate primitive type specific code.
Initially generating two sets of files:
{TYPE}Consumer, Obj2{TYPE}Function
Right now generation happens manually, and generated files are being committed.
In the future we can move those to a separate project, and have them generated
when maven is compiling and deploying.
Splitting of D52515 into reviewable pieces
Test Plan:
mvn clean install
There are no changes in logic in this diff.
Reviewers: spupyrev, sergey.edunov, dionysis.logothetis, maja.kabiljo
Reviewed By: maja.kabiljo
Differential Revision: https://reviews.facebook.net/D55527
Project: http://git-wip-us.apache.org/repos/asf/giraph/repo
Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/a927450a
Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/a927450a
Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/a927450a
Branch: refs/heads/trunk
Commit: a927450aa63fe8e21f7da22cc79de182cfcfd780
Parents: e4aa99d
Author: Igor Kabiljo <[email protected]>
Authored: Tue Mar 15 14:40:52 2016 -0700
Committer: Igor Kabiljo <[email protected]>
Committed: Fri Mar 18 16:49:45 2016 -0700
----------------------------------------------------------------------
.../org/apache/giraph/function/Consumer.java | 34 ----
.../org/apache/giraph/function/Function.java | 38 ----
.../apache/giraph/function/ObjectHolder.java | 56 ------
.../apache/giraph/function/ObjectTransfer.java | 113 -----------
.../apache/giraph/function/PairConsumer.java | 34 ----
.../apache/giraph/function/PairFunction.java | 40 ----
.../apache/giraph/function/PairPredicate.java | 35 ----
.../org/apache/giraph/function/Predicate.java | 36 ----
.../org/apache/giraph/function/Supplier.java | 37 ----
.../apache/giraph/function/TripleFunction.java | 41 ----
.../apache/giraph/function/package-info.java | 26 ---
.../function/primitive/Double2ObjFunction.java | 36 ----
.../function/primitive/DoubleConsumer.java | 32 ----
.../function/primitive/Int2ObjFunction.java | 36 ----
.../giraph/function/primitive/IntSupplier.java | 29 ---
.../function/primitive/Obj2DoubleFunction.java | 33 ----
.../function/primitive/Obj2FloatFunction.java | 33 ----
.../function/primitive/Obj2IntFunction.java | 33 ----
.../function/primitive/Obj2LongFunction.java | 33 ----
.../function/primitive/PrimitiveRefs.java | 107 -----------
.../giraph/function/primitive/package-info.java | 22 ---
.../function/vertex/ConsumerWithVertex.java | 48 -----
.../function/vertex/FunctionWithVertex.java | 52 ------
.../function/vertex/SupplierFromVertex.java | 49 -----
.../giraph/function/vertex/package-info.java | 22 ---
giraph-core/pom.xml | 7 +
.../org/apache/giraph/function/Consumer.java | 36 ++++
.../org/apache/giraph/function/Function.java | 41 ++++
.../apache/giraph/function/ObjectHolder.java | 62 +++++++
.../apache/giraph/function/ObjectTransfer.java | 129 +++++++++++++
.../apache/giraph/function/PairConsumer.java | 37 ++++
.../apache/giraph/function/PairFunction.java | 44 +++++
.../apache/giraph/function/PairPredicate.java | 39 ++++
.../org/apache/giraph/function/Predicate.java | 39 ++++
.../org/apache/giraph/function/Supplier.java | 39 ++++
.../apache/giraph/function/TripleFunction.java | 45 +++++
.../apache/giraph/function/package-info.java | 26 +++
.../function/primitive/BooleanConsumer.java | 36 ++++
.../giraph/function/primitive/ByteConsumer.java | 36 ++++
.../function/primitive/Double2ObjFunction.java | 39 ++++
.../function/primitive/DoubleConsumer.java | 36 ++++
.../function/primitive/FloatConsumer.java | 36 ++++
.../function/primitive/Int2ObjFunction.java | 39 ++++
.../giraph/function/primitive/IntConsumer.java | 36 ++++
.../giraph/function/primitive/IntSupplier.java | 33 ++++
.../giraph/function/primitive/LongConsumer.java | 36 ++++
.../function/primitive/Obj2BooleanFunction.java | 39 ++++
.../function/primitive/Obj2ByteFunction.java | 39 ++++
.../function/primitive/Obj2DoubleFunction.java | 39 ++++
.../function/primitive/Obj2FloatFunction.java | 39 ++++
.../function/primitive/Obj2IntFunction.java | 39 ++++
.../function/primitive/Obj2LongFunction.java | 39 ++++
.../function/primitive/PrimitiveRefs.java | 137 ++++++++++++++
.../giraph/function/primitive/package-info.java | 22 +++
.../function/vertex/ConsumerWithVertex.java | 51 +++++
.../function/vertex/FunctionWithVertex.java | 56 ++++++
.../function/vertex/SupplierFromVertex.java | 52 ++++++
.../giraph/function/vertex/package-info.java | 22 +++
.../generate/GeneratePrimitiveClasses.java | 185 +++++++++++++++++++
giraph-core/templates/Obj2TypeFunction.java | 38 ++++
giraph-core/templates/TypeConsumer.java | 35 ++++
61 files changed, 1703 insertions(+), 1055 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/Consumer.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/Consumer.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/Consumer.java
deleted file mode 100644
index 2a0e36a..0000000
--- a/giraph-block-app/src/main/java/org/apache/giraph/function/Consumer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-
-/**
- * Function:
- * (T) -> void
- *
- * @param <T> Argument type
- */
-public interface Consumer<T> extends Serializable {
- /**
- * Applies this function to {@code input}
- */
- void apply(T input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/Function.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/Function.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/Function.java
deleted file mode 100644
index 41046ba..0000000
--- a/giraph-block-app/src/main/java/org/apache/giraph/function/Function.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-
-/**
- * Function:
- * (F) -> T
- *
- * @param <F> Argument type
- * @param <T> Result type
- */
-public interface Function<F, T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- *
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- T apply(F input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectHolder.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectHolder.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectHolder.java
deleted file mode 100644
index fd531bd..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectHolder.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.function;
-
-/**
- * Default object holder, intermediary between producers and consumers.
- *
- * Holds value in memory, so can be used only when producer and consumer
- * are in the same context.
- *
- * Useful when value is set on the master, and later read in block logic
- * (RepeatUntilBlock), or in a different Piece, either on worker or master.
- * If it is read within the same piece - just use local field.
- *
- * @param <T> Type of object to hold.
- */
-public class ObjectHolder<T> implements Supplier<T>, Consumer<T> {
- private T value;
-
- public ObjectHolder(T value) {
- this.value = value;
- }
-
- public ObjectHolder() {
- }
-
- @Override
- public T get() {
- return value;
- }
-
- @Override
- public void apply(T value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return getClass() + " [value=" + value + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectTransfer.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectTransfer.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectTransfer.java
deleted file mode 100644
index 8d72017..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/ObjectTransfer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.function;
-
-import org.apache.giraph.function.vertex.ConsumerWithVertex;
-import org.apache.giraph.function.vertex.SupplierFromVertex;
-import org.apache.giraph.graph.Vertex;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Default object transfer, intermediary between producers and consumers.
- *
- * Holds value temporarily in memory, so can be used only when producer and
- * consumer are in the same context. Nulls it out after supplying, so each
- * object is returned only once, and second consecutive call to 'get' will
- * return null.
- *
- * Useful for both:
- *
- * - passing data from vertexReceive function of WorkerReceivePiece of previous
- * Piece to vertexSend function WorkerSendPiece of next Piece, of the same
- * vertex.
- * - when value is set on the master, and later read in block logic
- * (RepeatUntilBlock), or in a different Piece, either on worker or master.
- * If it is read within the same piece - just use local field.
- *
- * @param <T> Type of object to transfer.
- */
-public class ObjectTransfer<T> implements Supplier<T>, Consumer<T> {
- private T value;
-
- public ObjectTransfer(T value) {
- this.value = value;
- }
-
- public ObjectTransfer() {
- }
-
- @Override
- public T get() {
- T result = value;
- value = null;
- return result;
- }
-
- @Override
- public void apply(T value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return getClass() + " [value=" + value + "]";
- }
-
- /**
- * To be called when needing to pass it as a Supplier - making it
- * obvious that K, V and E on supplier side can be any types,
- * and to make code work without compile errors/warnings.
- *
- * In Java7, some callsites might need explicit types:
- * object.<LongWritable, DoubleWritable, Writable>castToSupplier()
- * In Java8, object.castToSupplier() is always going to be enough.
- */
- // TODO Java8: cleanup callers
- @SuppressWarnings("rawtypes")
- public <I extends WritableComparable, V extends Writable, E extends Writable>
- SupplierFromVertex<I, V, E, T> castToSupplier() {
- return new SupplierFromVertex<I, V, E, T>() {
- @Override
- public T get(Vertex<I, V, E> vertex) {
- return ObjectTransfer.this.get();
- }
- };
- }
-
- /**
- * To be called when needing to pass it as a Consumer - making it
- * obvious that K, V and E on consumer side can be any types,
- * and to make code work without compile errors/warnings.
- *
- * In Java7, some callsites might need explicit types:
- * object.<LongWritable, DoubleWritable, Writable>castToConsumer()
- * In Java8, object.castToConsumer() is always going to be enough.
- */
- // TODO Java8: cleanup callers
- @SuppressWarnings("rawtypes")
- public <I extends WritableComparable, V extends Writable, E extends Writable>
- ConsumerWithVertex<I, V, E, T> castToConsumer() {
- return new ConsumerWithVertex<I, V, E, T>() {
- @Override
- public void apply(Vertex<I, V, E> vertex, T value) {
- ObjectTransfer.this.apply(value);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/PairConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/PairConsumer.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/PairConsumer.java
deleted file mode 100644
index 012ec82..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/PairConsumer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-/**
- * Function:
- * (T1, T2) -> void
- *
- * @param <T1> First argument type
- * @param <T2> Second argument type
- */
-public interface PairConsumer<T1, T2> extends Serializable {
- /**
- * Applies this function to {@code input1} and {@code input2}
- */
- void apply(T1 input1, T2 input2);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/PairFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/PairFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/PairFunction.java
deleted file mode 100644
index bfff400..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/PairFunction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-
-/**
- * Function:
- * (F1, F2) -> T
- *
- * @param <F1> First argument type
- * @param <F2> Second argument type
- * @param <T> Result type
- */
-public interface PairFunction<F1, F2, T> extends Serializable {
- /**
- * Returns the result of applying this function to given
- * {@code input1} and {@code input2}.
- *
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- T apply(F1 input1, F2 input2);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/PairPredicate.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/PairPredicate.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/PairPredicate.java
deleted file mode 100644
index 6d85e93..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/PairPredicate.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-/**
- * Function:
- * (T) -> boolean
- *
- * @param <T1> First argument type
- * @param <T2> Second argument type
- */
-public interface PairPredicate<T1, T2> extends Serializable {
- /**
- * Returns the result of applying this predicate to
- * {@code input1} and {@code input2}.
- */
- boolean apply(T1 input1, T2 input2);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/Predicate.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/Predicate.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/Predicate.java
deleted file mode 100644
index c515ca0..0000000
--- a/giraph-block-app/src/main/java/org/apache/giraph/function/Predicate.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-/**
- * Function:
- * (T) -> boolean
- * <br>
- * Specialization of com.google.common.base.Predicate, that is also
- * Serializable.
- *
- * @param <T> Argument type
- */
-public interface Predicate<T> extends Serializable {
- /**
- * Returns the result of applying this predicate to {@code input}.
- */
- boolean apply(T input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/Supplier.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/Supplier.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/Supplier.java
deleted file mode 100644
index 1813b54..0000000
--- a/giraph-block-app/src/main/java/org/apache/giraph/function/Supplier.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-/**
- * Function:
- * () -> T
- * <br>
- * Specialization of com.google.common.base.Supplier, that is also
- * Serializable.
- *
- * @param <T> Result type
- */
-public interface Supplier<T> extends Serializable {
- /**
- * Retrieves an instance of the appropriate type. The returned object may or
- * may not be a new instance, depending on the implementation.
- */
- T get();
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/TripleFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/TripleFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/TripleFunction.java
deleted file mode 100644
index b7609ca..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/TripleFunction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.function;
-
-import java.io.Serializable;
-
-/**
- * Function:
- * (F1, F2, F3) -> T
- *
- * @param <F1> First argument type
- * @param <F2> Second argument type
- * @param <F3> Third argument type
- * @param <T> Result type
- */
-public interface TripleFunction<F1, F2, F3, T> extends Serializable {
-
- /**
- * Returns the result of applying this function to given
- * {@code input1}, {@code input2} and {@code input3}.
- *
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- T apply(F1 input1, F2 input2, F3 input3);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/package-info.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/package-info.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/package-info.java
deleted file mode 100644
index b089da6..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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 for interfaces representing different functions,
- * that all extends Serializable in order for Kryo to be able
- * to serialize them.
- *
- * Even when same interface is present in Guava, we do not extend it
- * due to @Nullable annotations adding requirement of handling nulls.
- */
-package org.apache.giraph.function;
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
deleted file mode 100644
index 8b3c0a3..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * (double) -> T
- *
- * @param <T> Result type
- */
-public interface Double2ObjFunction<T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- *
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- T apply(double input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
deleted file mode 100644
index 4725d4b..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-
-/**
- * Primitive specialization of Function:
- * (double) -> void
- */
-public interface DoubleConsumer extends Serializable {
- /**
- * Applies this function to {@code input}
- */
- void apply(double input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Int2ObjFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Int2ObjFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Int2ObjFunction.java
deleted file mode 100644
index d082072..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Int2ObjFunction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * (int) -> T
- *
- * @param <T> Result type
- */
-public interface Int2ObjFunction<T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- *
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- T apply(int input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/IntSupplier.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/IntSupplier.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/IntSupplier.java
deleted file mode 100644
index d709895..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/IntSupplier.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * () -> int
- */
-public interface IntSupplier extends Serializable {
- /** Retrieves an int value. */
- int get();
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2DoubleFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2DoubleFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2DoubleFunction.java
deleted file mode 100644
index ad1ca8e..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2DoubleFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * (F) -> double
- *
- * @param <T> Argument type
- */
-public interface Obj2DoubleFunction<T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- */
- double apply(T value);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2FloatFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2FloatFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2FloatFunction.java
deleted file mode 100644
index b1a653f..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2FloatFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * (F) -> float
- *
- * @param <T> Argument type
- */
-public interface Obj2FloatFunction<T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- */
- float apply(T input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2IntFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2IntFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2IntFunction.java
deleted file mode 100644
index 6d3d739..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2IntFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * (F) -> int
- *
- * @param <T> Argument type
- */
-public interface Obj2IntFunction<T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- */
- int apply(T input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2LongFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2LongFunction.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2LongFunction.java
deleted file mode 100644
index 5300250..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/Obj2LongFunction.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.function.primitive;
-
-import java.io.Serializable;
-
-/**
- * Primitive specialization of Function:
- * (F) -> long
- *
- * @param <T> Argument type
- */
-public interface Obj2LongFunction<T> extends Serializable {
- /**
- * Returns the result of applying this function to given {@code input}.
- */
- long apply(T input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/PrimitiveRefs.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/PrimitiveRefs.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/PrimitiveRefs.java
deleted file mode 100644
index 9a9f742..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/PrimitiveRefs.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.function.primitive;
-
-/**
- * Convenience classes holding primitive values - a reference
- * to a mutable value.
- * For use when lambdas need to mutate capturing primitive local variable.
- * (since lambdas cannot capture and modify local variables)
- */
-public interface PrimitiveRefs {
-
- // Have public field for convenience, since classes have no logic inside
- // CHECKSTYLE: stop VisibilityModifierCheck
-
- /**
- * Convenience class holding int value,
- * for use when lambdas need to mutate capturing int local variable.
- */
- public class IntRef {
- public int value;
-
- public IntRef(int value) {
- this.value = value;
- }
- }
-
- /**
- * Convenience class holding long value,
- * for use when lambdas need to mutate capturing long local variable.
- */
- public class LongRef {
- public long value;
-
- public LongRef(long value) {
- this.value = value;
- }
- }
-
- /**
- * Convenience class holding int value,
- * for use when lambdas need to mutate capturing int local variable.
- */
- public class ShortRef {
- public short value;
-
- public ShortRef(short value) {
- this.value = value;
- }
- }
-
-
- /**
- * Convenience class holding float value,
- * for use when lambdas need to mutate capturing float local variable.
- */
- public class FloatRef {
- public float value;
-
- public FloatRef(float value) {
- this.value = value;
- }
- }
-
- /**
- * Convenience class holding double value,
- * for use when lambdas need to mutate capturing double local variable.
- */
- public class DoubleRef {
- public double value;
-
- public DoubleRef(double value) {
- this.value = value;
- }
- }
-
- /**
- * Convenience class holding object values,
- * for use when lambdas need to mutate capturing object local variable.
- *
- * <O> object
- */
- public class ObjRef<O> {
- public O value;
-
- public ObjRef(O value) {
- this.value = value;
- }
- }
-
- // CHECKSTYLE: resume VisibilityModifierCheck
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/package-info.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/package-info.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/package-info.java
deleted file mode 100644
index fdf40ff..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/primitive/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-/**
- * Primitive specializations of interfaces from org.apache.giraph.function
- * package.
- */
-package org.apache.giraph.function.primitive;
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/ConsumerWithVertex.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/ConsumerWithVertex.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/ConsumerWithVertex.java
deleted file mode 100644
index 87e7f9b..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/ConsumerWithVertex.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.function.vertex;
-
-import java.io.Serializable;
-
-import org.apache.giraph.function.PairConsumer;
-import org.apache.giraph.graph.Vertex;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-
-/**
- * Function:
- * (vertex, T) -> void
- *
- * A class that can consume objects of a single type, when given a vertex.
- *
- * @param <I> Vertex id type
- * @param <V> Vertex value type
- * @param <E> Edge value type
- * @param <T> Argument type
- */
-@SuppressWarnings("rawtypes")
-public interface ConsumerWithVertex<I extends WritableComparable,
- V extends Writable, E extends Writable, T>
- extends PairConsumer<Vertex<I, V, E>, T>, Serializable {
- /**
- * Applies this function to {@code vertex} and {@code input}
- */
- @Override
- void apply(Vertex<I, V, E> vertex, T value);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/FunctionWithVertex.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/FunctionWithVertex.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/FunctionWithVertex.java
deleted file mode 100644
index fdab5de..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/FunctionWithVertex.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.function.vertex;
-
-import java.io.Serializable;
-
-import org.apache.giraph.function.PairFunction;
-import org.apache.giraph.graph.Vertex;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Function:
- * (vertex, F) -> T
- *
- * Determines an output value based on a vertex and an input value.
- *
- * @param <I> Vertex id type
- * @param <V> Vertex value type
- * @param <E> Edge value type
- * @param <F> Argument type
- * @param <T> Result type
- */
-@SuppressWarnings("rawtypes")
-public interface FunctionWithVertex<I extends WritableComparable,
- V extends Writable, E extends Writable, F, T>
- extends PairFunction<Vertex<I, V, E>, F, T>, Serializable {
- /**
- * Returns the result of applying this function to given
- * {@code vertex} and {@code input}.
- *
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- @Override
- T apply(Vertex<I, V, E> vertex, F input);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/SupplierFromVertex.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/SupplierFromVertex.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/SupplierFromVertex.java
deleted file mode 100644
index bc0f9c1..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/SupplierFromVertex.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.function.vertex;
-
-import java.io.Serializable;
-
-import org.apache.giraph.graph.Vertex;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
-
-/**
- * Function:
- * (vertex) -> T
- *
- * A class that can supply objects of a single type, when given a vertex.
- *
- * (doesn't extend Function<Vertex<I, V, E>, T>, because of different
- * method names)
- *
- * @param <I> Vertex id type
- * @param <V> Vertex value type
- * @param <E> Edge value type
- * @param <T> Result type
- */
-@SuppressWarnings("rawtypes")
-public interface SupplierFromVertex<I extends WritableComparable,
- V extends Writable, E extends Writable, T> extends Serializable {
- /**
- * Retrieves an instance of the appropriate type, given a vertex.
- * The returned object may or may not be a new instance,
- * depending on the implementation.
- */
- T get(Vertex<I, V, E> vertex);
-}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/package-info.java
----------------------------------------------------------------------
diff --git
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/package-info.java
b/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/package-info.java
deleted file mode 100644
index bd5b019..0000000
---
a/giraph-block-app/src/main/java/org/apache/giraph/function/vertex/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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 for interfaces representing functions additionally
- * performed on vertex values.
- */
-package org.apache.giraph.function.vertex;
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/pom.xml
----------------------------------------------------------------------
diff --git a/giraph-core/pom.xml b/giraph-core/pom.xml
index e98741e..ddf3cd1 100644
--- a/giraph-core/pom.xml
+++ b/giraph-core/pom.xml
@@ -578,5 +578,12 @@ under the License.
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.23</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/Consumer.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/function/Consumer.java
b/giraph-core/src/main/java/org/apache/giraph/function/Consumer.java
new file mode 100644
index 0000000..b5d49ab
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/Consumer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+
+/**
+ * Function:
+ * (T) -> void
+ *
+ * @param <T> Argument type
+ */
+public interface Consumer<T> extends Serializable {
+ /**
+ * Applies this function to {@code input}
+ *
+ * @param input Input
+ */
+ void apply(T input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/Function.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/function/Function.java
b/giraph-core/src/main/java/org/apache/giraph/function/Function.java
new file mode 100644
index 0000000..3354fda
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/Function.java
@@ -0,0 +1,41 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+
+/**
+ * Function:
+ * (F) -> T
+ *
+ * @param <F> Argument type
+ * @param <T> Result type
+ */
+public interface Function<F, T> extends Serializable {
+ /**
+ * Returns the result of applying this function to given {@code input}.
+ *
+ * The returned object may or may not be a new instance,
+ * depending on the implementation.
+ *
+ * @param input Input
+ * @return result
+ */
+ T apply(F input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/ObjectHolder.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/ObjectHolder.java
b/giraph-core/src/main/java/org/apache/giraph/function/ObjectHolder.java
new file mode 100644
index 0000000..ffbe78d
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/ObjectHolder.java
@@ -0,0 +1,62 @@
+/*
+ * 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.function;
+
+/**
+ * Default object holder, intermediary between producers and consumers.
+ *
+ * Holds value in memory, so can be used only when producer and consumer
+ * are in the same context.
+ *
+ * Useful when value is set on the master, and later read in block logic
+ * (RepeatUntilBlock), or in a different Piece, either on worker or master.
+ * If it is read within the same piece - just use local field.
+ *
+ * @param <T> Type of object to hold.
+ */
+public class ObjectHolder<T> implements Supplier<T>, Consumer<T> {
+ /** value */
+ private T value;
+
+ /**
+ * Constructor
+ * @param value initial value
+ */
+ public ObjectHolder(T value) {
+ this.value = value;
+ }
+
+ /** Constructor */
+ public ObjectHolder() {
+ }
+
+ @Override
+ public T get() {
+ return value;
+ }
+
+ @Override
+ public void apply(T value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return getClass() + " [value=" + value + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/ObjectTransfer.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/ObjectTransfer.java
b/giraph-core/src/main/java/org/apache/giraph/function/ObjectTransfer.java
new file mode 100644
index 0000000..a67dd12
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/ObjectTransfer.java
@@ -0,0 +1,129 @@
+/*
+ * 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.function;
+
+import org.apache.giraph.function.vertex.ConsumerWithVertex;
+import org.apache.giraph.function.vertex.SupplierFromVertex;
+import org.apache.giraph.graph.Vertex;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.io.WritableComparable;
+
+/**
+ * Default object transfer, intermediary between producers and consumers.
+ *
+ * Holds value temporarily in memory, so can be used only when producer and
+ * consumer are in the same context. Nulls it out after supplying, so each
+ * object is returned only once, and second consecutive call to 'get' will
+ * return null.
+ *
+ * Useful for both:
+ *
+ * - passing data from vertexReceive function of WorkerReceivePiece of previous
+ * Piece to vertexSend function WorkerSendPiece of next Piece, of the same
+ * vertex.
+ * - when value is set on the master, and later read in block logic
+ * (RepeatUntilBlock), or in a different Piece, either on worker or master.
+ * If it is read within the same piece - just use local field.
+ *
+ * @param <T> Type of object to transfer.
+ */
+public class ObjectTransfer<T> implements Supplier<T>, Consumer<T> {
+ /** value */
+ private T value;
+
+ /**
+ * Constructor
+ * @param value initial value
+ */
+ public ObjectTransfer(T value) {
+ this.value = value;
+ }
+
+ /** Constructor */
+ public ObjectTransfer() {
+ }
+
+ @Override
+ public T get() {
+ T result = value;
+ value = null;
+ return result;
+ }
+
+ @Override
+ public void apply(T value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return getClass() + " [value=" + value + "]";
+ }
+
+ /**
+ * To be called when needing to pass it as a Supplier - making it
+ * obvious that K, V and E on supplier side can be any types,
+ * and to make code work without compile errors/warnings.
+ *
+ * In Java7, some callsites might need explicit types:
+ * object.<LongWritable, DoubleWritable, Writable>castToSupplier()
+ * In Java8, object.castToSupplier() is always going to be enough.
+ *
+ * @param <I> Vertex id type
+ * @param <V> Vertex value type
+ * @param <E> Edge value type
+ * @return supplier from vertex
+ */
+ // TODO Java8: cleanup callers
+ @SuppressWarnings("rawtypes")
+ public <I extends WritableComparable, V extends Writable, E extends Writable>
+ SupplierFromVertex<I, V, E, T> castToSupplier() {
+ return new SupplierFromVertex<I, V, E, T>() {
+ @Override
+ public T get(Vertex<I, V, E> vertex) {
+ return ObjectTransfer.this.get();
+ }
+ };
+ }
+
+ /**
+ * To be called when needing to pass it as a Consumer - making it
+ * obvious that K, V and E on consumer side can be any types,
+ * and to make code work without compile errors/warnings.
+ *
+ * In Java7, some callsites might need explicit types:
+ * object.<LongWritable, DoubleWritable, Writable>castToConsumer()
+ * In Java8, object.castToConsumer() is always going to be enough.
+ *
+ * @param <I> Vertex id type
+ * @param <V> Vertex value type
+ * @param <E> Edge value type
+ * @return consumer with vertex
+ */
+ // TODO Java8: cleanup callers
+ @SuppressWarnings("rawtypes")
+ public <I extends WritableComparable, V extends Writable, E extends Writable>
+ ConsumerWithVertex<I, V, E, T> castToConsumer() {
+ return new ConsumerWithVertex<I, V, E, T>() {
+ @Override
+ public void apply(Vertex<I, V, E> vertex, T value) {
+ ObjectTransfer.this.apply(value);
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/PairConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/PairConsumer.java
b/giraph-core/src/main/java/org/apache/giraph/function/PairConsumer.java
new file mode 100644
index 0000000..b1c633f
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/PairConsumer.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.function;
+
+import java.io.Serializable;
+
+/**
+ * Function:
+ * (T1, T2) -> void
+ *
+ * @param <T1> First argument type
+ * @param <T2> Second argument type
+ */
+public interface PairConsumer<T1, T2> extends Serializable {
+ /**
+ * Applies this function to {@code input1} and {@code input2}
+ *
+ * @param input1 first input
+ * @param input2 second input
+ */
+ void apply(T1 input1, T2 input2);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/PairFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/PairFunction.java
b/giraph-core/src/main/java/org/apache/giraph/function/PairFunction.java
new file mode 100644
index 0000000..49ee3bf
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/PairFunction.java
@@ -0,0 +1,44 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+
+/**
+ * Function:
+ * (F1, F2) -> T
+ *
+ * @param <F1> First argument type
+ * @param <F2> Second argument type
+ * @param <T> Result type
+ */
+public interface PairFunction<F1, F2, T> extends Serializable {
+ /**
+ * Returns the result of applying this function to given
+ * {@code input1} and {@code input2}.
+ *
+ * The returned object may or may not be a new instance,
+ * depending on the implementation.
+ *
+ * @param input1 first input
+ * @param input2 second input
+ * @return result
+ */
+ T apply(F1 input1, F2 input2);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/PairPredicate.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/PairPredicate.java
b/giraph-core/src/main/java/org/apache/giraph/function/PairPredicate.java
new file mode 100644
index 0000000..5203ef7
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/PairPredicate.java
@@ -0,0 +1,39 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+/**
+ * Function:
+ * (T) -> boolean
+ *
+ * @param <T1> First argument type
+ * @param <T2> Second argument type
+ */
+public interface PairPredicate<T1, T2> extends Serializable {
+ /**
+ * Returns the result of applying this predicate to
+ * {@code input1} and {@code input2}.
+ *
+ * @param input1 first input
+ * @param input2 second input
+ * @return result
+ */
+ boolean apply(T1 input1, T2 input2);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/Predicate.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/Predicate.java
b/giraph-core/src/main/java/org/apache/giraph/function/Predicate.java
new file mode 100644
index 0000000..0e4e3fd
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/Predicate.java
@@ -0,0 +1,39 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+/**
+ * Function:
+ * (T) -> boolean
+ * <br>
+ * Specialization of com.google.common.base.Predicate, that is also
+ * Serializable.
+ *
+ * @param <T> Argument type
+ */
+public interface Predicate<T> extends Serializable {
+ /**
+ * Returns the result of applying this predicate to {@code input}.
+ *
+ * @param input input
+ * @return result
+ */
+ boolean apply(T input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/Supplier.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/function/Supplier.java
b/giraph-core/src/main/java/org/apache/giraph/function/Supplier.java
new file mode 100644
index 0000000..ce746d0
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/Supplier.java
@@ -0,0 +1,39 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+/**
+ * Function:
+ * () -> T
+ * <br>
+ * Specialization of com.google.common.base.Supplier, that is also
+ * Serializable.
+ *
+ * @param <T> Result type
+ */
+public interface Supplier<T> extends Serializable {
+ /**
+ * Retrieves an instance of the appropriate type. The returned object may or
+ * may not be a new instance, depending on the implementation.
+ *
+ * @return result
+ */
+ T get();
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/TripleFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/TripleFunction.java
b/giraph-core/src/main/java/org/apache/giraph/function/TripleFunction.java
new file mode 100644
index 0000000..0c6a73c
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/TripleFunction.java
@@ -0,0 +1,45 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+
+/**
+ * Function:
+ * (F1, F2, F3) -> T
+ *
+ * @param <F1> First argument type
+ * @param <F2> Second argument type
+ * @param <F3> Third argument type
+ * @param <T> Result type
+ */
+public interface TripleFunction<F1, F2, F3, T> extends Serializable {
+ /**
+ * Returns the result of applying this function to given
+ * {@code input1}, {@code input2} and {@code input3}.
+ *
+ * The returned object may or may not be a new instance,
+ * depending on the implementation.
+ *
+ * @param input1 first input
+ * @param input2 second input
+ * @param input3 third input
+ * @return result
+ */
+ T apply(F1 input1, F2 input2, F3 input3);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/package-info.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/package-info.java
b/giraph-core/src/main/java/org/apache/giraph/function/package-info.java
new file mode 100644
index 0000000..b089da6
--- /dev/null
+++ b/giraph-core/src/main/java/org/apache/giraph/function/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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 for interfaces representing different functions,
+ * that all extends Serializable in order for Kryo to be able
+ * to serialize them.
+ *
+ * Even when same interface is present in Guava, we do not extend it
+ * due to @Nullable annotations adding requirement of handling nulls.
+ */
+package org.apache.giraph.function;
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanConsumer.java
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanConsumer.java
new file mode 100644
index 0000000..a3e7991
--- /dev/null
+++
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/BooleanConsumer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (boolean) -> void
+ */
+public interface BooleanConsumer extends Serializable {
+ /**
+ * Applies this function to {@code input}
+ *
+ * @param input input
+ */
+ void apply(boolean input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/primitive/ByteConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/ByteConsumer.java
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/ByteConsumer.java
new file mode 100644
index 0000000..a936be8
--- /dev/null
+++
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/ByteConsumer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (byte) -> void
+ */
+public interface ByteConsumer extends Serializable {
+ /**
+ * Applies this function to {@code input}
+ *
+ * @param input input
+ */
+ void apply(byte input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
new file mode 100644
index 0000000..3feca25
--- /dev/null
+++
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/Double2ObjFunction.java
@@ -0,0 +1,39 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+/**
+ * Primitive specialization of Function:
+ * (double) -> T
+ *
+ * @param <T> Result type
+ */
+public interface Double2ObjFunction<T> extends Serializable {
+ /**
+ * Returns the result of applying this function to given {@code input}.
+ *
+ * The returned object may or may not be a new instance,
+ * depending on the implementation.
+ *
+ * @param input input
+ * @return result
+ */
+ T apply(double input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
new file mode 100644
index 0000000..f34e595
--- /dev/null
+++
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/DoubleConsumer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (double) -> void
+ */
+public interface DoubleConsumer extends Serializable {
+ /**
+ * Applies this function to {@code input}
+ *
+ * @param input input
+ */
+ void apply(double input);
+}
http://git-wip-us.apache.org/repos/asf/giraph/blob/a927450a/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatConsumer.java
----------------------------------------------------------------------
diff --git
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatConsumer.java
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatConsumer.java
new file mode 100644
index 0000000..db2999e
--- /dev/null
+++
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/FloatConsumer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.function.primitive;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float) -> void
+ */
+public interface FloatConsumer extends Serializable {
+ /**
+ * Applies this function to {@code input}
+ *
+ * @param input input
+ */
+ void apply(float input);
+}