hcrosse commented on code in PR #1594:
URL: https://github.com/apache/arrow-go/pull/1594#discussion_r4607664616


##########
parquet/file/page_reader.go:
##########
@@ -905,6 +910,11 @@ func (p *serializedPageReader) SeekToPageWithRow(rowIdx 
int64) error {
 
                p.rowsSeen = 0
                p.pageOrd = 0
+               if p.dataOffset > p.baseOffset {
+                       p.cryptoCtx.StartDecryptWithDictionaryPage = false
+               } else if p.dictOffset > 0 {
+                       p.cryptoCtx.StartDecryptWithDictionaryPage = true
+               }

Review Comment:
   Thanks. I set `chunkStartsWithDict` next to each `cryptoCtx = *ctx` in 
`init`, `NewPageReader` and `Reset`, and clear it when `Reset` drops encryption.



##########
parquet/file/page_reader.go:
##########
@@ -740,16 +740,23 @@ func extractStats(dataHeader dataheader) (pageStats 
metadata.EncodedStatistics)
 
 // dictionaryAtDataOffset reports whether the page at data_page_offset may be a
 // dictionary page, which is so when the chunk records no dictionary offset or
-// the same offset as the data offset. Encrypted chunks are excluded because 
the
-// AAD of a page header depends on the page type, which is unknown before the
-// header is read.
+// the same offset as the data offset. Encrypted chunks that record no offset
+// are excluded because the AAD of a page header depends on the page type, 
which
+// is unknown before the header is read.
 func (p *serializedPageReader) dictionaryAtDataOffset() bool {
-       return p.dataOffset <= p.baseOffset && p.cryptoCtx.MetaDecryptor == nil
+       return p.dataOffset <= p.baseOffset && (p.dictOffset > 0 || 
p.cryptoCtx.MetaDecryptor == nil)

Review Comment:
   I changed the condition and reworded the doc comment as you suggested.



##########
parquet/file/page_reader.go:
##########
@@ -740,16 +740,23 @@ func extractStats(dataHeader dataheader) (pageStats 
metadata.EncodedStatistics)
 
 // dictionaryAtDataOffset reports whether the page at data_page_offset may be a
 // dictionary page, which is so when the chunk records no dictionary offset or
-// the same offset as the data offset. Encrypted chunks are excluded because 
the
-// AAD of a page header depends on the page type, which is unknown before the
-// header is read.
+// the same offset as the data offset. Encrypted chunks that record no offset
+// are excluded because the AAD of a page header depends on the page type, 
which
+// is unknown before the header is read.
 func (p *serializedPageReader) dictionaryAtDataOffset() bool {
-       return p.dataOffset <= p.baseOffset && p.cryptoCtx.MetaDecryptor == nil
+       return p.dataOffset <= p.baseOffset && (p.dictOffset > 0 || 
p.cryptoCtx.MetaDecryptor == nil)
 }
 
 func (p *serializedPageReader) GetDictionaryPage() (*DictionaryPage, error) {
        probe := p.dictOffset == 0 && p.dictionaryAtDataOffset()
        if p.dictOffset > 0 || probe {
+               // This reads the dictionary page header wherever the stream 
is, so it needs
+               // the dictionary AAD. The flag must still describe the next 
page of p.r
+               // afterwards.

Review Comment:
   I changed it to your wording.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to