shard

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package shard ports DatoriumDB document sharding helpers (CRC32 of the sharding prefix → 8-bit slot).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RawSlot

func RawSlot(input string) byte

RawSlot returns the 8-bit shard slot for an arbitrary byte string using CRC32 with no document-ID prefix detection. Search result shards use this.

func RawSlotHex

func RawSlotHex(input string) string

RawSlotHex returns the two-character uppercase hex form of RawSlot.

func Slot

func Slot(documentID string) byte

Slot returns the 8-bit shard slot for a document ID using CRC32 of the sharding prefix. Periods in the first six rune positions are ignored for prefix detection. If there is no later period, the whole ID is used.

func SlotHex

func SlotHex(documentID string) string

SlotHex returns the two-character uppercase hex form of Slot.

func ValidateFullCoverage

func ValidateFullCoverage(ranges []Range) error

ValidateFullCoverage ensures ranges cover every slot 0x00-0xFF without overlap.

Types

type Range

type Range struct {
	Start byte
	End   byte
	Raw   string
}

Range describes an inclusive hex shard range such as "00-7F".

func ParseRange

func ParseRange(raw string) (Range, error)

ParseRange parses "AA-BB" or a single slot "7A".

func (Range) Contains

func (r Range) Contains(slot byte) bool

Contains reports whether slot is inside r.

Jump to

Keyboard shortcuts

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