Repository navigation
Expand file tree
/
Copy pathfooter.go
More file actions
56 lines (50 loc) · 1.53 KB
/
Copy pathfooter.go
File metadata and controls
56 lines (50 loc) · 1.53 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
package columns
import (
"bytes"
"encoding/gob"
)
// Footer is the file metadata block stored immediately before the trailing
// footer length and magic bytes.
type Footer struct {
Schema []ColumnSchema
RowGroups []RowGroupMeta
}
// RowGroupMeta describes one row group as written by AddRowGroup.
type RowGroupMeta struct {
NumRows uint32
ByteOffset int64
Columns []ColMeta
}
// ColMeta describes one column chunk within a row group.
type ColMeta struct {
ByteLength int64
NullCount uint32
MinVal []byte
MaxVal []byte
MinLen uint32
MaxLen uint32
Encoding uint8
Compress uint8
// Tokenizer is the one-based position of the tokenizer a tokenized column is
// stored through, in the table the file header holds. Zero names none, so a
// file written before tokenized columns, whose gob record carries no such
// field, decodes to the same zero and reads as an untokenized column.
Tokenizer int
}
// encodeFooter serializes f with encoding/gob, which cannot fail on the fixed
// shape of Footer: its only error sources are a value gob cannot represent and a
// writer that rejects a byte, and Footer is this package's own struct encoding
// into a buffer that never rejects one.
func encodeFooter(f Footer) []byte {
var buf bytes.Buffer
_ = gob.NewEncoder(&buf).Encode(f)
return buf.Bytes()
}
// decodeFooter is the inverse of encodeFooter.
func decodeFooter(b []byte) (Footer, error) {
var f Footer
if err := gob.NewDecoder(bytes.NewReader(b)).Decode(&f); err != nil {
return f, err
}
return f, nil
}