github.com/Schaudge/grailbase@v0.0.0-20240223061707-44c758a471c0/recordio/internal/magic.go (about)

     1  package internal
     2  
     3  import (
     4  	"hash/crc32"
     5  )
     6  
     7  // NumMagicBytes is the size of a magic header stored at the beginning of every
     8  // chunk.
     9  const NumMagicBytes = 8
    10  
    11  // MagicBytes is stored in the first 8 bytes of any chunk.
    12  type MagicBytes = [NumMagicBytes]byte
    13  
    14  // MagicLegacy is the legacy "unpacked" block header.
    15  var MagicLegacyUnpacked = MagicBytes{0xfc, 0xae, 0x95, 0x31, 0xf0, 0xd9, 0xbd, 0x20}
    16  
    17  // MagicPacked is the legacy "packed" block header, and the v2 data block header.
    18  var MagicPacked = MagicBytes{0x2e, 0x76, 0x47, 0xeb, 0x34, 0x07, 0x3c, 0x2e}
    19  
    20  // MagicHeader is a constant random 8 bytes used to distinguish the header block
    21  // of a v2 recordio file.
    22  var MagicHeader = MagicBytes{0xd9, 0xe1, 0xd9, 0x5c, 0xc2, 0x16, 0x04, 0xf7}
    23  
    24  // MagicTrailer is a constant random 8 bytes used to distinguish the trailer block
    25  // of a v2 recordio file.
    26  var MagicTrailer = MagicBytes{0xfe, 0xba, 0x1a, 0xd7, 0xcb, 0xdf, 0x75, 0x3a}
    27  
    28  // MagicInvalid is a sentinel. It is never stored in storage.
    29  var MagicInvalid = MagicBytes{0xe4, 0xe7, 0x9a, 0xc1, 0xb3, 0xf6, 0xb7, 0xa2}
    30  
    31  // MaxReadRecordSize defines a max size for a record when reading to avoid
    32  // crashes for unreasonable requests.
    33  var MaxReadRecordSize = uint64(1 << 29)
    34  
    35  // IEEECRC is used to compute IEEE CRC chunk checksums.
    36  var IEEECRC *crc32.Table
    37  
    38  func init() {
    39  	IEEECRC = crc32.MakeTable(crc32.IEEE)
    40  }