orc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject orc git commit: ORC-170. TypeDescription parent links aren't always initialized.
Date Tue, 11 Apr 2017 19:58:03 GMT
Repository: orc
Updated Branches:
  refs/heads/master 37a76d529 -> fbe553274


ORC-170. TypeDescription parent links aren't always initialized.

Fixes #105

Signed-off-by: Owen O'Malley <omalley@apache.org>


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

Branch: refs/heads/master
Commit: fbe553274263ec4b138a8d355dfea15f8ee53572
Parents: 37a76d5
Author: Owen O'Malley <omalley@apache.org>
Authored: Tue Apr 11 12:17:15 2017 -0700
Committer: Owen O'Malley <omalley@apache.org>
Committed: Tue Apr 11 12:41:21 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/orc/TypeDescription.java    | 18 +++++++++++-----
 .../org/apache/orc/TestTypeDescription.java     | 22 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/fbe55327/java/core/src/java/org/apache/orc/TypeDescription.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/TypeDescription.java b/java/core/src/java/org/apache/orc/TypeDescription.java
index 2086f3a..cced414 100644
--- a/java/core/src/java/org/apache/orc/TypeDescription.java
+++ b/java/core/src/java/org/apache/orc/TypeDescription.java
@@ -353,18 +353,26 @@ public class TypeDescription
         requireChar(source, ')');
         break;
       }
-      case LIST:
+      case LIST: {
         requireChar(source, '<');
-        result.children.add(parseType(source));
+        TypeDescription child = parseType(source);
+        result.children.add(child);
+        child.parent = result;
         requireChar(source, '>');
         break;
-      case MAP:
+      }
+      case MAP: {
         requireChar(source, '<');
-        result.children.add(parseType(source));
+        TypeDescription keyType = parseType(source);
+        result.children.add(keyType);
+        keyType.parent = result;
         requireChar(source, ',');
-        result.children.add(parseType(source));
+        TypeDescription valueType = parseType(source);
+        result.children.add(valueType);
+        valueType.parent = result;
         requireChar(source, '>');
         break;
+      }
       case UNION:
         parseUnion(result, source);
         break;

http://git-wip-us.apache.org/repos/asf/orc/blob/fbe55327/java/core/src/test/org/apache/orc/TestTypeDescription.java
----------------------------------------------------------------------
diff --git a/java/core/src/test/org/apache/orc/TestTypeDescription.java b/java/core/src/test/org/apache/orc/TestTypeDescription.java
index c5944af..404c9d0 100644
--- a/java/core/src/test/org/apache/orc/TestTypeDescription.java
+++ b/java/core/src/test/org/apache/orc/TestTypeDescription.java
@@ -198,4 +198,26 @@ public class TestTypeDescription {
     thrown.expectMessage("Extra characters at 'struct<i:int>^,'");
     TypeDescription.fromString("struct<i:int>,");
   }
+
+  @Test
+  public void testConnectedListSubtrees() {
+    TypeDescription type =
+        TypeDescription.fromString("struct<field1:array<struct<field2:int>>>");
+    TypeDescription leaf = type.getChildren().get(0)
+        .getChildren().get(0)
+        .getChildren().get(0);
+    assertEquals(3, leaf.getId());
+    assertEquals(0, type.getId());
+    assertEquals(3, leaf.getId());
+  }
+
+  @Test
+  public void testConnectedMapSubtrees() {
+    TypeDescription type =
+        TypeDescription.fromString("struct<field1:map<string,int>>");
+    TypeDescription leaf = type.getChildren().get(0).getChildren().get(0);
+    assertEquals(2, leaf.getId());
+    assertEquals(0, type.getId());
+    assertEquals(2, leaf.getId());
+  }
 }


Mime
View raw message