github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/limits.go (about)

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