labels

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2015 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package labels supports label-based data types like labelblk, labelvol, labelsurf, labelsz, etc. Basic 64-bit label data and deltas are kept here so all label-based data types can use them without cyclic package dependencies, especially when writing code to synchronize across data instances.

Index

Constants

View Source
const (
	ChangeBlockEvent    = imageblk.ChangeBlockEvent
	DeleteBlockEvent    = imageblk.DeleteBlockEvent
	SparsevolStartEvent = "SPARSEVOL_START"
	SparsevolModEvent   = "SPARSEVOL_MOD"
	SparsevolEndEvent   = "SPARSEVOL_END"
	ChangeSizeEvent     = "LABEL_SIZE_CHANGE"
	MergeStartEvent     = "MERGE_START"
	MergeBlockEvent     = "MERGE_BLOCK"
	MergeEndEvent       = "MERGE_END"
	SplitStartEvent     = "SPLIT_START"
	SplitLabelEvent     = "SPLIT_LABEL"
	SplitEndEvent       = "SPLIT_END"
)

Label change event identifiers

View Source
const (
	// MaxAllowedLabel is the largest label that should be allowed by DVID if we want to take
	// into account the maximum integer size within Javascript (due to its underlying use of
	// a double float for numbers).
	// This would circumvent the need to use strings within JSON (e.g., the Google solution)
	// to represent integer labels that could exceed the max javascript number.  It would
	// require adding a value check on each label voxel of a mutation request, which might
	// be too much of a hit to handle an edge case.
	MaxAllowedLabel = 9007199254740991
)

Variables

View Source
var (
	// MergeCache is a thread-safe cache for merge operations that provides
	// the current label mapping for any version of a data instance.
	MergeCache mergeCache
)

Functions

This section is empty.

Types

type Counts

type Counts struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Counts is a thread-safe type for counting label references.

func (*Counts) Decr

func (c *Counts) Decr(label uint64)

Decr decrements the count for a label.

func (*Counts) Empty

func (c *Counts) Empty() bool

Empty returns true if there are no counts.

func (*Counts) Incr

func (c *Counts) Incr(label uint64)

Incr increments the count for a label.

func (*Counts) Value

func (c *Counts) Value(label uint64) int

Value returns the count for a label.

type DeleteBlock

type DeleteBlock imageblk.Block

DeleteBlock encapsulates data necessary to delete blocks of labels.

type DeltaDeleteSize

type DeltaDeleteSize struct {
	Label    uint64
	OldSize  uint64
	OldKnown bool // true if OldSize is valid, otherwise delete all size k/v for this label.
}

DeltaDeleteSize gives info to delete a label's size.

type DeltaMerge

type DeltaMerge struct {
	MergeOp
	Blocks map[dvid.IZYXString]struct{}
}

DeltaMerge describes the labels and blocks affected by a merge operation. It is sent during a MergeBlockEvent.

type DeltaMergeEnd

type DeltaMergeEnd struct {
	MergeOp
}

DeltaMergeEnd is the data sent during a MergeEndEvent.

type DeltaMergeStart

type DeltaMergeStart struct {
	MergeOp
}

DeltaMergeStart is the data sent during a MergeStartEvent.

type DeltaModSize

type DeltaModSize struct {
	Label      uint64
	SizeChange int64 // Adds to old label size
}

DeltaModSize gives info to modify an existing label size without knowing the old size.

type DeltaNewSize

type DeltaNewSize struct {
	Label uint64
	Size  uint64
}

DeltaNewSize is a new label being introduced.

type DeltaReplaceSize

type DeltaReplaceSize struct {
	Label   uint64
	OldSize uint64
	NewSize uint64
}

DeltaReplaceSize gives info to precisely remove an old label size and add the updated size.

type DeltaSparsevol

type DeltaSparsevol struct {
	Label uint64
	Mods  dvid.BlockRLEs
}

DeltaSparsevol describes a change to an existing label.

type DeltaSplit

type DeltaSplit struct {
	OldLabel     uint64
	NewLabel     uint64
	Split        dvid.BlockRLEs
	SortedBlocks dvid.IZYXSlice
}

DeltaSplit describes the voxels modified during a split operation. The Split field may be null if this is a coarse split only defined by block indices.

type DeltaSplitEnd

type DeltaSplitEnd struct {
	OldLabel uint64
	NewLabel uint64
}

DeltaSplitEnd is the data sent during a SplitEndEvent.

type DeltaSplitStart

type DeltaSplitStart struct {
	OldLabel uint64
	NewLabel uint64
}

DeltaSplitStart is the data sent during a SplitStartEvent.

type DirtyCache

type DirtyCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

DirtyCache tracks dirty labels across versions

func (*DirtyCache) AddMerge

func (d *DirtyCache) AddMerge(iv dvid.InstanceVersion, op MergeOp)

func (*DirtyCache) Decr

func (d *DirtyCache) Decr(iv dvid.InstanceVersion, label uint64)

func (*DirtyCache) Empty

func (d *DirtyCache) Empty(iv dvid.InstanceVersion) bool

func (*DirtyCache) Incr

func (d *DirtyCache) Incr(iv dvid.InstanceVersion, label uint64)

func (*DirtyCache) IsDirty

func (d *DirtyCache) IsDirty(iv dvid.InstanceVersion, label uint64) bool

func (*DirtyCache) RemoveMerge

func (d *DirtyCache) RemoveMerge(iv dvid.InstanceVersion, op MergeOp)

type Mapping

type Mapping struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Mapping is an immutable thread-safe mapping of labels to labels.

func (Mapping) FinalLabel

func (m Mapping) FinalLabel(start uint64) (uint64, bool)

FinalLabel follows mappings from a start label until a final mapped label is reached.

func (Mapping) Get

func (m Mapping) Get(label uint64) (uint64, bool)

Get returns the mapping or false if no mapping exists.

type MergeOp

type MergeOp struct {
	Target uint64
	Merged Set
}

MergeOp represents the merging of a set of labels into a target label.

type MergeTuple

type MergeTuple []uint64

MergeTuple represents a merge of labels. Its first element is the destination label and all later elements in the slice are labels to be merged. It's an easy JSON representation as a list of labels.

func (MergeTuple) Op

func (t MergeTuple) Op() (MergeOp, error)

Op converts a MergeTuple into a MergeOp.

type Set

type Set map[uint64]struct{}

Set is a set of labels.

func (Set) String

func (s Set) String() string

Jump to

Keyboard shortcuts

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