Help us shape the future of Go! Take the 2026 Go Developer Survey

writer

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxPackBytes is the byte ceiling for a single uploaded packfile.
	DefaultMaxPackBytes int64 = 63 * 1024 * 1024
	// DefaultMaxBlocksPerPack is the block-count ceiling for one packfile.
	DefaultMaxBlocksPerPack uint64 = 4096
	// DefaultBloomFalsePositiveRate is the target pack bloom false-positive rate.
	DefaultBloomFalsePositiveRate = 0.008
)
View Source
const ValueOrderIterator = "iterator"

ValueOrderIterator records that physical kvfile value order follows the writer iterator order.

Variables

This section is empty.

Functions

func DigestSortedKeys

func DigestSortedKeys(keys [][]byte) []byte

DigestSortedKeys digests a pack's block keys independent of physical value order.

func PolicyTag

func PolicyTag(policy Policy) string

PolicyTag returns the canonical v1 policy tag for a pack construction policy.

Types

type BlockIterator

type BlockIterator func() (h *hash.Hash, blk *block.StoredBlock, err error)

BlockIterator yields each block to pack with its hash. It returns a nil hash when exhausted.

type PackResult

type PackResult struct {
	// BloomFilter is the serialized bloom filter bytes.
	BloomFilter []byte
	// BlockCount is the number of blocks packed.
	BlockCount uint64
	// BytesWritten is the total bytes written.
	BytesWritten uint64
	// SortedKeyDigest is the v1 digest of the sorted block key set.
	SortedKeyDigest []byte
	// PackBytesDigest is the SHA-256 digest of the kvfile bytes.
	PackBytesDigest []byte
	// PolicyTag is the pack construction policy tag used for v1 identity.
	PolicyTag string
	// ValueOrderPolicy names how physical kvfile values were ordered.
	ValueOrderPolicy string
}

PackResult contains the result of packing blocks into a kvfile.

func PackBlocks

func PackBlocks(w io.Writer, iter BlockIterator) (*PackResult, error)

PackBlocks packs blocks from the iterator into a kvfile and computes a bloom filter sized to the packed block count. Each value is the encoded block.BlockObject of the block's bytes and refs, so every block must carry known refs.

type Policy

type Policy struct {
	MaxPackBytes       int64
	MaxBlocksPerPack   uint64
	BloomFalsePositive float64
	RequireBloomFilter bool
	RequireBlockCount  bool
	RequireCreatedAt   bool
}

Policy describes pack construction limits and required metadata.

func DefaultPolicy

func DefaultPolicy() Policy

DefaultPolicy returns the shared Spacewave pack construction policy.

func (Policy) NewBloomFilter

func (p Policy) NewBloomFilter(blockCount uint64) *bloom.Filter

NewBloomFilter creates an empty bloom filter sized for a pack of blockCount blocks at the policy false-positive rate.

Jump to

Keyboard shortcuts

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