sharding

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 5 modules, 14 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatedShardFn

type AggregatedShardFn func(chunkedID id.ChunkedID, numShards int) uint32

AggregatedShardFn maps a chunked id to a shard.

type HashType

type HashType string

HashType is the hashing type.

const (
	// Murmur32Hash represents the murmur3 hash.
	Murmur32Hash HashType = "murmur32"

	DefaultHash = Murmur32Hash
)

List of supported hashing types.

func (HashType) AggregatedShardFn

func (t HashType) AggregatedShardFn() (AggregatedShardFn, error)

AggregatedShardFn returns the sharding function for computing aggregated shards.

func (HashType) MustShardFn

func (t HashType) MustShardFn() ShardFn

MustShardFn returns the sharding function, or panics if an error is encountered.

func (HashType) ShardFn

func (t HashType) ShardFn() (ShardFn, error)

ShardFn returns the sharding function.

func (*HashType) UnmarshalYAML

func (t *HashType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals YAML object into a hash type.

type ShardFn

type ShardFn func(id []byte, numShards uint32) uint32

ShardFn maps a id to a shard.

type ShardSet

type ShardSet map[uint32]struct{}

ShardSet is a collection of shards organized as a set. The shards contained in the set can be discontinuous.

func MustParseShardSet

func MustParseShardSet(s string) ShardSet

MustParseShardSet parses a shard set from the input string, and panics if parsing is unsuccessful.

func ParseShardSet

func ParseShardSet(s string) (ShardSet, error)

ParseShardSet parses a shard set from the input string.

func (ShardSet) Add

func (ss ShardSet) Add(p uint32)

Add adds the shard to the set.

func (ShardSet) AddBetween

func (ss ShardSet) AddBetween(minInclusive, maxExclusive uint32)

AddBetween adds shards between the given min (inclusive) and max (exclusive).

func (ShardSet) Contains

func (ss ShardSet) Contains(p uint32) bool

Contains returns true if the shard set contains the given shard.

func (ShardSet) ParseRange

func (ss ShardSet) ParseRange(s string) error

ParseRange parses a range of shards and adds them to the set.

func (*ShardSet) UnmarshalYAML

func (ss *ShardSet) UnmarshalYAML(f func(interface{}) error) error

UnmarshalYAML unmarshals YAML into a shard set. The following formats are supported: * StartShard..EndShard, e.g., 0..63. * Single shard, e.g., 5. * Array containing shard ranges and single shards.

Jump to

Keyboard shortcuts

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