@@ -17,47 +17,6 @@ import (
17
17
"strings"
18
18
)
19
19
20
- // The most signifiant bit indicates whether or not the type is nullable
21
- // The 6 least significant bits identify the type, per below
22
- const (
23
- NullMask = 0x80 // nullable bit
24
- CustomMask = 0x40 // custom schema type bit
25
-
26
- FixedIntMask = 0x70 // 0b00 nnns where s is the signed/unsigned bit and n represents the encoded integer size in (8 << n) bits.
27
- FixedIntByte = 0x00
28
- IntSignedMask = 0x01
29
- IntBitsMask = 0x0E
30
-
31
- VarIntMask = 0x7E
32
- VarIntByte = 0x10 // 0b01 000s where s is the signed/unsigned bit
33
-
34
- FloatMask = 0x7C
35
- FloatBitsMask = 0x01
36
- FloatByte = 0x14 // 0b01 01*n where n is the floating-point size in (32 << n) bits and * is reserved for future use
37
-
38
- ComplexMask = 0x7C
39
- ComplexBitsMask = 0x01
40
- ComplexByte = 0x18 // 0b01 10*n where n is the complex number size in (64 << n) bits and * is reserved for future use
41
-
42
- BoolMask = 0x7F
43
- BoolByte = 0x1C // 0b01 1100
44
-
45
- EnumMask = 0x7F
46
- EnumByte = 0x1D // 0b01 1101
47
-
48
- StringMask = 0x7F
49
- VarStringByte = 0x20 // 0b10 000f where f indicates that the string is of fixed byte length
50
- FixedStringByte = 0x21
51
-
52
- ArrayMask = 0x7F
53
- VarArrayByte = 0x24 // 0b10 010f where f indicates that the array is of fixed length
54
- FixedArrayByte = 0x25
55
-
56
- ObjectMask = 0x7F
57
- VarObjectByte = 0x28 // 0b10 100f where f indicates that the object has fixed number of fields
58
- FixedObjectByte = 0x29
59
- )
60
-
61
20
// Schema is an interface that encodes and decodes data of a specific type
62
21
type Schema interface {
63
22
// Encode uses the schema to write the encoded value of i to the output
@@ -729,7 +688,7 @@ func DecodeSchema(r io.Reader) (Schema, error) {
729
688
s := & FixedIntSchema {}
730
689
s .SetNullable (curByte & NullMask > 0 )
731
690
s .Signed = curByte & IntSignedMask > 0
732
- s .Bits = 8 << ((curByte & IntBitsMask ) >> 1 )
691
+ s .Bits = 8 << ((curByte & FixedIntBitsMask ) >> 1 )
733
692
734
693
return s , nil
735
694
}
@@ -861,6 +820,7 @@ func DecodeSchema(r io.Reader) (Schema, error) {
861
820
return nil , err
862
821
}
863
822
823
+ varStringSchema := VarStringSchema {}
864
824
for i := 0 ; i < int (numFields ); i ++ {
865
825
of := ObjectField {}
866
826
@@ -873,7 +833,6 @@ func DecodeSchema(r io.Reader) (Schema, error) {
873
833
// read out each alias name...
874
834
for j := 0 ; j < int (numAliases ); j ++ {
875
835
alias := ""
876
- varStringSchema := VarStringSchema {}
877
836
878
837
err = varStringSchema .Decode (r , & alias )
879
838
if err != nil {
0 commit comments