incubator-crunch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwi...@apache.org
Subject git commit: Fix nested table test for Avro PTypes
Date Tue, 03 Jul 2012 15:12:11 GMT
Updated Branches:
  refs/heads/master 2232d0a7a -> a69bda8f5


Fix nested table test for Avro PTypes


Project: http://git-wip-us.apache.org/repos/asf/incubator-crunch/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-crunch/commit/a69bda8f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-crunch/tree/a69bda8f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-crunch/diff/a69bda8f

Branch: refs/heads/master
Commit: a69bda8f50b6ed227cf28a3a59da0c0c2d379dcc
Parents: 2232d0a
Author: Josh Wills <jwills@cloudera.com>
Authored: Tue Jul 3 08:11:57 2012 -0700
Committer: Josh Wills <jwills@cloudera.com>
Committed: Tue Jul 3 08:11:57 2012 -0700

----------------------------------------------------------------------
 .../java/com/cloudera/crunch/types/avro/Avros.java |    9 +++++++++
 .../com/cloudera/crunch/types/avro/AvrosTest.java  |    4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-crunch/blob/a69bda8f/src/main/java/com/cloudera/crunch/types/avro/Avros.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/cloudera/crunch/types/avro/Avros.java b/src/main/java/com/cloudera/crunch/types/avro/Avros.java
index d2edae2..59237fc 100644
--- a/src/main/java/com/cloudera/crunch/types/avro/Avros.java
+++ b/src/main/java/com/cloudera/crunch/types/avro/Avros.java
@@ -44,6 +44,7 @@ import com.cloudera.crunch.Tuple4;
 import com.cloudera.crunch.TupleN;
 import com.cloudera.crunch.fn.CompositeMapFn;
 import com.cloudera.crunch.fn.IdentityFn;
+import com.cloudera.crunch.types.PTableType;
 import com.cloudera.crunch.types.PType;
 import com.cloudera.crunch.types.TupleFactory;
 import com.cloudera.crunch.util.PTypes;
@@ -601,6 +602,14 @@ public class Avros {
 
 	public static final <K, V> AvroTableType<K, V> tableOf(PType<K> key,
 			PType<V> value) {
+	  if (key instanceof PTableType) {
+	    PTableType ptt = (PTableType) key;
+	    key = Avros.pairs(ptt.getKeyType(), ptt.getValueType());
+	  }
+	  if (value instanceof PTableType) {
+	    PTableType ptt = (PTableType) value;
+	    value = Avros.pairs(ptt.getKeyType(), ptt.getValueType());
+	  }
 		AvroType<K> avroKey = (AvroType<K>) key;
 		AvroType<V> avroValue = (AvroType<V>) value;
 		return new AvroTableType(avroKey, avroValue, Pair.class);

http://git-wip-us.apache.org/repos/asf/incubator-crunch/blob/a69bda8f/src/test/java/com/cloudera/crunch/types/avro/AvrosTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/com/cloudera/crunch/types/avro/AvrosTest.java b/src/test/java/com/cloudera/crunch/types/avro/AvrosTest.java
index 74e2ad3..c7e9908 100644
--- a/src/test/java/com/cloudera/crunch/types/avro/AvrosTest.java
+++ b/src/test/java/com/cloudera/crunch/types/avro/AvrosTest.java
@@ -105,8 +105,8 @@ public class AvrosTest {
   @Test
   public void testNestedTables() throws Exception {
 	PTableType<Long, Long> pll = Avros.tableOf(Avros.longs(), Avros.longs());
-	PTableType<Pair<Long, Long>, String> nest = Avros.tableOf(pll, Avros.strings());
-	assertNotNull(nest);
+	String schema = Avros.tableOf(pll, Avros.strings()).getSchema().toString();
+	assertNotNull(schema);
   }
   
   @Test


Mime
View raw message