forked from segmentio/parquet-go
/
limits.go
45 lines (35 loc) · 1.1 KB
/
limits.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package parquet
import (
"fmt"
"math"
)
const (
// MaxColumnDepth is the maximum column depth supported by this package.
MaxColumnDepth = math.MaxInt8
// MaxColumnIndex is the maximum column index supported by this package.
MaxColumnIndex = math.MaxInt16
// MaxRepetitionLevel is the maximum repetition level supported by this package.
MaxRepetitionLevel = math.MaxInt8
// MaxDefinitionLevel is the maximum definition level supported by this package.
MaxDefinitionLevel = math.MaxInt8
)
func makeRepetitionLevel(i int) int8 {
checkIndexRange("repetition level", i, 0, MaxRepetitionLevel)
return int8(i)
}
func makeDefinitionLevel(i int) int8 {
checkIndexRange("definition level", i, 0, MaxDefinitionLevel)
return int8(i)
}
func makeColumnIndex(i int) int16 {
checkIndexRange("column index", i, 0, MaxColumnIndex)
return int16(i)
}
func checkIndexRange(typ string, i, min, max int) {
if i < min || i > max {
panic(errIndexOutOfRange(typ, i, min, max))
}
}
func errIndexOutOfRange(typ string, i, min, max int) error {
return fmt.Errorf("%s out of range: %d not in [%d:%d]", typ, i, min, max)
}