You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by su...@apache.org on 2022/05/26 22:23:23 UTC
[hive] branch master updated: HIVE-26260: Use `Reader.getSchema` instead of deprecated `Reader.getTypes` (#3318)
This is an automated email from the ASF dual-hosted git repository.
sunchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new fd3990c0bdb HIVE-26260: Use `Reader.getSchema` instead of deprecated `Reader.getTypes` (#3318)
fd3990c0bdb is described below
commit fd3990c0bdb54010c6e64b167bec469152275b5f
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Thu May 26 15:23:13 2022 -0700
HIVE-26260: Use `Reader.getSchema` instead of deprecated `Reader.getTypes` (#3318)
### What changes were proposed in this pull request?
This PR aims to use `org.apache.orc.Reader.getSchema` instead of the deprecated `org.apache.orc.Reader.getTypes` API.
### Why are the changes needed?
`getTypes` was deprecated.
- https://github.com/apache/orc/blob/main/java/core/src/java/org/apache/orc/Reader.java#L144
```java
/**
* Get the list of types contained in the file. The root type is the first
* type in the list.
* @return the list of flattened types
* @deprecated use getSchema instead
* @since 1.1.0
*/
List<OrcProto.Type> getTypes();
```
In addition, AS-IS implementation is only a slow-wrapper.
- https://github.com/apache/orc/blob/1e2962064b209f1b00188877f08d4226da85c640/java/core/src/java/org/apache/orc/impl/ReaderImpl.java#L259-L262
```java
@Override
public List<OrcProto.Type> getTypes() {
return OrcUtils.getOrcTypes(schema);
}
```
- https://github.com/apache/orc/blob/1e2962064b209f1b00188877f08d4226da85c640/java/core/src/java/org/apache/orc/OrcUtils.java#L108-L112
```java
public static List<OrcProto.Type> getOrcTypes(TypeDescription typeDescr) {
List<OrcProto.Type> result = new ArrayList<>();
appendOrcTypes(result, typeDescr);
return result;
}
```
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs
---
ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java | 3 +--
ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcNewInputFormat.java | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
index a2936b36ffb..0f1333b9a68 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
@@ -252,9 +252,8 @@ public class OrcInputFormat implements InputFormat<NullWritable, OrcStruct>,
OrcRecordReader(Reader file, Configuration conf,
FileSplit split) throws IOException {
- List<OrcProto.Type> types = file.getTypes();
this.file = file;
- numColumns = (types.size() == 0) ? 0 : types.get(0).getSubtypesCount();
+ numColumns = file.getSchema().getChildren().size();
this.offset = split.getStart();
this.length = split.getLength();
this.reader = createReaderFromFile(file, conf, offset, length);
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcNewInputFormat.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcNewInputFormat.java
index fb04573c183..645f00602a9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcNewInputFormat.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcNewInputFormat.java
@@ -66,8 +66,7 @@ public class OrcNewInputFormat extends InputFormat<NullWritable, OrcStruct>{
OrcRecordReader(Reader file, Configuration conf,
long offset, long length) throws IOException {
- List<OrcProto.Type> types = file.getTypes();
- numColumns = (types.size() == 0) ? 0 : types.get(0).getSubtypesCount();
+ numColumns = file.getSchema().getChildren().size();
value = new OrcStruct(numColumns);
this.reader = OrcInputFormat.createReaderFromFile(file, conf, offset,
length);