partition

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package partition implements a location system to find a shard or index rule. This system reflects the entity identity which is a intermediate result in calculating the target shard.

Index

Constants

This section is empty.

Variables

View Source
var ErrMalformedElement = errors.New("element is malformed")

ErrMalformedElement indicates the element is malformed.

Functions

func GetTagByOffset

func GetTagByOffset(value []*modelv1.TagFamilyForWrite, fIndex, tIndex int) (*modelv1.TagValue, error)

GetTagByOffset gets a tag value based of a tag family offset and a tag offset in this family.

func ShardID

func ShardID(key []byte, shardNum uint32) (uint, error)

ShardID calculates a shard id.

Types

type EntityLocator

type EntityLocator struct {
	TagLocators []TagLocator
	ModRevision int64
}

EntityLocator combines several TagLocators that help find the entity value.

func NewEntityLocator

func NewEntityLocator(families []*databasev1.TagFamilySpec, entity *databasev1.Entity, modRevision int64) EntityLocator

NewEntityLocator return a EntityLocator based on tag family spec and entity spec.

func (EntityLocator) Find

Find the entity from a tag family, prepend a subject to the entity.

func (EntityLocator) Locate

func (e EntityLocator) Locate(subject string, value []*modelv1.TagFamilyForWrite, shardNum uint32) (tsdb.Entity, tsdb.EntityValues, common.ShardID, error)

Locate a shard and find the entity from a tag family, prepend a subject to the entity.

type IndexRuleLocator

type IndexRuleLocator struct {
	Rule       *databasev1.IndexRule
	TagIndices []TagLocator
}

IndexRuleLocator combines several TagLocators that help find the index value.

func ParseIndexRuleLocators

func ParseIndexRuleLocators(families []*databasev1.TagFamilySpec, indexRules []*databasev1.IndexRule) (locators []*IndexRuleLocator)

ParseIndexRuleLocators returns a IndexRuleLocator based on the tag family spec and index rules.

type TagLocator

type TagLocator struct {
	FamilyOffset int
	TagOffset    int
}

TagLocator contains offsets to retrieve a tag swiftly.

Jump to

Keyboard shortcuts

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