You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@orc.apache.org by "difin (via GitHub)" <gi...@apache.org> on 2023/03/09 02:53:58 UTC

[GitHub] [orc] difin opened a new pull request, #1432: ORC-1393: Returning the possibility to change stream length when rese…

difin opened a new pull request, #1432:
URL: https://github.com/apache/orc/pull/1432

   …tting UncompressedStream.
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. File a JIRA issue first and use it as a prefix of your PR title, e.g., `ORC-001: Fix ABC`.
     2. Use your PR title to summarize what this PR proposes instead of describing the problem.
     3. Make PR title and description complete because these will be the permanent commit log.
     4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
     5. If the PR is unfinished, use GitHub PR Draft feature.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If there is a discussion in the mailing list, please add the link.
   -->
   Adding a possibility to re-set the length of the UncompressedStream when calling reset() on it.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   In some cases after resetting an UncompressedStream, its actual length is longer than it initial length.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   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.
   
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1432:
URL: https://github.com/apache/orc/pull/1432#issuecomment-1462839697

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


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on a diff in pull request #1432: ORC-1393: Returning the possibility to change stream length when resetting UncompressedStream

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1130359748


##########
java/core/src/java/org/apache/orc/impl/InStream.java:
##########
@@ -106,7 +111,7 @@ public static class UncompressedStream extends InStream {
     protected ByteBuffer decrypted;
     protected DiskRangeList currentRange;
     protected long currentOffset;
-
+    

Review Comment:
   Could you make CI happy, @difin ?
   ```
   Error:  src/java/org/apache/orc/impl/InStream.java:[114] (regexp) RegexpSingleline: No trailing white space allowed.
   ```



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] difin commented on a diff in pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1131606891


##########
java/core/src/test/org/apache/orc/impl/TestInStream.java:
##########
@@ -957,4 +957,47 @@ public void testMultiRangeCompressHeader() throws IOException {
       assertEquals((byte)i, inBuffer[i], "position " + i);
     }
   }
+
+  private static final byte[] uncompressed = input(
+          0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+  
+  @Test
+  public void testStreamResetWithIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream with the increased length
+    inStream.reset(list.get(), 10);
+    // Reading the stream and expecting to read 10 bytes
+    byte[] inBuffer = new byte[10];
+    assertEquals(10, inStream.read(inBuffer));
+  }
+
+  @Test
+  public void testStreamResetWithoutIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a shorter length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream without updating its length
+    inStream.reset(list.get());

Review Comment:
   Yes, and this causes "Can't finish byte read from uncompressed stream DATA position" exception in Hive (HIVE-27128). We plan to fix it in Hive by upgrading its ORC version once a new ORC version is releases with this fix(ORC-1393) and with ORC-1384 which is a blocker for the upgrade. Thanks a lot for merging my PR!



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun closed pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class
URL: https://github.com/apache/orc/pull/1432


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on pull request #1432: ORC-1393: Returning the possibility to change stream length when resetting UncompressedStream

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1432:
URL: https://github.com/apache/orc/pull/1432#issuecomment-1461351290

   cc @omalley , @williamhyun , @guiyanakuang 


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] difin commented on a diff in pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1131606891


##########
java/core/src/test/org/apache/orc/impl/TestInStream.java:
##########
@@ -957,4 +957,47 @@ public void testMultiRangeCompressHeader() throws IOException {
       assertEquals((byte)i, inBuffer[i], "position " + i);
     }
   }
+
+  private static final byte[] uncompressed = input(
+          0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+  
+  @Test
+  public void testStreamResetWithIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream with the increased length
+    inStream.reset(list.get(), 10);
+    // Reading the stream and expecting to read 10 bytes
+    byte[] inBuffer = new byte[10];
+    assertEquals(10, inStream.read(inBuffer));
+  }
+
+  @Test
+  public void testStreamResetWithoutIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a shorter length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream without updating its length
+    inStream.reset(list.get());

Review Comment:
   Yes, and this causes "Can't finish byte read from uncompressed stream DATA position" exception in Hive (HIVE-27128). We plan to fix it in Hive by upgrading its ORC version once a new ORC version is released with this fix(ORC-1393) and with ORC-1384 which is a blocker for the upgrade. Thanks a lot for merging my PR!



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on a diff in pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1131575180


##########
java/core/src/test/org/apache/orc/impl/TestInStream.java:
##########
@@ -957,4 +957,47 @@ public void testMultiRangeCompressHeader() throws IOException {
       assertEquals((byte)i, inBuffer[i], "position " + i);
     }
   }
+
+  private static final byte[] uncompressed = input(
+          0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+  
+  @Test
+  public void testStreamResetWithIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream with the increased length
+    inStream.reset(list.get(), 10);
+    // Reading the stream and expecting to read 10 bytes
+    byte[] inBuffer = new byte[10];
+    assertEquals(10, inStream.read(inBuffer));
+  }
+
+  @Test
+  public void testStreamResetWithoutIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a shorter length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream without updating its length
+    inStream.reset(list.get());

Review Comment:
   So, Hive also has this use case?



##########
java/core/src/test/org/apache/orc/impl/TestInStream.java:
##########
@@ -957,4 +957,47 @@ public void testMultiRangeCompressHeader() throws IOException {
       assertEquals((byte)i, inBuffer[i], "position " + i);
     }
   }
+
+  private static final byte[] uncompressed = input(
+          0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+  
+  @Test
+  public void testStreamResetWithIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream with the increased length
+    inStream.reset(list.get(), 10);
+    // Reading the stream and expecting to read 10 bytes
+    byte[] inBuffer = new byte[10];
+    assertEquals(10, inStream.read(inBuffer));
+  }
+
+  @Test
+  public void testStreamResetWithoutIncreasedLength() throws IOException {
+    // Set up an initial buffer of PREVIOUS_LENGTH followed by our stream
+    // at START.
+    final long START = 1_000;
+    final int PREVIOUS_LENGTH = 30;
+    BufferChunkList list = new BufferChunkList();
+    byte[] previous = new byte[PREVIOUS_LENGTH];
+    Arrays.fill(previous, (byte) -1);
+    list.add(new BufferChunk(ByteBuffer.wrap(previous), START - PREVIOUS_LENGTH));
+    list.add(new BufferChunk(ByteBuffer.wrap(uncompressed), START));
+    // Creating a stream of 10 bytes, but with a shorter length of 5
+    InStream inStream = InStream.create("test", list.get(), START, 5, new InStream.StreamOptions());
+    // Resetting the stream without updating its length
+    inStream.reset(list.get());

Review Comment:
   So, Hive also has this use case still, right?



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to InStream impl class

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1432:
URL: https://github.com/apache/orc/pull/1432#issuecomment-1461360158

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


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] difin commented on a diff in pull request #1432: ORC-1393: Returning the possibility to change stream length when resetting UncompressedStream

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1130371106


##########
java/core/src/java/org/apache/orc/impl/InStream.java:
##########
@@ -106,7 +111,7 @@ public static class UncompressedStream extends InStream {
     protected ByteBuffer decrypted;
     protected DiskRangeList currentRange;
     protected long currentOffset;
-
+    

Review Comment:
   Sure, done.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] deshanxiao commented on pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "deshanxiao (via GitHub)" <gi...@apache.org>.
deshanxiao commented on PR #1432:
URL: https://github.com/apache/orc/pull/1432#issuecomment-1461736822

   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?


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1432:
URL: https://github.com/apache/orc/pull/1432#issuecomment-1462550696

   Thank you for updating, @difin .


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] dongjoon-hyun commented on a diff in pull request #1432: ORC-1393: Returning the possibility to change stream length when resetting UncompressedStream

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1130527909


##########
java/core/src/java/org/apache/orc/impl/InStream.java:
##########
@@ -87,6 +87,11 @@ protected void reset(DiskRangeList input) {
     setCurrent(input, true);
   }
 
+  protected void reset(DiskRangeList input, long length) {

Review Comment:
   Please add a function description for this method because this method will be used as a wrapper from now.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] difin commented on a diff in pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on code in PR #1432:
URL: https://github.com/apache/orc/pull/1432#discussion_r1131375197


##########
java/core/src/java/org/apache/orc/impl/InStream.java:
##########
@@ -87,6 +87,11 @@ protected void reset(DiskRangeList input) {
     setCurrent(input, true);
   }
 
+  protected void reset(DiskRangeList input, long length) {

Review Comment:
   Thanks for your comment, done.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [orc] difin commented on pull request #1432: ORC-1393: Add `reset(DiskRangeList input, long length)` to `InStream` impl class

Posted by "difin (via GitHub)" <gi...@apache.org>.
difin commented on PR #1432:
URL: https://github.com/apache/orc/pull/1432#issuecomment-1462480500

   I've added unit tests as suggested.
   
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org