http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatDoublePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatDoublePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatDoublePredicate.java
new file mode 100644
index 0000000..e410711
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatDoublePredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, double) -> boolean
+ */
+public interface FloatDoublePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(float input1, double input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatConsumer.java
new file mode 100644
index 0000000..eb54a24
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, float) -> void
+ */
+public interface FloatFloatConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(float input1, float input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatPredicate.java
new file mode 100644
index 0000000..3abfcef
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatFloatPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, float) -> boolean
+ */
+public interface FloatFloatPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(float input1, float input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntConsumer.java
new file mode 100644
index 0000000..3842846
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, int) -> void
+ */
+public interface FloatIntConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(float input1, int input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntPredicate.java
new file mode 100644
index 0000000..d65be01
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatIntPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, int) -> boolean
+ */
+public interface FloatIntPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(float input1, int input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongConsumer.java
new file mode 100644
index 0000000..28bf849
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, long) -> void
+ */
+public interface FloatLongConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(float input1, long input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongPredicate.java
new file mode 100644
index 0000000..4a13e7d
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/FloatLongPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (float, long) -> boolean
+ */
+public interface FloatLongPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(float input1, long input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanConsumer.java
new file mode 100644
index 0000000..f9786d2
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, boolean) -> void
+ */
+public interface IntBooleanConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(int input1, boolean input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanPredicate.java
new file mode 100644
index 0000000..19e8dba
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBooleanPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, boolean) -> boolean
+ */
+public interface IntBooleanPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(int input1, boolean input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntByteConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntByteConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntByteConsumer.java
new file mode 100644
index 0000000..4578d2e
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntByteConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, byte) -> void
+ */
+public interface IntByteConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(int input1, byte input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBytePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBytePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBytePredicate.java
new file mode 100644
index 0000000..bc4d33f
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntBytePredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, byte) -> boolean
+ */
+public interface IntBytePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(int input1, byte input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoubleConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoubleConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoubleConsumer.java
new file mode 100644
index 0000000..29c721c
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoubleConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, double) -> void
+ */
+public interface IntDoubleConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(int input1, double input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoublePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoublePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoublePredicate.java
new file mode 100644
index 0000000..d8ef5c3
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntDoublePredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, double) -> boolean
+ */
+public interface IntDoublePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(int input1, double input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatConsumer.java
new file mode 100644
index 0000000..9ec2e00
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, float) -> void
+ */
+public interface IntFloatConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(int input1, float input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatPredicate.java
new file mode 100644
index 0000000..21cb455
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntFloatPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, float) -> boolean
+ */
+public interface IntFloatPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(int input1, float input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntConsumer.java
new file mode 100644
index 0000000..f08c5bd
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, int) -> void
+ */
+public interface IntIntConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(int input1, int input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntPredicate.java
new file mode 100644
index 0000000..d8d42b4
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntIntPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, int) -> boolean
+ */
+public interface IntIntPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(int input1, int input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongConsumer.java
new file mode 100644
index 0000000..8e8a258
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, long) -> void
+ */
+public interface IntLongConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(int input1, long input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongPredicate.java
new file mode 100644
index 0000000..b485bff
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/IntLongPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (int, long) -> boolean
+ */
+public interface IntLongPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(int input1, long input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanConsumer.java
new file mode 100644
index 0000000..57958a7
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, boolean) -> void
+ */
+public interface LongBooleanConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(long input1, boolean input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanPredicate.java
new file mode 100644
index 0000000..951e893
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBooleanPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, boolean) -> boolean
+ */
+public interface LongBooleanPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(long input1, boolean input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongByteConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongByteConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongByteConsumer.java
new file mode 100644
index 0000000..ff94dd5
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongByteConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, byte) -> void
+ */
+public interface LongByteConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(long input1, byte input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBytePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBytePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBytePredicate.java
new file mode 100644
index 0000000..bf30a1e
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongBytePredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, byte) -> boolean
+ */
+public interface LongBytePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(long input1, byte input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoubleConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoubleConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoubleConsumer.java
new file mode 100644
index 0000000..a4e6372
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoubleConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, double) -> void
+ */
+public interface LongDoubleConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(long input1, double input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoublePredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoublePredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoublePredicate.java
new file mode 100644
index 0000000..01a9541
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongDoublePredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, double) -> boolean
+ */
+public interface LongDoublePredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(long input1, double input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatConsumer.java
new file mode 100644
index 0000000..3747a39
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, float) -> void
+ */
+public interface LongFloatConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(long input1, float input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatPredicate.java
new file mode 100644
index 0000000..0330582
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongFloatPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, float) -> boolean
+ */
+public interface LongFloatPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(long input1, float input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntConsumer.java
new file mode 100644
index 0000000..b8d1d41
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, int) -> void
+ */
+public interface LongIntConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(long input1, int input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntPredicate.java
new file mode 100644
index 0000000..95b2834
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongIntPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, int) -> boolean
+ */
+public interface LongIntPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(long input1, int input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongConsumer.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongConsumer.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongConsumer.java
new file mode 100644
index 0000000..5d7085f
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongConsumer.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.primitive.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, long) -> void
+ */
+public interface LongLongConsumer extends Serializable {
+  /**
+   * Applies this function to {@code input1} and {@code input2}
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   */
+  void apply(long input1, long input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongPredicate.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongPredicate.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongPredicate.java
new file mode 100644
index 0000000..0bc7f61
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/LongLongPredicate.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pairs;
+
+import java.io.Serializable;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Primitive specialization of Function:
+ * (long, long) -> boolean
+ */
+public interface LongLongPredicate extends Serializable {
+  /**
+   * Returns the result of applying this predicate to {@code input}.
+   *
+   * @param input1 First input
+   * @param input2 Second input
+   * @return result
+   */
+  boolean apply(long input1, long input2);
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/package-info.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/package-info.java
 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/package-info.java
new file mode 100644
index 0000000..f4e5152
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/function/primitive/pairs/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 {@link org.apache.giraph.function.PairConsumer}
+ * and {@link org.apache.giraph.function.PairPredicate}
+ */
+package org.apache.giraph.function.primitive.pairs;

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntByteMinHeap.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntByteMinHeap.java
 
b/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntByteMinHeap.java
new file mode 100644
index 0000000..003f355
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntByteMinHeap.java
@@ -0,0 +1,361 @@
+/*
+ * 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.types.heaps;
+
+import it.unimi.dsi.fastutil.ints.AbstractInt2ByteMap;
+import it.unimi.dsi.fastutil.ints.Int2ByteMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.NoSuchElementException;
+
+import org.apache.giraph.function.primitive.pairs.IntByteConsumer;
+import org.apache.giraph.function.primitive.pairs.IntBytePredicate;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Min heap which holds (int key, byte value) pairs with
+ * the largest values as its elements, up to the given maximum number of
+ * elements.
+ *
+ * When multiple elements with same values are added and there is no space for
+ * all of them in the heap, the one with larger keys will be kept in the heap.
+ *
+ * You can remove a pair with the minimum value currently in the heap.
+ */
+public class FixedCapacityIntByteMinHeap
+    implements Int2ByteMapEntryIterable {
+  /** Keys in the heap */
+  private final int[] keys;
+  /** Values in the heap */
+  private final byte[] values;
+  /** Number of elements currently in the heap */
+  private int size;
+  /** Capacity of the heap */
+  private final int capacity;
+  /** Reusable iterator instance */
+  private final IteratorImpl iterator;
+
+  /**
+   * Initialize the heap with desired capacity
+   *
+   * @param capacity Capacity
+   */
+  public FixedCapacityIntByteMinHeap(int capacity) {
+    keys = new int[capacity];
+    values = new byte[capacity];
+    size = 0;
+    this.capacity = capacity;
+    iterator = new IteratorImpl();
+  }
+
+  /** Clear the heap */
+  public void clear() {
+    size = 0;
+  }
+
+  /**
+   * Add a key value pair
+   *
+   * @param key   Key
+   * @param value Value
+   */
+  public void add(int key, byte value) {
+    if (size == capacity && compare(keys[0], values[0], key, value) >= 0) {
+      // If the heap is full and smallest element in it is not smaller
+      // than value, do nothing
+      return;
+    }
+    int position;
+    if (size < capacity) {
+      // If the heap is not full, increase its size and find the position for
+      // new element (up-heap search)
+      position = size;
+      size++;
+      while (position > 0) {
+        int parent = (position - 1) >> 1;
+        if (compare(keys[parent], values[parent], key, value) < 0) {
+          break;
+        }
+        values[position] = values[parent];
+        keys[position] = keys[parent];
+        position = parent;
+      }
+    } else {
+      // If the heap is full, remove element from the root and find the 
position
+      // for new element (down-heap search)
+      position = removeRootAndFindPosition(key, value);
+    }
+    // Fill position with key value pair
+    keys[position] = key;
+    values[position] = value;
+  }
+
+  /**
+   * @return Key corresponding to the minimum value currently in the heap
+   * @throws NoSuchElementException if the heap is empty.
+   */
+  public int getMinKey() {
+    if (size() > 0) {
+      return keys[0];
+    } else {
+      throw new NoSuchElementException();
+    }
+  }
+
+  /**
+   * @return Minimum value currently in the heap
+   * @throws NoSuchElementException if the heap is empty.
+   */
+  public byte getMinValue() {
+    if (size() > 0) {
+      return values[0];
+    } else {
+      throw new NoSuchElementException();
+    }
+  }
+
+  /**
+   * Removes the (key, value) pair that corresponds to the minimum value
+   * currently in the heap.
+   */
+  public void removeMin() {
+    if (size() > 0) {
+      size--;
+      int position = removeRootAndFindPosition(keys[size], values[size]);
+      keys[position] = keys[size];
+      values[position] = values[size];
+    }
+  }
+
+  /**
+   * Comapre two (key, value) entries
+   *
+   * @param key1   First key
+   * @param value1 First value
+   * @param key2   Second key
+   * @param value2 Second value
+   * @return 0 if entries are equal, < 0 if first entry is smaller than the
+   * second one, and > 0 if first entry is larger than the second one
+   */
+  protected int compare(int key1, byte value1,
+      int key2, byte value2) {
+    int t = Byte.compare(value1, value2);
+    return (t == 0) ? Integer.compare(key1, key2) : t;
+  }
+
+  @Override
+  public ObjectIterator<Int2ByteMap.Entry> iterator() {
+    iterator.reset();
+    return iterator;
+  }
+
+  @Override
+  public int size() {
+    return size;
+  }
+
+  /**
+   * Check if the heap is empty
+   *
+   * @return True iff the heap is empty
+   */
+  public boolean isEmpty() {
+    return size == 0;
+  }
+
+  /**
+   * Get capacity of the heap
+   *
+   * @return Heap capacity
+   */
+  public int getCapacity() {
+    return capacity;
+  }
+
+  /**
+   * Serializes an object into data output.
+   *
+   * @param heap Object instance to serialize
+   * @param out  Data output
+   * @throws java.io.IOException
+   */
+  public static void write(FixedCapacityIntByteMinHeap heap,
+      DataOutput out) throws IOException {
+    out.writeInt(heap.capacity);
+    out.writeInt(heap.size);
+    for (int i = 0; i < heap.size(); i++) {
+      out.writeInt(heap.keys[i]);
+      out.writeByte(heap.values[i]);
+    }
+  }
+
+  /**
+   * Deserializes an object from data input.
+   *
+   * @param heap Object to reuse if possible
+   * @param in   Data input
+   * @return FixedCapacityIntByteMinHeap deserialized from data input.
+   * @throws IOException
+   */
+  public static FixedCapacityIntByteMinHeap read(
+      FixedCapacityIntByteMinHeap heap, DataInput in)
+      throws IOException {
+    int capacity = in.readInt();
+    if (heap == null || heap.capacity != capacity) {
+      heap = new FixedCapacityIntByteMinHeap(capacity);
+    } else {
+      heap.clear();
+    }
+    heap.size = in.readInt();
+    for (int i = 0; i < heap.size; i++) {
+      heap.keys[i] = in.readInt();
+      heap.values[i] = in.readByte();
+    }
+    return heap;
+  }
+
+  /**
+   * Takes a (key, value) pair, removes the root of the heap, and finds
+   * a position where the pair can be inserted.
+   *
+   * @param key   Key
+   * @param value Value
+   * @return Position in the heap where the (key, value) pair can be inserted
+   * while preserving the heap property.
+   */
+  private int removeRootAndFindPosition(int key, byte value) {
+    int position = 0;
+    while (position < size) {
+      // Find the left child
+      int minChild = (position << 1) + 1;
+      // Compare the left and the right child values - find the smaller one
+      if (minChild + 1 < size &&
+          compare(keys[minChild + 1], values[minChild + 1],
+              keys[minChild], values[minChild]) < 0) {
+        minChild++;
+      }
+      if (minChild >= size || compare(keys[minChild], values[minChild],
+          key, value) >= 0) {
+        break;
+      }
+      keys[position] = keys[minChild];
+      values[position] = values[minChild];
+      position = minChild;
+    }
+    return position;
+  }
+
+  /**
+   * Traverse all elements of the heap, calling given function on each element.
+   *
+   * @param f Function to call on each element.
+   */
+  public void forEachIntByte(IntByteConsumer f) {
+    for (int i = 0; i < size(); ++i) {
+      f.apply(keys[i], values[i]);
+    }
+  }
+
+  /**
+   * Traverse all elements of the heap, calling given function on each element,
+   * or until predicate returns false.
+   *
+   * @param f Function to call on each element.
+   * @return true if the predicate returned true for all elements,
+   *    false if it returned false for some element.
+   */
+  public boolean forEachWhileIntByte(IntBytePredicate f) {
+    for (int i = 0; i < size(); ++i) {
+      if (!f.apply(keys[i], values[i])) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /** Iterator for FixedCapacityIntByteMinHeap */
+  private class IteratorImpl implements ObjectIterator<Int2ByteMap.Entry> {
+    /** Reusable entry */
+    private final MutableEntry entry = new MutableEntry();
+    /** Current index */
+    private int index;
+
+    /** Reset the iterator so it can be reused */
+    public void reset() {
+      index = -1;
+    }
+
+    @Override
+    public boolean hasNext() {
+      return index < size - 1;
+    }
+
+    @Override
+    public Int2ByteMap.Entry next() {
+      if (!hasNext()) {
+        throw new NoSuchElementException();
+      }
+      index++;
+      entry.setIntKey(keys[index]);
+      entry.setByteValue(values[index]);
+      return entry;
+    }
+
+    @Override
+    public void remove() {
+      throw new UnsupportedOperationException("remove() shouldn't be called");
+    }
+
+    @Override
+    public int skip(int i) {
+      throw new UnsupportedOperationException("skip(int) shouldn't be called");
+    }
+  }
+
+  /** Helper mutable Entry class */
+  private static class MutableEntry extends AbstractInt2ByteMap.BasicEntry {
+    /** Default constructor */
+    private MutableEntry() {
+      super(0, (byte) 0);
+    }
+
+    /**
+     * Set key
+     *
+     * @param key Key to set
+     */
+    private void setIntKey(int key) {
+      this.key = key;
+    }
+
+    /**
+     * Set value
+     *
+     * @param value Value to set
+     */
+    private void setByteValue(byte value) {
+      this.value = value;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/4321e448/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntDoubleMinHeap.java
----------------------------------------------------------------------
diff --git 
a/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntDoubleMinHeap.java
 
b/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntDoubleMinHeap.java
new file mode 100644
index 0000000..02cb667
--- /dev/null
+++ 
b/giraph-core/src/main/java/org/apache/giraph/types/heaps/FixedCapacityIntDoubleMinHeap.java
@@ -0,0 +1,361 @@
+/*
+ * 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.types.heaps;
+
+import it.unimi.dsi.fastutil.ints.AbstractInt2DoubleMap;
+import it.unimi.dsi.fastutil.ints.Int2DoubleMap;
+import it.unimi.dsi.fastutil.objects.ObjectIterator;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.NoSuchElementException;
+
+import org.apache.giraph.function.primitive.pairs.IntDoubleConsumer;
+import org.apache.giraph.function.primitive.pairs.IntDoublePredicate;
+
+// AUTO-GENERATED class via class:
+// org.apache.giraph.generate.GeneratePrimitiveClasses
+
+/**
+ * Min heap which holds (int key, double value) pairs with
+ * the largest values as its elements, up to the given maximum number of
+ * elements.
+ *
+ * When multiple elements with same values are added and there is no space for
+ * all of them in the heap, the one with larger keys will be kept in the heap.
+ *
+ * You can remove a pair with the minimum value currently in the heap.
+ */
+public class FixedCapacityIntDoubleMinHeap
+    implements Int2DoubleMapEntryIterable {
+  /** Keys in the heap */
+  private final int[] keys;
+  /** Values in the heap */
+  private final double[] values;
+  /** Number of elements currently in the heap */
+  private int size;
+  /** Capacity of the heap */
+  private final int capacity;
+  /** Reusable iterator instance */
+  private final IteratorImpl iterator;
+
+  /**
+   * Initialize the heap with desired capacity
+   *
+   * @param capacity Capacity
+   */
+  public FixedCapacityIntDoubleMinHeap(int capacity) {
+    keys = new int[capacity];
+    values = new double[capacity];
+    size = 0;
+    this.capacity = capacity;
+    iterator = new IteratorImpl();
+  }
+
+  /** Clear the heap */
+  public void clear() {
+    size = 0;
+  }
+
+  /**
+   * Add a key value pair
+   *
+   * @param key   Key
+   * @param value Value
+   */
+  public void add(int key, double value) {
+    if (size == capacity && compare(keys[0], values[0], key, value) >= 0) {
+      // If the heap is full and smallest element in it is not smaller
+      // than value, do nothing
+      return;
+    }
+    int position;
+    if (size < capacity) {
+      // If the heap is not full, increase its size and find the position for
+      // new element (up-heap search)
+      position = size;
+      size++;
+      while (position > 0) {
+        int parent = (position - 1) >> 1;
+        if (compare(keys[parent], values[parent], key, value) < 0) {
+          break;
+        }
+        values[position] = values[parent];
+        keys[position] = keys[parent];
+        position = parent;
+      }
+    } else {
+      // If the heap is full, remove element from the root and find the 
position
+      // for new element (down-heap search)
+      position = removeRootAndFindPosition(key, value);
+    }
+    // Fill position with key value pair
+    keys[position] = key;
+    values[position] = value;
+  }
+
+  /**
+   * @return Key corresponding to the minimum value currently in the heap
+   * @throws NoSuchElementException if the heap is empty.
+   */
+  public int getMinKey() {
+    if (size() > 0) {
+      return keys[0];
+    } else {
+      throw new NoSuchElementException();
+    }
+  }
+
+  /**
+   * @return Minimum value currently in the heap
+   * @throws NoSuchElementException if the heap is empty.
+   */
+  public double getMinValue() {
+    if (size() > 0) {
+      return values[0];
+    } else {
+      throw new NoSuchElementException();
+    }
+  }
+
+  /**
+   * Removes the (key, value) pair that corresponds to the minimum value
+   * currently in the heap.
+   */
+  public void removeMin() {
+    if (size() > 0) {
+      size--;
+      int position = removeRootAndFindPosition(keys[size], values[size]);
+      keys[position] = keys[size];
+      values[position] = values[size];
+    }
+  }
+
+  /**
+   * Comapre two (key, value) entries
+   *
+   * @param key1   First key
+   * @param value1 First value
+   * @param key2   Second key
+   * @param value2 Second value
+   * @return 0 if entries are equal, < 0 if first entry is smaller than the
+   * second one, and > 0 if first entry is larger than the second one
+   */
+  protected int compare(int key1, double value1,
+      int key2, double value2) {
+    int t = Double.compare(value1, value2);
+    return (t == 0) ? Integer.compare(key1, key2) : t;
+  }
+
+  @Override
+  public ObjectIterator<Int2DoubleMap.Entry> iterator() {
+    iterator.reset();
+    return iterator;
+  }
+
+  @Override
+  public int size() {
+    return size;
+  }
+
+  /**
+   * Check if the heap is empty
+   *
+   * @return True iff the heap is empty
+   */
+  public boolean isEmpty() {
+    return size == 0;
+  }
+
+  /**
+   * Get capacity of the heap
+   *
+   * @return Heap capacity
+   */
+  public int getCapacity() {
+    return capacity;
+  }
+
+  /**
+   * Serializes an object into data output.
+   *
+   * @param heap Object instance to serialize
+   * @param out  Data output
+   * @throws java.io.IOException
+   */
+  public static void write(FixedCapacityIntDoubleMinHeap heap,
+      DataOutput out) throws IOException {
+    out.writeInt(heap.capacity);
+    out.writeInt(heap.size);
+    for (int i = 0; i < heap.size(); i++) {
+      out.writeInt(heap.keys[i]);
+      out.writeDouble(heap.values[i]);
+    }
+  }
+
+  /**
+   * Deserializes an object from data input.
+   *
+   * @param heap Object to reuse if possible
+   * @param in   Data input
+   * @return FixedCapacityIntDoubleMinHeap deserialized from data input.
+   * @throws IOException
+   */
+  public static FixedCapacityIntDoubleMinHeap read(
+      FixedCapacityIntDoubleMinHeap heap, DataInput in)
+      throws IOException {
+    int capacity = in.readInt();
+    if (heap == null || heap.capacity != capacity) {
+      heap = new FixedCapacityIntDoubleMinHeap(capacity);
+    } else {
+      heap.clear();
+    }
+    heap.size = in.readInt();
+    for (int i = 0; i < heap.size; i++) {
+      heap.keys[i] = in.readInt();
+      heap.values[i] = in.readDouble();
+    }
+    return heap;
+  }
+
+  /**
+   * Takes a (key, value) pair, removes the root of the heap, and finds
+   * a position where the pair can be inserted.
+   *
+   * @param key   Key
+   * @param value Value
+   * @return Position in the heap where the (key, value) pair can be inserted
+   * while preserving the heap property.
+   */
+  private int removeRootAndFindPosition(int key, double value) {
+    int position = 0;
+    while (position < size) {
+      // Find the left child
+      int minChild = (position << 1) + 1;
+      // Compare the left and the right child values - find the smaller one
+      if (minChild + 1 < size &&
+          compare(keys[minChild + 1], values[minChild + 1],
+              keys[minChild], values[minChild]) < 0) {
+        minChild++;
+      }
+      if (minChild >= size || compare(keys[minChild], values[minChild],
+          key, value) >= 0) {
+        break;
+      }
+      keys[position] = keys[minChild];
+      values[position] = values[minChild];
+      position = minChild;
+    }
+    return position;
+  }
+
+  /**
+   * Traverse all elements of the heap, calling given function on each element.
+   *
+   * @param f Function to call on each element.
+   */
+  public void forEachIntDouble(IntDoubleConsumer f) {
+    for (int i = 0; i < size(); ++i) {
+      f.apply(keys[i], values[i]);
+    }
+  }
+
+  /**
+   * Traverse all elements of the heap, calling given function on each element,
+   * or until predicate returns false.
+   *
+   * @param f Function to call on each element.
+   * @return true if the predicate returned true for all elements,
+   *    false if it returned false for some element.
+   */
+  public boolean forEachWhileIntDouble(IntDoublePredicate f) {
+    for (int i = 0; i < size(); ++i) {
+      if (!f.apply(keys[i], values[i])) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /** Iterator for FixedCapacityIntDoubleMinHeap */
+  private class IteratorImpl implements ObjectIterator<Int2DoubleMap.Entry> {
+    /** Reusable entry */
+    private final MutableEntry entry = new MutableEntry();
+    /** Current index */
+    private int index;
+
+    /** Reset the iterator so it can be reused */
+    public void reset() {
+      index = -1;
+    }
+
+    @Override
+    public boolean hasNext() {
+      return index < size - 1;
+    }
+
+    @Override
+    public Int2DoubleMap.Entry next() {
+      if (!hasNext()) {
+        throw new NoSuchElementException();
+      }
+      index++;
+      entry.setIntKey(keys[index]);
+      entry.setDoubleValue(values[index]);
+      return entry;
+    }
+
+    @Override
+    public void remove() {
+      throw new UnsupportedOperationException("remove() shouldn't be called");
+    }
+
+    @Override
+    public int skip(int i) {
+      throw new UnsupportedOperationException("skip(int) shouldn't be called");
+    }
+  }
+
+  /** Helper mutable Entry class */
+  private static class MutableEntry extends AbstractInt2DoubleMap.BasicEntry {
+    /** Default constructor */
+    private MutableEntry() {
+      super(0, 0);
+    }
+
+    /**
+     * Set key
+     *
+     * @param key Key to set
+     */
+    private void setIntKey(int key) {
+      this.key = key;
+    }
+
+    /**
+     * Set value
+     *
+     * @param value Value to set
+     */
+    private void setDoubleValue(double value) {
+      this.value = value;
+    }
+  }
+}

Reply via email to