-
Notifications
You must be signed in to change notification settings - Fork 451
/
types.go
129 lines (114 loc) · 4.07 KB
/
types.go
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package schema
import (
"github.com/m3db/m3/src/dbnode/persist"
)
// MajorVersion is the major schema version for a set of fileset files,
// this is only incremented when breaking changes are introduced and
// tooling needs to upgrade older files to newer files before a server restart
const MajorVersion = 1
// MinorVersion is the minor schema version for a set of fileset files.
// This is only incremented when *non-breaking* changes are introduced that
// we want to have some level of control around how they're rolled out.
const MinorVersion = 1
// IndexInfo stores metadata information about block filesets.
type IndexInfo struct {
MajorVersion int64
BlockStart int64
BlockSize int64
Entries int64
Summaries IndexSummariesInfo
BloomFilter IndexBloomFilterInfo
SnapshotTime int64
FileType persist.FileSetType
SnapshotID []byte
VolumeIndex int
MinorVersion int64
}
// IndexSummariesInfo stores metadata about the summaries.
type IndexSummariesInfo struct {
Summaries int64
}
// IndexBloomFilterInfo stores metadata about the bloom filter.
type IndexBloomFilterInfo struct {
NumElementsM int64
NumHashesK int64
}
// IndexEntry stores entry-level data indexing.
//
// When serialized to disk, the encoder will automatically add the IndexEntryChecksum, a checksum to validate
// the index entry itself, to the end of the entry. That field is not exposed on this struct as this is handled
// transparently by the encoder and decoder. Appending of checksum starts in V3.
type IndexEntry struct {
Index int64
ID []byte
Size int64
Offset int64
DataChecksum int64
EncodedTags []byte
IndexChecksum int64
}
// IndexChecksum extends IndexEntry for use with queries, by providing
// an additional metadata checksum field.
type IndexChecksum struct {
// IndexChecksum embeds IndexEntry.
IndexEntry
// MetadataChecksum is the computed index metadata checksum.
// NB: built from ID, DataChecksum, and tags.
MetadataChecksum int64
}
// IndexEntryHasher hashes an index entry.
type IndexEntryHasher interface {
// HashIndexEntry computes a hash value for this IndexEntry using its ID, tags,
// and the computed data checksum.
HashIndexEntry(e IndexEntry) int64
}
// IndexSummary stores a summary of an index entry to lookup.
type IndexSummary struct {
Index int64
ID []byte
IndexEntryOffset int64
}
// LogInfo stores summary information about a commit log.
type LogInfo struct {
// Deprecated fields, left intact as documentation for the actual
// format on disk.
DeprecatedDoNotUseStart int64
DeprecatedDoNotUseDuration int64
Index int64
}
// LogEntry stores per-entry data in a commit log
type LogEntry struct {
Index uint64
Create int64
Metadata []byte
Timestamp int64
Value float64
Unit uint32
Annotation []byte
}
// LogMetadata stores metadata information about a commit log.
type LogMetadata struct {
ID []byte
Namespace []byte
Shard uint32
EncodedTags []byte
}