dwilson1988 commented on code in PR #177: URL: https://github.com/apache/iceberg-go/pull/177#discussion_r1813446168
########## manifest.go: ########## @@ -876,7 +1030,140 @@ func (m *manifestEntryV2) FileSequenceNum() *int64 { return m.FileSeqNum } -func (m *manifestEntryV2) DataFile() DataFile { return &m.Data } +func (m *manifestEntryV2) DataFile() DataFile { return m.Data } + +// DataFileBuilder is a helper for building a data file struct which will +// conform to the DataFile interface. +type DataFileBuilder struct { + d *dataFile +} + +// NewDataFileBuilder is passed all of the required fields and then allows +// all of the optional fields to be set by calling the corresponding methods +// before calling [DataFileBuilder.Build] to construct the object. +func NewDataFileBuilder( + content ManifestEntryContent, + path string, + format FileFormat, + partitionData map[string]any, + recordCount int64, + fileSize int64, +) *DataFileBuilder { + return &DataFileBuilder{ + d: &dataFile{ + Content: content, + Path: path, + Format: format, + PartitionData: partitionData, + RecordCount: recordCount, + FileSize: fileSize, + }, + } +} + +// BlockSizeInBytes sets the block size in bytes for the data file. Deprecated in v2. +func (b *DataFileBuilder) BlockSizeInBytes(size int64) *DataFileBuilder { + b.d.BlockSizeInBytes = size + return b +} + +// ColumnSizes sets the column sizes for the data file. +func (b *DataFileBuilder) ColumnSizes(sizes map[int]int64) *DataFileBuilder { + colSizes := make([]colMap[int, int64], 0, len(sizes)) + for k, v := range sizes { + colSizes = append(colSizes, colMap[int, int64]{Key: k, Value: v}) + } + b.d.ColSizes = &colSizes + return b +} + +// ValueCounts sets the value counts for the data file. +func (b *DataFileBuilder) ValueCounts(counts map[int]int64) *DataFileBuilder { + vals := make([]colMap[int, int64], 0, len(counts)) + for k, v := range counts { + vals = append(vals, colMap[int, int64]{Key: k, Value: v}) + } Review Comment: 🤦 That's what I get for doing this late at night. -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org