labels

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 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 (
	IngestBlockEvent    = imageblk.IngestBlockEvent
	MutateBlockEvent    = imageblk.MutateBlockEvent
	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, leading to max int = 2^53 - 1).
	// 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

This section is empty.

Functions

func MergeStart added in v0.8.0

func MergeStart(iv dvid.InstanceVersion, op MergeOp) error

MergeStart handles label map caches during an active merge operation. Note that if there are multiple synced label instances, the InstanceVersion will always be the labelblk instance. Multiple merges into a single label are allowed, but chained merges are not. For example, you can merge label 1, 2, and 3 into 4, then later merge 6 into 4. However, you cannot concurrently merge label 4 into some other label because there can be a race condition between 3 -> 4 and 4 -> X.

func MergeStop added in v0.8.0

func MergeStop(iv dvid.InstanceVersion, op MergeOp)

MergeStop marks the end of a merge operation.

func SplitStart added in v0.8.0

func SplitStart(iv dvid.InstanceVersion, op DeltaSplitStart) error

SplitStart checks current label map to see if the split conflicts.

func SplitStop added in v0.8.0

func SplitStop(iv dvid.InstanceVersion, op DeltaSplitEnd)

SplitStop marks the end of a split operation.

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 Mapping

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

Mapping is a thread-safe, mapping of labels to labels in both forward and backward direction. Mutation of a Mapping instance can only be done through labels.MergeCache.

func LabelMap added in v0.8.0

func LabelMap(iv dvid.InstanceVersion) *Mapping

LabelMap returns a label mapping for a version of a data instance. If no label mapping is available, a nil is returned.

func (*Mapping) ConstituentLabels added in v0.8.0

func (m *Mapping) ConstituentLabels(final uint64) Set

ConstituentLabels returns a set of labels that will be mapped to the given label. The set will always include the given label.

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.

func (MergeOp) String added in v0.8.5

func (op MergeOp) String() string

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) Copy added in v0.8.5

func (s Set) Copy() Set

Copy returns a duplicate of the Set.

func (Set) Exists added in v0.8.5

func (s Set) Exists(i uint64) bool

Exists returns true if the given uint64 is present in the Set.

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