Skip to content

ORC-1393: Add reset(DiskRangeList input, long length) to InStream impl class - #1432

Closed
difin wants to merge 1 commit into
apache:mainfrom
difin:ORC-1393
Closed

difin wants to merge 1 commit into
apache:mainfrom
difin:ORC-1393

Conversation

@difin

@difin difin commented Mar 9, 2023 •

Copy link
Copy Markdown

What changes were proposed in this pull request?

Adding a possibility to re-set the length of the UncompressedStream when calling reset() on it.

Why are the changes needed?

In short, in some cases, after resetting an UncompressedStream, its actual length is longer than its initial length.

Before 'ORC-516 - Update InStream for column compression', InStream.UncompressedStream class had 'length' field and the length was modifiable in reset() method. ORC-516 was the root cause of this regression reported in HIVE-27128.

The reset() method was used in SettableUncompressedStream class in setBuffers() method:

public void setBuffers(DiskRangeInfo diskRangeInfo) {
  reset(diskRangeInfo.getDiskRanges(), diskRangeInfo.getTotalLength());
  setOffset(diskRangeInfo.getDiskRanges());
}

After Orc version upgrade in Hive to 1.6.7., and since SettableUncompressedStream class was removed from Orc code base, Hive manages it own copy of SettableUncompressedStream which doesn't pass new length to UncompressedStream when calling reset (because UncompressedStream doesn't accept new length any more in the reset method):

public void setBuffers(DiskRangeInfo diskRangeList) {
  reset(diskRangeList.getDiskRanges());
  setOffset(diskRangeList.getDiskRanges());
}

When investigating the issue reported in HIVE-27128 and comparing the lengths of the InStream.UncompressedStream prior to the upgrade of ORC version in Hive to 1.6.7. (which included ORC-516) and after I noticed that the issue happens with ORC-516 changes because the length of the InStream.UncompressedStream is set once for all row groups, while without those changes the length is dynamic and sometimes is set to bigger value than the initial value.

How was this patch tested?

  1. Passing CI pipeline tests
  2. Running Hive Q-test https://github.com/difin/hive/commits/orc_read_err_qtest on the local dev env with a change in Hive's SettableUncompressedStream to pass diskRangeList.getTotalLength() to the reset method of UncompressedStream.

@github-actions github-actions Bot added the JAVA label Mar 9, 2023
@guiyanakuang guiyanakuang changed the title ORC-1393: Returning the possibility to change stream length when rese… ORC-1393: Returning the possibility to change stream length when resetting UncompressedStream Mar 9, 2023
@dongjoon-hyun dongjoon-hyun added this to the 1.8.3 milestone Mar 9, 2023

@dongjoon-hyun dongjoon-hyun left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Although we don't have a test coverage here, I believe this patch is fully tested with Hive tests, @difin .

  1. I copied your JIRA description into the PR description and revise it to make a rich commit log.
  2. I added one minor comment about a function description. You can reuse the most of the existing comments. Please add the background of this new wrapper reset method, especially, the increased length.

@dongjoon-hyun

Copy link
Copy Markdown
Member

cc @omalley , @williamhyun , @guiyanakuang

@dongjoon-hyun dongjoon-hyun changed the title ORC-1393: Returning the possibility to change stream length when resetting UncompressedStream ORC-1393: Add reset(DiskRangeList input, long length) to InStream impl class Mar 9, 2023
@dongjoon-hyun

dongjoon-hyun commented Mar 9, 2023 •

Copy link
Copy Markdown
Member

Although this impl class should not be used outside, I believe we need this because Apache Hive is the mother of Apache ORC initially.

@dongjoon-hyun dongjoon-hyun changed the title ORC-1393: Add reset(DiskRangeList input, long length) to InStream impl class ORC-1393: Add reset(DiskRangeList input, long length) to InStream impl class Mar 9, 2023

@guiyanakuang guiyanakuang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

@deshanxiao

Copy link
Copy Markdown
Contributor

Could we add a simple unit test like this:
Invocation the new reset(DiskRangeList input, long length) and test the real avaliable bypes of Instream?

@difin

difin commented Mar 9, 2023

Copy link
Copy Markdown
Author

I've added unit tests as suggested.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Thank you for updating, @difin .

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Merged to main/1.8 for Apache ORC 1.8.3.

dongjoon-hyun pushed a commit that referenced this pull request Mar 9, 2023
… impl class

### What changes were proposed in this pull request?

Adding a possibility to re-set the length of the UncompressedStream when calling reset() on it.

### Why are the changes needed?

In short, in some cases, after resetting an UncompressedStream, its actual length is longer than its initial length.

Before 'ORC-516 - Update InStream for column compression', InStream.UncompressedStream class had 'length' field and the length was modifiable in reset() method. ORC-516 was the root cause of this regression reported in HIVE-27128.

The `reset()` method was used in `SettableUncompressedStream` class in `setBuffers()` method:

```java
public void setBuffers(DiskRangeInfo diskRangeInfo) {
  reset(diskRangeInfo.getDiskRanges(), diskRangeInfo.getTotalLength());
  setOffset(diskRangeInfo.getDiskRanges());
}
```
After Orc version upgrade in Hive to 1.6.7., and since `SettableUncompressedStream` class was removed from Orc code base, Hive manages it own copy of `SettableUncompressedStream` which doesn't pass new length to `UncompressedStream` when calling reset (because `UncompressedStream` doesn't accept new length any more in the reset method):

```java
public void setBuffers(DiskRangeInfo diskRangeList) {
  reset(diskRangeList.getDiskRanges());
  setOffset(diskRangeList.getDiskRanges());
}
```
When investigating the issue reported in HIVE-27128 and comparing the lengths of the InStream.UncompressedStream prior to the upgrade of ORC version in Hive to 1.6.7. (which included ORC-516) and after I noticed that the issue happens with ORC-516 changes because the length of the InStream.UncompressedStream is set once for all row groups, while without those changes the length is dynamic and sometimes is set to bigger value than the initial value.

### How was this patch tested?

1. Passing CI pipeline tests
2. Running Hive Q-test https://github.com/difin/hive/commits/orc_read_err_qtest on the local dev env with a change in Hive's SettableUncompressedStream to pass  diskRangeList.getTotalLength() to the reset method of UncompressedStream.

Closes #1432 from difin/ORC-1393.

Authored-by: Dmitriy Fingerman <dfingerman@cloudera.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit b56d2d1)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
@dongjoon-hyun

Copy link
Copy Markdown
Member

Thank you for your contribution. ORC-1393 is resolved and assigned to you.
Welcome to the Apache ORC community.

cxzl25 pushed a commit to cxzl25/orc that referenced this pull request Jan 11, 2024
… impl class

### What changes were proposed in this pull request?

Adding a possibility to re-set the length of the UncompressedStream when calling reset() on it.

### Why are the changes needed?

In short, in some cases, after resetting an UncompressedStream, its actual length is longer than its initial length.

Before 'ORC-516 - Update InStream for column compression', InStream.UncompressedStream class had 'length' field and the length was modifiable in reset() method. ORC-516 was the root cause of this regression reported in HIVE-27128.

The `reset()` method was used in `SettableUncompressedStream` class in `setBuffers()` method:

```java
public void setBuffers(DiskRangeInfo diskRangeInfo) {
  reset(diskRangeInfo.getDiskRanges(), diskRangeInfo.getTotalLength());
  setOffset(diskRangeInfo.getDiskRanges());
}
```
After Orc version upgrade in Hive to 1.6.7., and since `SettableUncompressedStream` class was removed from Orc code base, Hive manages it own copy of `SettableUncompressedStream` which doesn't pass new length to `UncompressedStream` when calling reset (because `UncompressedStream` doesn't accept new length any more in the reset method):

```java
public void setBuffers(DiskRangeInfo diskRangeList) {
  reset(diskRangeList.getDiskRanges());
  setOffset(diskRangeList.getDiskRanges());
}
```
When investigating the issue reported in HIVE-27128 and comparing the lengths of the InStream.UncompressedStream prior to the upgrade of ORC version in Hive to 1.6.7. (which included ORC-516) and after I noticed that the issue happens with ORC-516 changes because the length of the InStream.UncompressedStream is set once for all row groups, while without those changes the length is dynamic and sometimes is set to bigger value than the initial value.

### How was this patch tested?

1. Passing CI pipeline tests
2. Running Hive Q-test https://github.com/difin/hive/commits/orc_read_err_qtest on the local dev env with a change in Hive's SettableUncompressedStream to pass  diskRangeList.getTotalLength() to the reset method of UncompressedStream.

Closes apache#1432 from difin/ORC-1393.

Authored-by: Dmitriy Fingerman <dfingerman@cloudera.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants