You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2017/02/15 23:12:47 UTC

orc git commit: ORC-147. Fix backwards compatibility with Hive 2.1. (omalley)

Repository: orc
Updated Branches:
  refs/heads/master 54540c058 -> 60c879c36


ORC-147. Fix backwards compatibility with Hive 2.1. (omalley)

Fixes #92

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


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

Branch: refs/heads/master
Commit: 60c879c369092bafbb00be70b4bf7c5c7f56b5a3
Parents: 54540c0
Author: Owen O'Malley <om...@apache.org>
Authored: Tue Feb 14 13:08:50 2017 -0800
Committer: Owen O'Malley <om...@apache.org>
Committed: Wed Feb 15 15:12:04 2017 -0800

----------------------------------------------------------------------
 java/core/pom.xml                               |  3 ++
 .../java/org/apache/orc/impl/MemoryManager.java | 32 +++++++++++++++
 .../org/apache/orc/impl/RecordReaderImpl.java   | 43 +++++++++++++++++++-
 .../org/apache/orc/impl/SchemaEvolution.java    | 20 ++++++---
 .../apache/orc/impl/TestSchemaEvolution.java    | 22 +++++-----
 5 files changed, 103 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/60c879c3/java/core/pom.xml
----------------------------------------------------------------------
diff --git a/java/core/pom.xml b/java/core/pom.xml
index abcdd4c..dbe50ac 100644
--- a/java/core/pom.xml
+++ b/java/core/pom.xml
@@ -102,6 +102,9 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
         <configuration>
+	  <sourceFileExcludes>
+	    <exclude>**/OrcProto.java</exclude>
+	  </sourceFileExcludes>
           <destDir>${project.artifactId}</destDir>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/orc/blob/60c879c3/java/core/src/java/org/apache/orc/impl/MemoryManager.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/impl/MemoryManager.java b/java/core/src/java/org/apache/orc/impl/MemoryManager.java
new file mode 100644
index 0000000..30535bf
--- /dev/null
+++ b/java/core/src/java/org/apache/orc/impl/MemoryManager.java
@@ -0,0 +1,32 @@
+/**
+ * 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.orc.impl;
+
+import org.apache.hadoop.conf.Configuration;
+
+/**
+ * Shim for backwards compatibility with Hive
+ */
+@Deprecated
+public class MemoryManager extends MemoryManagerImpl {
+
+  public MemoryManager(Configuration conf) {
+    super(conf);
+  }
+}

http://git-wip-us.apache.org/repos/asf/orc/blob/60c879c3/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
index 766eb00..f75d70a 100644
--- a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
+++ b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java
@@ -138,6 +138,47 @@ public class RecordReaderImpl implements RecordReader {
     return result;
   }
 
+  /**
+   * Given a list of column names, find the given column and return the index.
+   *
+   * @param columnNames the list of potential column names
+   * @param columnName  the column name to look for
+   * @param rootColumn  offset the result with the rootColumn
+   * @return the column number or -1 if the column wasn't found
+   */
+  private static int findColumns(String[] columnNames,
+                         String columnName,
+                         int rootColumn) {
+    for(int i=0; i < columnNames.length; ++i) {
+      if (columnName.equals(columnNames[i])) {
+        return i + rootColumn;
+      }
+    }
+    return -1;
+  }
+
+  /**
+   * Find the mapping from predicate leaves to columns.
+   * @param sargLeaves the search argument that we need to map
+   * @param columnNames the names of the columns
+   * @param rootColumn the offset of the top level row, which offsets the
+   *                   result
+   * @return an array mapping the sarg leaves to concrete column numbers
+   * @deprecated Use #mapSargColumnsToOrcInternalColIdx(List, SchemaEvolution)
+   */
+  @Deprecated
+  public static int[] mapSargColumnsToOrcInternalColIdx(List<PredicateLeaf> sargLeaves,
+                                                        String[] columnNames,
+                                                        int rootColumn) {
+    int[] result = new int[sargLeaves.size()];
+    Arrays.fill(result, -1);
+    for(int i=0; i < result.length; ++i) {
+      String colName = sargLeaves.get(i).getColumnName();
+      result[i] = findColumns(columnNames, colName, rootColumn);
+    }
+    return result;
+  }
+
   protected RecordReaderImpl(ReaderImpl fileReader,
                              Reader.Options options) throws IOException {
     this.writerVersion = fileReader.getWriterVersion();
@@ -146,7 +187,7 @@ public class RecordReaderImpl implements RecordReader {
         LOG.info("Reader schema not provided -- using file schema " +
             fileReader.getSchema());
       }
-      evolution = new SchemaEvolution(fileReader.getSchema(), options);
+      evolution = new SchemaEvolution(fileReader.getSchema(), null, options);
     } else {
 
       // Now that we are creating a record reader for a file, validate that

http://git-wip-us.apache.org/repos/asf/orc/blob/60c879c3/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
----------------------------------------------------------------------
diff --git a/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java b/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
index a438db3..886d585 100644
--- a/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
+++ b/java/core/src/java/org/apache/orc/impl/SchemaEvolution.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.orc.Reader;
 import org.apache.orc.TypeDescription;
 import org.slf4j.Logger;
@@ -63,11 +64,6 @@ public class SchemaEvolution {
   }
 
   public SchemaEvolution(TypeDescription fileSchema,
-                         Reader.Options options) {
-    this(fileSchema, null, options);
-  }
-
-  public SchemaEvolution(TypeDescription fileSchema,
                          TypeDescription readerSchema,
                          Reader.Options options) {
     boolean allowMissingMetadata = options.getTolerateMissingSchema();
@@ -131,6 +127,20 @@ public class SchemaEvolution {
     this.ppdSafeConversion = populatePpdSafeConversion();
   }
 
+  @Deprecated
+  public SchemaEvolution(TypeDescription fileSchema, boolean[] readerIncluded) {
+    this(fileSchema, null, readerIncluded);
+  }
+
+  @Deprecated
+  public SchemaEvolution(TypeDescription fileSchema,
+                         TypeDescription readerSchema,
+                         boolean[] readerIncluded) {
+    this(fileSchema, readerSchema,
+        new Reader.Options(new Configuration())
+            .include(readerIncluded));
+  }
+
   // Return true iff all fields have names like _col[0-9]+
   private boolean hasColumnNames(TypeDescription fileSchema) {
     if (fileSchema.getCategory() != TypeDescription.Category.STRUCT) {

http://git-wip-us.apache.org/repos/asf/orc/blob/60c879c3/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
----------------------------------------------------------------------
diff --git a/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java b/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
index ac0115d..82f823a 100644
--- a/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
+++ b/java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
@@ -78,7 +78,7 @@ public class TestSchemaEvolution {
         .addField("f1", TypeDescription.createInt())
         .addField("f2", TypeDescription.createString())
         .addField("f3", TypeDescription.createDecimal().withPrecision(38).withScale(10));
-    SchemaEvolution same1 = new SchemaEvolution(fileStruct1, options);
+    SchemaEvolution same1 = new SchemaEvolution(fileStruct1, null, options);
     assertFalse(same1.hasConversion());
     TypeDescription readerStruct1 = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createInt())
@@ -113,7 +113,7 @@ public class TestSchemaEvolution {
             .addField("f4", TypeDescription.createDouble())
             .addField("f5", TypeDescription.createBoolean()))
         .addField("f6", TypeDescription.createChar().withMaxLength(100));
-    SchemaEvolution same2 = new SchemaEvolution(fileStruct2, options);
+    SchemaEvolution same2 = new SchemaEvolution(fileStruct2, null, options);
     assertFalse(same2.hasConversion());
     TypeDescription readerStruct2 = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createUnion()
@@ -186,7 +186,7 @@ public class TestSchemaEvolution {
         .addField("f1", TypeDescription.createInt())
         .addField("f2", TypeDescription.createString())
         .addField("f3", TypeDescription.createDecimal().withPrecision(38).withScale(10));
-    SchemaEvolution same1 = new SchemaEvolution(fileStruct1, options);
+    SchemaEvolution same1 = new SchemaEvolution(fileStruct1, null, options);
     assertTrue(same1.isPPDSafeConversion(0));
     assertFalse(same1.hasConversion());
     TypeDescription readerStruct1 = TypeDescription.createStruct()
@@ -247,7 +247,7 @@ public class TestSchemaEvolution {
     // byte -> short -> int -> long
     TypeDescription fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createByte());
-    SchemaEvolution schemaEvolution = new SchemaEvolution(fileSchema, options);
+    SchemaEvolution schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertFalse(schemaEvolution.hasConversion());
 
     // byte -> short
@@ -277,7 +277,7 @@ public class TestSchemaEvolution {
     // short -> int -> long
     fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createShort());
-    schemaEvolution = new SchemaEvolution(fileSchema, options);
+    schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertFalse(schemaEvolution.hasConversion());
 
     // unsafe conversion short -> byte
@@ -307,7 +307,7 @@ public class TestSchemaEvolution {
     // int -> long
     fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createInt());
-    schemaEvolution = new SchemaEvolution(fileSchema, options);
+    schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertFalse(schemaEvolution.hasConversion());
 
     // unsafe conversion int -> byte
@@ -337,7 +337,7 @@ public class TestSchemaEvolution {
     // long
     fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createLong());
-    schemaEvolution = new SchemaEvolution(fileSchema, options);
+    schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertTrue(schemaEvolution.isPPDSafeConversion(0));
     assertFalse(schemaEvolution.hasConversion());
 
@@ -394,7 +394,7 @@ public class TestSchemaEvolution {
   public void testSafePpdEvaluationForStrings() throws IOException {
     TypeDescription fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createString());
-    SchemaEvolution schemaEvolution = new SchemaEvolution(fileSchema, options);
+    SchemaEvolution schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertTrue(schemaEvolution.isPPDSafeConversion(0));
     assertFalse(schemaEvolution.hasConversion());
 
@@ -416,7 +416,7 @@ public class TestSchemaEvolution {
 
     fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createChar());
-    schemaEvolution = new SchemaEvolution(fileSchema, options);
+    schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertTrue(schemaEvolution.isPPDSafeConversion(0));
     assertFalse(schemaEvolution.hasConversion());
 
@@ -438,7 +438,7 @@ public class TestSchemaEvolution {
 
     fileSchema = TypeDescription.createStruct()
         .addField("f1", TypeDescription.createVarchar());
-    schemaEvolution = new SchemaEvolution(fileSchema, options);
+    schemaEvolution = new SchemaEvolution(fileSchema, null, options);
     assertTrue(schemaEvolution.isPPDSafeConversion(0));
     assertFalse(schemaEvolution.hasConversion());
 
@@ -994,7 +994,7 @@ public class TestSchemaEvolution {
   public void testFileIncludeWithNoEvolution() {
     TypeDescription fileType = TypeDescription.fromString(
         "struct<a:int,b:double,c:string>");
-    SchemaEvolution evo = new SchemaEvolution(fileType,
+    SchemaEvolution evo = new SchemaEvolution(fileType, null,
         options.include(new boolean[]{true, false, true, false}));
     assertFalse(evo.isAcid());
     assertEquals("struct<a:int,b:double,c:string>",