shards

package
Version: v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package shards provides a low level support for implementing sharded set of []byte blobs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShardIndex

func ShardIndex(member []byte, shardCount int) int

ShardIndex returns an index of a shard to use when storing given blob.

Types

type Set

type Set []Shard

Set is an array of shards (representing a single sharded set).

The size of the array is number of shards in the set. Allocate it using regular make(...).

func (Set) Insert

func (s Set) Insert(blob []byte)

Insert adds a blob into the sharded set.

type Shard

type Shard map[string]struct{}

Shard is a set of byte blobs.

It represents s single shard of a sharded set.

func ParseShard

func ParseShard(blob []byte) (Shard, error)

ParseShard deserializes a shard (serialized with Serialize).

func (Shard) Serialize

func (s Shard) Serialize() []byte

Serialize serializes the shard to a byte buffer.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL