You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2023/10/23 16:48:53 UTC

[PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

mapleFU opened a new pull request, #38413:
URL: https://github.com/apache/arrow/pull/38413

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   As https://github.com/apache/arrow/issues/38399 says. DeltaBitPack will corrupt when we meet a column chunk
   with more than one page. During first page decoding, it works well. But when the second page comes, the
   `d.usedFirst` haven't been reset, which cause the bug.
   
   ### What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   1. Some style enhancement
   2. Bug fix
   
   ### Are these changes tested?
   
   Currently not
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   3. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   bugfix
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #38413:
URL: https://github.com/apache/arrow/pull/38413#discussion_r1368986904


##########
go/parquet/internal/encoding/delta_bit_packing.go:
##########
@@ -172,6 +174,10 @@ func (d *DeltaBitPackInt32Decoder) Decode(out []int32) (int, error) {
 	for len(out) > 0 { // unpack mini blocks until we get all the values we need
 		if d.currentBlockVals == 0 {
 			err = d.initBlock()
+			if err != nil {
+				return 0, err
+			}
+			d.currentMiniBlockVals = 0

Review Comment:
   isn't this redundant due to the above if statement?



-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #38413:
URL: https://github.com/apache/arrow/pull/38413#discussion_r1368995387


##########
go/parquet/internal/encoding/delta_bit_packing.go:
##########
@@ -172,6 +174,10 @@ func (d *DeltaBitPackInt32Decoder) Decode(out []int32) (int, error) {
 	for len(out) > 0 { // unpack mini blocks until we get all the values we need
 		if d.currentBlockVals == 0 {
 			err = d.initBlock()
+			if err != nil {
+				return 0, err
+			}
+			d.currentMiniBlockVals = 0

Review Comment:
   Yeah. Previously I though it might raise from data on last block( already-read + d.currentBlockVals would greater than max). However finally I found that here it will limit by `out` and `max`. So this line can be removed.



-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1775625628

   This looks great to me @mapleFU thanks! I'll review again once you add the tests


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1779839989

   After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 7b1281a432f2ea8dcc6bec5c7824a97d608486ca.
   
   There were no benchmark performance regressions. 🎉
   
   The [full Conbench report](https://github.com/apache/arrow/runs/18054411793) has more details. It also includes information about 3 possible false positives for unstable benchmarks that are known to sometimes produce them.


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #38413:
URL: https://github.com/apache/arrow/pull/38413#discussion_r1368987448


##########
go/parquet/internal/encoding/delta_bit_packing.go:
##########
@@ -260,6 +266,10 @@ func (d *DeltaBitPackInt64Decoder) Decode(out []int64) (int, error) {
 	for len(out) > 0 {
 		if d.currentBlockVals == 0 {
 			err = d.initBlock()
+			if err != nil {
+				return 0, err
+			}
+			d.currentMiniBlockVals = 0

Review Comment:
   same as above, isn't this redundant due to the if above?



-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #38413:
URL: https://github.com/apache/arrow/pull/38413#discussion_r1368985334


##########
go/parquet/internal/encoding/delta_bit_packing.go:
##########
@@ -82,9 +82,12 @@ func (d *deltaBitPackDecoder) SetData(nvalues int, data []byte) error {
 		return xerrors.New("parquet: eof exception")
 	}
 
-	if d.miniBlocks, ok = d.bitdecoder.GetVlqInt(); !ok {
+	if d.miniBlocksPerBlock, ok = d.bitdecoder.GetVlqInt(); !ok {
 		return xerrors.New("parquet: eof exception")
 	}
+	if d.miniBlocksPerBlock == 0 {
+		return xerrors.New("parquet: cannot have zero miniblock per block")

Review Comment:
   `xerrors` is no longer necessary as it has been absorbed into the stdlib, so for new code please just use `errors` instead.



-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1777336198

   @mapleFU The failing appveyor test doesn't appear related at all so you're fine there.
   
   Are either of the tests you added able to reproduce the initial failure that was reported in the issue (without your fix)? If not, can you add a test that does reproduce the initial failure?


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #38413:
URL: https://github.com/apache/arrow/pull/38413#discussion_r1368995387


##########
go/parquet/internal/encoding/delta_bit_packing.go:
##########
@@ -172,6 +174,10 @@ func (d *DeltaBitPackInt32Decoder) Decode(out []int32) (int, error) {
 	for len(out) > 0 { // unpack mini blocks until we get all the values we need
 		if d.currentBlockVals == 0 {
 			err = d.initBlock()
+			if err != nil {
+				return 0, err
+			}
+			d.currentMiniBlockVals = 0

Review Comment:
   Yeah. Previously I though it might raise from data on last block( already-read + d.currentBlockVals would greater than max). However finally I found that here it will limit by `out` and `max`. So this line can be moved.



-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #38413:
URL: https://github.com/apache/arrow/pull/38413#discussion_r1368996270


##########
go/parquet/internal/encoding/delta_bit_packing.go:
##########
@@ -82,9 +82,12 @@ func (d *deltaBitPackDecoder) SetData(nvalues int, data []byte) error {
 		return xerrors.New("parquet: eof exception")
 	}
 
-	if d.miniBlocks, ok = d.bitdecoder.GetVlqInt(); !ok {
+	if d.miniBlocksPerBlock, ok = d.bitdecoder.GetVlqInt(); !ok {
 		return xerrors.New("parquet: eof exception")
 	}
+	if d.miniBlocksPerBlock == 0 {
+		return xerrors.New("parquet: cannot have zero miniblock per block")

Review Comment:
   Should I replace the `xerrors` in this file? Since mixing `xerror` and standard lib is so weird :-(



-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1776423362

   I'm not familiar with go enough, so don't know why CI failed...


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #38413:
URL: https://github.com/apache/arrow/pull/38413


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1775607732

   :warning: GitHub issue #38399 **has been automatically assigned in GitHub** to PR creator.


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1775608819

   @zeroshade I've investigate and submit a fixing. It's a bit late in UTC-8. I'll add tests tomorrow.


-- 
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: github-unsubscribe@arrow.apache.org

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


Re: [PR] GH-38399: [Go][Parquet] DeltaBitPack decoder reset usedFirst after SetData [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #38413:
URL: https://github.com/apache/arrow/pull/38413#issuecomment-1777479595

   ```go
   		// Using same Decoder to decode the data.
   		dec := encoding.NewDecoder(parquet.Types.Int32, parquet.Encodings.DeltaBinaryPacked, column, memory.DefaultAllocator)
   		for i := 0; i < 5; i += 1 {
   			dec.(encoding.Int32Decoder).SetData(len(values), buf.Bytes())
   
   			valueBuf := make([]int32, 100)
   			for i, j := 0, len(valueBuf); j <= len(values); i, j = i+len(valueBuf), j+len(valueBuf) {
   				dec.(encoding.Int32Decoder).Decode(valueBuf)
   				assert.Equalf(t, values[i:j], valueBuf, "indexes %d:%d", i, j)
   			}
   		}
   ```
   
   I've add the same test for int32 and int64, please refer to "test decoding multiple pages". @zeroshade 


-- 
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: github-unsubscribe@arrow.apache.org

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