crc

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package crc implements the checksum algorithm used throughout pebble.

The algorithm is CRC-32 with Castagnoli's polynomial, followed by a bit rotation and an additional delta. The additional processing is to lessen the probability of arbitrary key/value data coincidentally containing bytes that look like a checksum.

To calculate the uint32 checksum of some data:

var u uint32 = crc.New(data).Value()

In pebble, the uint32 value is then stored in little-endian format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CRC

type CRC uint32

CRC is a small convenience wrapper for computing the CRC32 checksum used by pebble. This is the same algorithm as used by RocksDB.

func New

func New(b []byte) CRC

New returns the result of adding the bytes to the zero-value CRC.

func (CRC) Update

func (c CRC) Update(b []byte) CRC

Update returns the result of adding the bytes to the CRC.

func (CRC) Value

func (c CRC) Value() uint32

Value returns the cooked CRC value. The additional processing is to lessen the probability of arbitrary key/value data coincidentally containing bytes that look like a checksum.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL