-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from reproio/file-wide-config
Support parquet file-wide configuration allows to tune I/O performance and file size
- Loading branch information
Showing
5 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package columnifier | ||
|
||
import ( | ||
"github.com/xitongsys/parquet-go/parquet" | ||
) | ||
|
||
type Config struct { | ||
Parquet Parquet | ||
} | ||
|
||
type Parquet struct { | ||
PageSize int64 | ||
RowGroupSize int64 | ||
CompressionCodec parquet.CompressionCodec | ||
} | ||
|
||
func NewConfig(parquetPageSize, parquetRowGroupSize int64, parquetCompressionCodec string) (*Config, error) { | ||
cc, err := parquet.CompressionCodecFromString(parquetCompressionCodec) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Config{ | ||
Parquet: Parquet{ | ||
PageSize: parquetPageSize, | ||
RowGroupSize: parquetRowGroupSize, | ||
CompressionCodec: cc, | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package columnifier | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/xitongsys/parquet-go/parquet" | ||
) | ||
|
||
func TestNewConfig(t *testing.T) { | ||
cases := []struct { | ||
parquetPageSize int64 | ||
parquetRowGroupSize int64 | ||
parquetCompressionCodec string | ||
expected *Config | ||
isErr bool | ||
}{ | ||
{ | ||
parquetPageSize: 8 * 1024, | ||
parquetRowGroupSize: 128 * 1024 * 1024, | ||
parquetCompressionCodec: "SNAPPY", | ||
expected: &Config{ | ||
Parquet: Parquet{ | ||
PageSize: 8 * 1024, | ||
RowGroupSize: 128 * 1024 * 1024, | ||
CompressionCodec: parquet.CompressionCodec_SNAPPY, | ||
}, | ||
}, | ||
isErr: false, | ||
}, | ||
|
||
{ | ||
parquetPageSize: 8 * 1024, | ||
parquetRowGroupSize: 128 * 1024 * 1024, | ||
parquetCompressionCodec: "INVALID", | ||
expected: nil, | ||
isErr: true, | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
actual, err := NewConfig(c.parquetPageSize, c.parquetRowGroupSize, c.parquetCompressionCodec) | ||
|
||
if err != nil != c.isErr { | ||
t.Errorf("expected %v, but actual %v", c.isErr, err) | ||
} | ||
|
||
if !reflect.DeepEqual(actual, c.expected) { | ||
t.Errorf("expected %v, but actual %v", c.expected, actual) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters