github.com/parquet-go/parquet-go@v0.21.1-0.20240501160520-b3c3a0c3ed6f/page_min_purego.go (about) 1 //go:build purego || !amd64 2 3 package parquet 4 5 import "encoding/binary" 6 7 // ----------------------------------------------------------------------------- 8 // TODO: use generics versions of the these functions to reduce the amount of 9 // code to maintain when we drop compatilibty with Go version older than 1.18. 10 // ----------------------------------------------------------------------------- 11 12 func minInt32(data []int32) (min int32) { 13 if len(data) > 0 { 14 min = data[0] 15 16 for _, value := range data { 17 if value < min { 18 min = value 19 } 20 } 21 } 22 return min 23 } 24 25 func minInt64(data []int64) (min int64) { 26 if len(data) > 0 { 27 min = data[0] 28 29 for _, value := range data { 30 if value < min { 31 min = value 32 } 33 } 34 } 35 return min 36 } 37 38 func minUint32(data []uint32) (min uint32) { 39 if len(data) > 0 { 40 min = data[0] 41 42 for _, value := range data { 43 if value < min { 44 min = value 45 } 46 } 47 } 48 return min 49 } 50 51 func minUint64(data []uint64) (min uint64) { 52 if len(data) > 0 { 53 min = data[0] 54 55 for _, value := range data { 56 if value < min { 57 min = value 58 } 59 } 60 } 61 return min 62 } 63 64 func minFloat32(data []float32) (min float32) { 65 if len(data) > 0 { 66 min = data[0] 67 68 for _, value := range data { 69 if value < min { 70 min = value 71 } 72 } 73 } 74 return min 75 } 76 77 func minFloat64(data []float64) (min float64) { 78 if len(data) > 0 { 79 min = data[0] 80 81 for _, value := range data { 82 if value < min { 83 min = value 84 } 85 } 86 } 87 return min 88 } 89 90 func minBE128(data [][16]byte) (min []byte) { 91 if len(data) > 0 { 92 m := binary.BigEndian.Uint64(data[0][:8]) 93 j := 0 94 for i := 1; i < len(data); i++ { 95 x := binary.BigEndian.Uint64(data[i][:8]) 96 switch { 97 case x < m: 98 m, j = x, i 99 case x == m: 100 y := binary.BigEndian.Uint64(data[i][8:]) 101 n := binary.BigEndian.Uint64(data[j][8:]) 102 if y < n { 103 m, j = x, i 104 } 105 } 106 } 107 min = data[j][:] 108 } 109 return min 110 }