giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgho...@apache.org
Subject svn commit: r1352585 [2/2] - in /giraph/trunk: ./ src/main/java/org/apache/giraph/aggregators/ src/main/java/org/apache/giraph/benchmark/ src/main/java/org/apache/giraph/examples/ src/test/java/org/apache/giraph/ src/test/java/org/apache/giraph/aggrega...
Date Thu, 21 Jun 2012 16:02:09 GMT
Added: giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java?rev=1352585&view=auto
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java (added)
+++ giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestFloatAggregators.java Thu
Jun 21 16:02:07 2012
@@ -0,0 +1,101 @@
+/*
+ * 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.0f (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.0f
+ *
+ * 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.aggregators;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.hadoop.io.FloatWritable;
+import org.junit.Test;
+
+public class TestFloatAggregators {
+
+  @Test
+  public void testAverageAggregator() {
+    FloatAverageAggregator max = new FloatAverageAggregator();
+    max.aggregate(1.0f);
+    max.aggregate(new FloatWritable(3.0f));
+    assertEquals(2.0f, max.getAggregatedValue().get());
+    max.resetAggregatedValue();
+    assertEquals(0.0f, max.getAggregatedValue().get());
+    FloatWritable fw = max.createAggregatedValue();
+    assertNotNull(fw);
+  }
+  
+  @Test
+  public void testMaxAggregator() {
+    FloatMaxAggregator max = new FloatMaxAggregator();
+    max.aggregate(2.0f);
+    max.aggregate(new FloatWritable(3.0f));
+    assertEquals(3.0f, max.getAggregatedValue().get());
+    max.setAggregatedValue(1.0f);
+    assertEquals(1.0f, max.getAggregatedValue().get());
+    FloatWritable fw = max.createAggregatedValue();
+    assertNotNull(fw);
+  }
+
+  @Test
+  public void testMinAggregator() {
+    FloatMinAggregator min = new FloatMinAggregator();
+    min.aggregate(3.0f);
+    min.aggregate(new FloatWritable(2.0f));
+    assertEquals(2.0f, min.getAggregatedValue().get());
+    min.setAggregatedValue(3.0f);
+    assertEquals(3.0f, min.getAggregatedValue().get());
+    FloatWritable fw = min.createAggregatedValue();
+    assertNotNull(fw);
+  }
+
+  @Test
+  public void testOverwriteAggregator() {
+    FloatOverwriteAggregator overwrite = new FloatOverwriteAggregator();
+    overwrite.aggregate(1.0f);
+    assertEquals(1.0f, overwrite.getAggregatedValue().get());
+    overwrite.aggregate(new FloatWritable(2.0f));
+    assertEquals(2.0f, overwrite.getAggregatedValue().get());
+    overwrite.setAggregatedValue(3.0f);
+    assertEquals(3.0f, overwrite.getAggregatedValue().get());
+    FloatWritable fw = overwrite.createAggregatedValue();
+    assertNotNull(fw);
+  }
+  
+  @Test
+  public void testProductAggregator() {
+    FloatProductAggregator product = new FloatProductAggregator();
+    product.aggregate(6.0f);
+    product.aggregate(new FloatWritable(7.0f));
+    assertEquals(42.0f, product.getAggregatedValue().get());
+    product.setAggregatedValue(1.0f);
+    assertEquals(1.0f, product.getAggregatedValue().get());
+    FloatWritable fw = product.createAggregatedValue();
+    assertNotNull(fw);
+  }
+
+  @Test
+  public void testSumAggregator() {
+    FloatSumAggregator sum = new FloatSumAggregator();
+    sum.aggregate(1.0f);
+    sum.aggregate(new FloatWritable(2.0f));
+    assertEquals(3.0f, sum.getAggregatedValue().get());
+    sum.setAggregatedValue(4.0f);
+    assertEquals(4.0f, sum.getAggregatedValue().get());
+    FloatWritable fw = sum.createAggregatedValue();
+    assertNotNull(fw);
+  }
+
+}

Added: giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestIntAggregators.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestIntAggregators.java?rev=1352585&view=auto
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestIntAggregators.java (added)
+++ giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestIntAggregators.java Thu Jun
21 16:02:07 2012
@@ -0,0 +1,89 @@
+/*
+ * 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.aggregators;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.hadoop.io.IntWritable;
+import org.junit.Test;
+
+public class TestIntAggregators {
+
+  @Test
+  public void testMaxAggregator() {
+    IntMaxAggregator max = new IntMaxAggregator();
+    max.aggregate(2);
+    max.aggregate(new IntWritable(3));
+    assertEquals(3, max.getAggregatedValue().get());
+    max.setAggregatedValue(1);
+    assertEquals(1, max.getAggregatedValue().get());
+    IntWritable iw = max.createAggregatedValue();
+    assertNotNull(iw);
+  }
+
+  @Test
+  public void testMinAggregator() {
+    IntMinAggregator min = new IntMinAggregator();
+    min.aggregate(3);
+    min.aggregate(new IntWritable(2));
+    assertEquals(2, min.getAggregatedValue().get());
+    min.setAggregatedValue(3);
+    assertEquals(3, min.getAggregatedValue().get());
+    IntWritable iw = min.createAggregatedValue();
+    assertNotNull(iw);
+  }
+
+  @Test
+  public void testOverwriteAggregator() {
+    IntOverwriteAggregator overwrite = new IntOverwriteAggregator();
+    overwrite.aggregate(1);
+    assertEquals(1, overwrite.getAggregatedValue().get());
+    overwrite.aggregate(new IntWritable(2));
+    assertEquals(2, overwrite.getAggregatedValue().get());
+    overwrite.setAggregatedValue(3);
+    assertEquals(3, overwrite.getAggregatedValue().get());
+    IntWritable iw = overwrite.createAggregatedValue();
+    assertNotNull(iw);
+  }
+  
+  @Test
+  public void testProductAggregator() {
+    IntProductAggregator product = new IntProductAggregator();
+    product.aggregate(6);
+    product.aggregate(new IntWritable(7));
+    assertEquals(42, product.getAggregatedValue().get());
+    product.setAggregatedValue(1);
+    assertEquals(1, product.getAggregatedValue().get());
+    IntWritable iw = product.createAggregatedValue();
+    assertNotNull(iw);
+  }
+
+  @Test
+  public void testSumAggregator() {
+    IntSumAggregator sum = new IntSumAggregator();
+    sum.aggregate(1);
+    sum.aggregate(new IntWritable(2));
+    assertEquals(3, sum.getAggregatedValue().get());
+    sum.setAggregatedValue(4);
+    assertEquals(4, sum.getAggregatedValue().get());
+    IntWritable iw = sum.createAggregatedValue();
+    assertNotNull(iw);
+  }
+
+}

Added: giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestLongAggregators.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestLongAggregators.java?rev=1352585&view=auto
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestLongAggregators.java (added)
+++ giraph/trunk/src/test/java/org/apache/giraph/aggregators/TestLongAggregators.java Thu
Jun 21 16:02:07 2012
@@ -0,0 +1,89 @@
+/*
+ * 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.aggregators;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Test;
+
+public class TestLongAggregators {
+
+  @Test
+  public void testMaxAggregator() {
+    LongMaxAggregator max = new LongMaxAggregator();
+    max.aggregate(2L);
+    max.aggregate(new LongWritable(3L));
+    assertEquals(3L, max.getAggregatedValue().get());
+    max.setAggregatedValue(1L);
+    assertEquals(1L, max.getAggregatedValue().get());
+    LongWritable lw = max.createAggregatedValue();
+    assertNotNull(lw);
+  }
+
+  @Test
+  public void testMinAggregator() {
+    LongMinAggregator min = new LongMinAggregator();
+    min.aggregate(3L);
+    min.aggregate(new LongWritable(2L));
+    assertEquals(2L, min.getAggregatedValue().get());
+    min.setAggregatedValue(3L);
+    assertEquals(3L, min.getAggregatedValue().get());
+    LongWritable lw = min.createAggregatedValue();
+    assertNotNull(lw);
+  }
+
+  @Test
+  public void testOverwriteAggregator() {
+    LongOverwriteAggregator overwrite = new LongOverwriteAggregator();
+    overwrite.aggregate(1L);
+    assertEquals(1L, overwrite.getAggregatedValue().get());
+    overwrite.aggregate(new LongWritable(2L));
+    assertEquals(2L, overwrite.getAggregatedValue().get());
+    overwrite.setAggregatedValue(3L);
+    assertEquals(3L, overwrite.getAggregatedValue().get());
+    LongWritable lw = overwrite.createAggregatedValue();
+    assertNotNull(lw);
+  }
+  
+  @Test
+  public void testProductAggregator() {
+    LongProductAggregator product = new LongProductAggregator();
+    product.aggregate(6L);
+    product.aggregate(new LongWritable(7L));
+    assertEquals(42L, product.getAggregatedValue().get());
+    product.setAggregatedValue(1L);
+    assertEquals(1L, product.getAggregatedValue().get());
+    LongWritable lw = product.createAggregatedValue();
+    assertNotNull(lw);
+  }
+
+  @Test
+  public void testSumAggregator() {
+    LongSumAggregator sum = new LongSumAggregator();
+    sum.aggregate(1L);
+    sum.aggregate(new LongWritable(2L));
+    assertEquals(3L, sum.getAggregatedValue().get());
+    sum.setAggregatedValue(4L);
+    assertEquals(4L, sum.getAggregatedValue().get());
+    LongWritable lw = sum.createAggregatedValue();
+    assertNotNull(lw);
+  }
+
+}



Mime
View raw message