aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ClickHouse/ch-go/proto/col_low_cardinality_enum.go
blob: ade86f27add3f1cf2406bd6c222041f2cf94e6a2 (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Code generated by "enumer -type CardinalityKey -trimprefix Key -output col_low_cardinality_enum.go"; DO NOT EDIT.

package proto

import (
	"fmt"
	"strings"
)

const _CardinalityKeyName = "UInt8UInt16UInt32UInt64"

var _CardinalityKeyIndex = [...]uint8{0, 5, 11, 17, 23}

const _CardinalityKeyLowerName = "uint8uint16uint32uint64"

func (i CardinalityKey) String() string {
	if i >= CardinalityKey(len(_CardinalityKeyIndex)-1) {
		return fmt.Sprintf("CardinalityKey(%d)", i)
	}
	return _CardinalityKeyName[_CardinalityKeyIndex[i]:_CardinalityKeyIndex[i+1]]
}

// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _CardinalityKeyNoOp() {
	var x [1]struct{}
	_ = x[KeyUInt8-(0)]
	_ = x[KeyUInt16-(1)]
	_ = x[KeyUInt32-(2)]
	_ = x[KeyUInt64-(3)]
}

var _CardinalityKeyValues = []CardinalityKey{KeyUInt8, KeyUInt16, KeyUInt32, KeyUInt64}

var _CardinalityKeyNameToValueMap = map[string]CardinalityKey{
	_CardinalityKeyName[0:5]:        KeyUInt8,
	_CardinalityKeyLowerName[0:5]:   KeyUInt8,
	_CardinalityKeyName[5:11]:       KeyUInt16,
	_CardinalityKeyLowerName[5:11]:  KeyUInt16,
	_CardinalityKeyName[11:17]:      KeyUInt32,
	_CardinalityKeyLowerName[11:17]: KeyUInt32,
	_CardinalityKeyName[17:23]:      KeyUInt64,
	_CardinalityKeyLowerName[17:23]: KeyUInt64,
}

var _CardinalityKeyNames = []string{
	_CardinalityKeyName[0:5],
	_CardinalityKeyName[5:11],
	_CardinalityKeyName[11:17],
	_CardinalityKeyName[17:23],
}

// CardinalityKeyString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func CardinalityKeyString(s string) (CardinalityKey, error) {
	if val, ok := _CardinalityKeyNameToValueMap[s]; ok {
		return val, nil
	}

	if val, ok := _CardinalityKeyNameToValueMap[strings.ToLower(s)]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to CardinalityKey values", s)
}

// CardinalityKeyValues returns all values of the enum
func CardinalityKeyValues() []CardinalityKey {
	return _CardinalityKeyValues
}

// CardinalityKeyStrings returns a slice of all String values of the enum
func CardinalityKeyStrings() []string {
	strs := make([]string, len(_CardinalityKeyNames))
	copy(strs, _CardinalityKeyNames)
	return strs
}

// IsACardinalityKey returns "true" if the value is listed in the enum definition. "false" otherwise
func (i CardinalityKey) IsACardinalityKey() bool {
	for _, v := range _CardinalityKeyValues {
		if i == v {
			return true
		}
	}
	return false
}