storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/s3select/internal/parquet-go/data/data.go (about) 1 /* 2 * Minio Cloud Storage, (C) 2019 Minio, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package data 18 19 import ( 20 "storj.io/minio/pkg/s3select/internal/parquet-go/gen-go/parquet" 21 ) 22 23 // ColumnChunk ... 24 type ColumnChunk struct { 25 parquet.ColumnChunk 26 isDictPage bool 27 dictPageLen int64 28 dataPageLen int64 29 dataLen int64 30 data []byte 31 } 32 33 // Data returns the data. 34 func (chunk *ColumnChunk) Data() []byte { 35 return chunk.data 36 } 37 38 // DataLen returns the length of the data. 39 func (chunk *ColumnChunk) DataLen() int64 { 40 return chunk.dataLen 41 } 42 43 // NewRowGroup creates a new row group. 44 func NewRowGroup(chunks []*ColumnChunk, numRows, offset int64) *parquet.RowGroup { 45 rows := parquet.NewRowGroup() 46 rows.NumRows = numRows 47 48 for _, chunk := range chunks { 49 rows.Columns = append(rows.Columns, &chunk.ColumnChunk) 50 rows.TotalByteSize += chunk.dataLen 51 52 chunk.ColumnChunk.FileOffset = offset 53 54 if chunk.isDictPage { 55 dictPageOffset := offset 56 chunk.ColumnChunk.MetaData.DictionaryPageOffset = &dictPageOffset 57 offset += chunk.dictPageLen 58 } 59 60 chunk.ColumnChunk.MetaData.DataPageOffset = offset 61 offset += chunk.dataPageLen 62 } 63 64 return rows 65 }