github.com/m3db/m3@v1.5.0/src/dbnode/persist/schema/types.go (about)

     1  // Copyright (c) 2016 Uber Technologies, Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in
    11  // all copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19  // THE SOFTWARE.
    20  
    21  package schema
    22  
    23  import (
    24  	"github.com/m3db/m3/src/dbnode/persist"
    25  	"github.com/m3db/m3/src/dbnode/ts"
    26  	"github.com/m3db/m3/src/x/ident"
    27  )
    28  
    29  // MajorVersion is the major schema version for a set of fileset files,
    30  // this is only incremented when breaking changes are introduced and
    31  // tooling needs to upgrade older files to newer files before a server restart
    32  const MajorVersion = 1
    33  
    34  // MinorVersion is the minor schema version for a set of fileset files.
    35  // This is only incremented when *non-breaking* changes are introduced that
    36  // we want to have some level of control around how they're rolled out.
    37  const MinorVersion = 1
    38  
    39  // IndexInfo stores metadata information about block filesets.
    40  type IndexInfo struct {
    41  	MajorVersion int64
    42  	BlockStart   int64
    43  	BlockSize    int64
    44  	Entries      int64
    45  	Summaries    IndexSummariesInfo
    46  	BloomFilter  IndexBloomFilterInfo
    47  	SnapshotTime int64
    48  	FileType     persist.FileSetType
    49  	SnapshotID   []byte
    50  	VolumeIndex  int
    51  	MinorVersion int64
    52  }
    53  
    54  // IndexSummariesInfo stores metadata about the summaries.
    55  type IndexSummariesInfo struct {
    56  	Summaries int64
    57  }
    58  
    59  // IndexBloomFilterInfo stores metadata about the bloom filter.
    60  type IndexBloomFilterInfo struct {
    61  	NumElementsM int64
    62  	NumHashesK   int64
    63  }
    64  
    65  // IndexEntry stores entry-level data indexing.
    66  //
    67  // When serialized to disk, the encoder will automatically add the IndexEntryChecksum, a checksum to validate
    68  // the index entry itself, to the end of the entry. That field is not exposed on this struct as this is handled
    69  // transparently by the encoder and decoder. Appending of checksum starts in V3.
    70  type IndexEntry struct {
    71  	Index         int64
    72  	ID            []byte
    73  	Size          int64
    74  	Offset        int64
    75  	DataChecksum  int64
    76  	EncodedTags   []byte
    77  	IndexChecksum int64
    78  }
    79  
    80  // IndexEntryHasher hashes an index entry.
    81  type IndexEntryHasher interface {
    82  	// HashIndexEntry computes a hash value for this index entry using its ID, tags,
    83  	// and the computed data checksum.
    84  	// NB: not passing the whole IndexEntry because of linter message:
    85  	// "hugeParam: e is heavy (88 bytes); consider passing it by pointer".
    86  	HashIndexEntry(
    87  		id ident.BytesID,
    88  		encodedTags ts.EncodedTags,
    89  		dataChecksum int64,
    90  	) int64
    91  }
    92  
    93  // IndexSummary stores a summary of an index entry to lookup.
    94  type IndexSummary struct {
    95  	Index            int64
    96  	ID               []byte
    97  	IndexEntryOffset int64
    98  }
    99  
   100  // LogInfo stores summary information about a commit log.
   101  type LogInfo struct {
   102  	// Deprecated fields, left intact as documentation for the actual
   103  	// format on disk.
   104  	DeprecatedDoNotUseStart    int64
   105  	DeprecatedDoNotUseDuration int64
   106  
   107  	Index int64
   108  }
   109  
   110  // LogEntry stores per-entry data in a commit log
   111  type LogEntry struct {
   112  	Index      uint64
   113  	Create     int64
   114  	Metadata   []byte
   115  	Timestamp  int64
   116  	Value      float64
   117  	Unit       uint32
   118  	Annotation []byte
   119  }
   120  
   121  // LogMetadata stores metadata information about a commit log.
   122  type LogMetadata struct {
   123  	ID          []byte
   124  	Namespace   []byte
   125  	Shard       uint32
   126  	EncodedTags []byte
   127  }