emkornfield commented on a change in pull request #10379:
URL: https://github.com/apache/arrow/pull/10379#discussion_r654006657



##########
File path: go/parquet/internal/encoding/delta_bit_packing.go
##########
@@ -0,0 +1,515 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package encoding
+
+import (
+       "bytes"
+       "math"
+       "math/bits"
+       "reflect"
+
+       "github.com/apache/arrow/go/arrow"
+       "github.com/apache/arrow/go/arrow/memory"
+       "github.com/apache/arrow/go/parquet"
+       "github.com/apache/arrow/go/parquet/internal/utils"
+       "golang.org/x/xerrors"
+)
+
+// see the deltaBitPack encoder for a description of the encoding format that 
is
+// used for delta-bitpacking.
+type deltaBitPackDecoder struct {
+       decoder
+
+       mem memory.Allocator
+
+       usedFirst            bool
+       bitdecoder           *utils.BitReader
+       blockSize            uint64
+       currentBlockVals     uint64
+       miniBlocks           uint64
+       valsPerMini          uint64
+       currentMiniBlockVals uint64
+       minDelta             int64
+       miniBlockIdx         uint64
+
+       deltaBitWidths *memory.Buffer
+       deltaBitWidth  byte
+
+       lastVal int64
+}
+
+// returns the number of bytes read so far
+func (d *deltaBitPackDecoder) bytesRead() int64 {
+       return d.bitdecoder.CurOffset()
+}
+
+func (d *deltaBitPackDecoder) Allocator() memory.Allocator { return d.mem }
+
+// SetData sets the bytes and the expected number of values to decode
+// into the decoder, updating the decoder and allowing it to be reused.
+func (d *deltaBitPackDecoder) SetData(nvalues int, data []byte) {
+       // set our data into the underlying decoder for the type
+       d.decoder.SetData(nvalues, data)
+       // create a bit reader for our decoder's values
+       d.bitdecoder = utils.NewBitReader(bytes.NewReader(d.data))
+       d.currentBlockVals = 0
+       d.currentMiniBlockVals = 0
+       if d.deltaBitWidths == nil {
+               d.deltaBitWidths = memory.NewResizableBuffer(d.mem)
+       }
+
+       var ok bool
+       d.blockSize, ok = d.bitdecoder.GetVlqInt()
+       if !ok {
+               panic("parquet: eof exception")
+       }
+
+       if d.miniBlocks, ok = d.bitdecoder.GetVlqInt(); !ok {
+               panic("parquet: eof exception")
+       }
+
+       var totalValues uint64
+       if totalValues, ok = d.bitdecoder.GetVlqInt(); !ok {
+               panic("parquet: eof exception")
+       }
+
+       if int(totalValues) != d.nvals {
+               panic("parquet: mismatch between number of values and count in 
data header")
+       }
+
+       if d.lastVal, ok = d.bitdecoder.GetZigZagVlqInt(); !ok {
+               panic("parquet: eof exception")
+       }
+
+       d.valsPerMini = uint64(d.blockSize / d.miniBlocks)

Review comment:
       This is my intuition.  I believe values per page are limited to 2^32 - 
1.  I was assuming at worst 1 mini block per value.

##########
File path: go/parquet/internal/encoding/delta_bit_packing.go
##########
@@ -0,0 +1,515 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package encoding
+
+import (
+       "bytes"
+       "math"
+       "math/bits"
+       "reflect"
+
+       "github.com/apache/arrow/go/arrow"
+       "github.com/apache/arrow/go/arrow/memory"
+       "github.com/apache/arrow/go/parquet"
+       "github.com/apache/arrow/go/parquet/internal/utils"
+       "golang.org/x/xerrors"
+)
+
+// see the deltaBitPack encoder for a description of the encoding format that 
is
+// used for delta-bitpacking.
+type deltaBitPackDecoder struct {
+       decoder
+
+       mem memory.Allocator
+
+       usedFirst            bool
+       bitdecoder           *utils.BitReader
+       blockSize            uint64
+       currentBlockVals     uint64
+       miniBlocks           uint64
+       valsPerMini          uint64
+       currentMiniBlockVals uint64
+       minDelta             int64
+       miniBlockIdx         uint64
+
+       deltaBitWidths *memory.Buffer
+       deltaBitWidth  byte
+
+       lastVal int64
+}
+
+// returns the number of bytes read so far
+func (d *deltaBitPackDecoder) bytesRead() int64 {
+       return d.bitdecoder.CurOffset()
+}
+
+func (d *deltaBitPackDecoder) Allocator() memory.Allocator { return d.mem }
+
+// SetData sets the bytes and the expected number of values to decode
+// into the decoder, updating the decoder and allowing it to be reused.
+func (d *deltaBitPackDecoder) SetData(nvalues int, data []byte) {
+       // set our data into the underlying decoder for the type
+       d.decoder.SetData(nvalues, data)
+       // create a bit reader for our decoder's values
+       d.bitdecoder = utils.NewBitReader(bytes.NewReader(d.data))
+       d.currentBlockVals = 0
+       d.currentMiniBlockVals = 0
+       if d.deltaBitWidths == nil {
+               d.deltaBitWidths = memory.NewResizableBuffer(d.mem)
+       }
+
+       var ok bool
+       d.blockSize, ok = d.bitdecoder.GetVlqInt()
+       if !ok {
+               panic("parquet: eof exception")
+       }
+
+       if d.miniBlocks, ok = d.bitdecoder.GetVlqInt(); !ok {
+               panic("parquet: eof exception")
+       }
+
+       var totalValues uint64
+       if totalValues, ok = d.bitdecoder.GetVlqInt(); !ok {
+               panic("parquet: eof exception")
+       }
+
+       if int(totalValues) != d.nvals {
+               panic("parquet: mismatch between number of values and count in 
data header")
+       }
+
+       if d.lastVal, ok = d.bitdecoder.GetZigZagVlqInt(); !ok {
+               panic("parquet: eof exception")
+       }
+
+       d.valsPerMini = uint64(d.blockSize / d.miniBlocks)

Review comment:
       
https://github.com/apache/parquet-format/blob/master/src/main/thrift/parquet.thrift#L555
 limits number of values.
   




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

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


Reply via email to