-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathempty.go
More file actions
81 lines (73 loc) · 1.85 KB
/
Copy pathempty.go
File metadata and controls
81 lines (73 loc) · 1.85 KB
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
package vector
import (
"github.com/brimdata/super"
"github.com/brimdata/super/scode"
"github.com/brimdata/super/sup"
)
// An Empty vector represents a vector with a type of zero length.
// These are needed to support recursive types since the invariant on union
// values is that the Type method may be called on a zero-length element of
// a union but zero-length values of recursel XXX
type Empty struct {
typ super.Type
}
var _ Any = (*Empty)(nil)
func NewEmpty(typ super.Type) *Empty {
return &Empty{typ}
}
func (e *Empty) Kind() Kind {
typ := e.typ
for {
switch t := typ.(type) {
case *super.TypeOfUint8, *super.TypeOfUint16, *super.TypeOfUint32, *super.TypeOfUint64:
return KindUint
case *super.TypeOfInt8, *super.TypeOfInt16, *super.TypeOfInt32, *super.TypeOfInt64, *super.TypeOfDuration, *super.TypeOfTime:
return KindInt
case *super.TypeOfFloat16, *super.TypeOfFloat32, *super.TypeOfFloat64:
return KindFloat
case *super.TypeOfBool:
return KindBool
case *super.TypeOfBytes:
return KindBytes
case *super.TypeOfString:
return KindString
case *super.TypeOfIP:
return KindIP
case *super.TypeOfNet:
return KindNet
case *super.TypeOfType:
return KindType
case *super.TypeOfNull:
return KindNull
case *super.TypeOfNone:
return KindNone
case *super.TypeRecord:
return KindRecord
case *super.TypeArray:
return KindArray
case *super.TypeSet:
return KindSet
case *super.TypeMap:
return KindMap
case *super.TypeUnion:
return KindUnion
case *super.TypeEnum:
return KindEnum
case *super.TypeError:
return KindError
case *super.TypeFusion:
return KindFusion
case *super.TypeNamed:
typ = t.Type
default:
panic(sup.String(e.typ))
}
}
}
func (e *Empty) Type() super.Type {
return e.typ
}
func (*Empty) Len() uint32 {
return 0
}
func (*Empty) Serialize(*scode.Builder, uint32) {}