pavibhai commented on a change in pull request #647:
URL: https://github.com/apache/orc/pull/647#discussion_r586706448



##########
File path: java/core/src/java/org/apache/orc/impl/ParserUtils.java
##########
@@ -244,80 +250,172 @@ public static TypeDescription 
parseType(ParserUtils.StringPosition source) {
 
   private static final Pattern INTEGER_PATTERN = Pattern.compile("^[0-9]+$");
 
+  public static ColumnVector[] findBranchVectors(TypeDescription schema,
+                                                 ParserUtils.StringPosition 
source,
+                                                 VectorizedRowBatch batch) {
+    List<String> names = ParserUtils.splitName(source);
+    return vectorWalker.get().find(schema, names, true, batch).vectorBranch;
+  }
+
   public static TypeDescription findSubtype(TypeDescription schema,
                                             ParserUtils.StringPosition source) 
{
     return findSubtype(schema, source, true);
   }
 
-  public static TypeDescription findSubtype(TypeDescription schema,
-                                            ParserUtils.StringPosition source,
-                                            boolean 
isSchemaEvolutionCaseAware) {
-    List<String> names = ParserUtils.splitName(source);
-    if (names.size() == 1 && INTEGER_PATTERN.matcher(names.get(0)).matches()) {
-      return schema.findSubtype(Integer.parseInt(names.get(0)));
+  private static final ThreadLocal<TypeWalker> typeWalker = 
ThreadLocal.withInitial(TypeWalker::new);
+  private static class TypeWalker {
+    private List<String> names;
+    private boolean caseAware;
+
+    // Walk specific
+    TypeDescription current = null;
+
+    private TypeWalker() {
     }
-    TypeDescription current = SchemaEvolution.checkAcidSchema(schema)
-        ? SchemaEvolution.getBaseRow(schema) : schema;
-    while (names.size() > 0) {
-      String first = names.remove(0);
-      switch (current.getCategory()) {
-        case STRUCT: {
-          int posn = -1;
-          if (isSchemaEvolutionCaseAware) {
-            posn = current.getFieldNames().indexOf(first);
-          } else {
-            // Case-insensitive search like ORC 1.5
-            for (int i = 0; i < current.getFieldNames().size(); i++) {
-              if (current.getFieldNames().get(i).equalsIgnoreCase(first)) {
-                posn = i;
-                break;
+
+    protected void handleLevel(int posn) {
+      this.current = current.getChildren().get(posn);
+    }
+
+    private void findInternal() {

Review comment:
       I have incorporated the suggestion with some tweaks.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to