dvid

package
v0.0.0-...-e545f54 Latest Latest
Warning

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

Go to latest
Published: May 6, 2014 License: BSD-3-Clause Imports: 35 Imported by: 0

Documentation

Overview

Package dvid provides types, constants, and functions that have no other dependencies and can be used by all packages within DVID. This includes core data structures, command string handling, and command packaging. Since these elements are used at multiple DVID layers, we separate them here and allow reuse in layer-specific types through embedding.

Index

Constants

View Source
const (
	LocalIDSize   = 2
	LocalID32Size = 4

	MaxLocalID   = 0xFFFF
	MaxLocalID32 = 0xFFFFFFFF
)
View Source
const (
	NoCompression      CompressionLevel = 0
	BestSpeed                           = 1
	BestCompression                     = 9
	DefaultCompression                  = -1
)
View Source
const (
	Uncompressed CompressionFormat = 0
	Snappy                         = 1 << (iota - 1)
	Gzip                           // Gzip stores length and checksum automatically.
	LZ4
)
View Source
const (
	Kilo = 1 << 10
	Mega = 1 << 20
	Giga = 1 << 30
	Tera = 1 << 40
)
View Source
const (
	EncodingBinary      byte = 0x00
	EncodingGrayscale8       = 0x01
	EncodingGrayscale16      = 0x02
	EncodingNormal16         = 0x04
)

Sparse Volume binary encoding payload descriptors.

View Source
const ChunkPoint2dSize = 8
View Source
const ChunkPoint3dSize = 12
View Source
const CoordinateBits = 32
View Source
const DataShapeBytes = 7
View Source
const DefaultJPEGQuality = 80

DefaultJPEGQuality is the quality of images returned if requesting JPEG images and an explicit Quality amount is omitted.

View Source
const IndexZYXSize = ChunkPoint3dSize
View Source
const (
	MaxNumberConcurrentCgo = 10000
)

Variables

View Source
var (
	MaxChunkPoint2d = ChunkPoint2d{math.MaxInt32, math.MaxInt32}
	MinChunkPoint2d = ChunkPoint2d{math.MinInt32, math.MinInt32}
)
View Source
var (
	// XY describes a 2d rectangle of voxels that share a z-coord.
	XY = DataShape{3, []uint8{0, 1}}

	// XZ describes a 2d rectangle of voxels that share a y-coord.
	XZ = DataShape{3, []uint8{0, 2}}

	// YZ describes a 2d rectangle of voxels that share a x-coord.
	YZ = DataShape{3, []uint8{1, 2}}

	// Arb describes a 2d rectangle of voxels with arbitrary 3d orientation.
	Arb = DataShape{/* contains filtered or unexported fields */}

	// Vol3d describes a 3d volume of voxels
	Vol3d = DataShape{3, []uint8{0, 1, 2}}
)
View Source
var (
	MaxIndexZYX = IndexZYX(MaxChunkPoint3d)
	MinIndexZYX = IndexZYX(MinChunkPoint3d)
)
View Source
var (
	// NumCPU is the number of cores available to this DVID server.
	NumCPU int

	// Mode is a global variable set to the run modes of this DVID process.
	Mode ModeFlag
)
View Source
var (
	Font *truetype.Font
)

Functions

func BlockOnActiveCgo

func BlockOnActiveCgo()

BlockOnActiveCgo will block until all active cgo routines have been finished or queued for starting. This requires cgo routines to be bracketed by:

dvid.StartCgo()
/* Some cgo code */
dvid.StopCgo()

func DataFromPost

func DataFromPost(r *http.Request, key string) ([]byte, error)

DataFromPost returns data submitted in the given key of a POST request.

func DataTypeBytes

func DataTypeBytes(t DataType) int32

DataTypeBytes returns the # of bytes for a given type string. For example, "uint16" is 2 bytes. No error checking is performed to make sure string is valid.

func DecodeSerializationFormat

func DecodeSerializationFormat(s SerializationFormat) (CompressionFormat, Checksum)

func Deserialize

func Deserialize(s []byte, object interface{}) error

Deserializes a Go object using Gob encoding

func ElapsedTime

func ElapsedTime(mode ModeFlag, startTime time.Time, p ...interface{})

ElapsedTime prints the time elapsed from the start time with Printf arguments afterwards. Example: ElapsedTime(dvid.Debug, startTime, "Time since launch of %s", funcName)

func EmptyValue

func EmptyValue() []byte

func Error

func Error(p ...interface{})

Error prints a message to the Error Log File, which is useful to mark potential issues but not ones that should crash the DVID server. Basically, you should opt to crash the server if a mistake can propagate and corrupt data. If not, you can use this function. Note that Error logging to a file only occurs if DVID is running as a server, otherwise this function will print to stdout.

func EstimateGoroutines

func EstimateGoroutines(percentCPUs float64, goroutineMB int32) int

EstimateGoroutines returns the # of goroutines that can be launched given a percentage (up to 1.0) of available CPUs (set by command line option or # cores) and/or the megabytes (MB) of memory needed for each goroutine. A minimum of 1 goroutine is returned. TODO: Actually use the required memory provided in argument. For now,

only returns percentage of maximum # of cores.

func Fmt

func Fmt(mode ModeFlag, p ...interface{})

Fmt prints a message via fmt.Print() depending on the Mode of DVID.

func GetNumBlocks

func GetNumBlocks(geom Geometry, blockSize Point) int

GetNumBlocks returns the number of n-d blocks necessary to cover the given geometry.

func ImageData

func ImageData(img image.Image) (data []uint8, bytesPerPixel, stride int32, err error)

ImageData returns the underlying pixel data for an image or an error if the image doesn't have the requisite []uint8 pixel data.

func ImageFromFile

func ImageFromFile(filename string) (img image.Image, format string, err error)

ImageFromFile returns an image and its format name given a file name.

func ImageFromForm

func ImageFromForm(r *http.Request, key string) (img image.Image, format string, err error)

ImageFromForm returns an image and its format name given a key to a POST request. The image should be the first file in a POSTed form.

func ImageFromPOST

func ImageFromPOST(r *http.Request) (img image.Image, format string, err error)

ImageFromPOST returns an image and its format name given a POST request.

func ImageGrayFromData

func ImageGrayFromData(data []uint8, nx, ny int) (img *image.Gray)

ImageGrayFromData returns a Gray image given data and image size.

func ListDataShapes

func ListDataShapes() (shapes []string)

ListDataShapes returns a slice of shape names

func Log

func Log(mode ModeFlag, p ...interface{})

Log prints a message via log.Print() depending on the Mode of DVID.

func PlaceholderImage

func PlaceholderImage(shape DataShape, imageSize Point, message string) (image.Image, error)

PlaceholderImage returns an solid image with a message and text describing the shape.

func PrintNonZero

func PrintNonZero(message string, value []byte)

PrintNonZero prints the number of non-zero bytes in a slice of bytes.

func ReadJSONFile

func ReadJSONFile(filename string) (value map[string]interface{}, err error)

ReadJSONFile returns a map[string]interface{} with decoded JSON from a file. If a file is not organized as a JSON object, an error will be returned.

func SendHTTP

func SendHTTP(w http.ResponseWriter, r *http.Request, name string, data []byte)

SendHTTP sends data after setting an appropriate Content-Type by examining the name and also some byte sniffing.

func Serialize

func Serialize(object interface{}, compress Compression, checksum Checksum) ([]byte, error)

Serializes an arbitrary Go object using Gob encoding and optional compression, checksum. If your object is []byte, you should preferentially use SerializeData since the Gob encoding process adds some overhead in performance as well as size of wire format to describe the transmitted types.

func SerializeData

func SerializeData(data []byte, compress Compression, checksum Checksum) ([]byte, error)

Serialize a slice of bytes using optional compression, checksum. Checksum will be ignored if the underlying compression already employs checksums, e.g., Gzip.

func SetErrorLoggingFile

func SetErrorLoggingFile(out io.Writer)

SetErrorLoggingFile creates an error logger to the given file for this DVID process.

func StartCgo

func StartCgo()

StartCgo is used to mark the beginning of a cgo routine and blocks if we have requested a BlockOnActiveCgo(). This is used for graceful shutdowns and monitoring.

func StopCgo

func StopCgo()

func SupportsGzipEncoding

func SupportsGzipEncoding(r *http.Request) bool

SupportsGzipEncoding returns true if the http requestor can accept gzip encoding.

func UnblockCgo

func UnblockCgo()

UnblockCgo allows cgo routines to start if they have been previously blocked using a BlockOnActiveCgo() call.

func WaitToComplete

func WaitToComplete(wg *sync.WaitGroup, mode ModeFlag, startTime time.Time, p ...interface{})

Wait for WaitGroup then print message including time for operation. The last arguments are fmt.Printf arguments and should not include the newline since one is added in this function.

func WriteGzip

func WriteGzip(gzipData []byte, w http.ResponseWriter, r *http.Request) error

WriteGzip will write already gzip-encoded data to the ResponseWriter unless the requestor cannot support it. In that case, the gzip data is uncompressed and sent uncompressed.

func WriteImageHttp

func WriteImageHttp(w http.ResponseWriter, img image.Image, formatStr string) error

WriteImageHttp writes an image to a HTTP response writer using a format and optional compression strength specified in a string, e.g., "png", "jpg:80".

func WriteJSONFile

func WriteJSONFile(filename string, value interface{}) error

WriteJSONFile writes an arbitrary but exportable Go object to a JSON file.

Types

type BinaryVolume

type BinaryVolume struct {
	// contains filtered or unexported fields
}

BinaryVolume holds 3d binary data including a 3d offset.

func NewBinaryVolume

func NewBinaryVolume(offset, size Point3d, res NdFloat32) *BinaryVolume

NewBinaryVolume returns a BinaryVolume with an allocated 3d volume for data.

func (*BinaryVolume) CheckSurface

func (binvol *BinaryVolume) CheckSurface(x, y, z int32) (normx, normy, normz float32, isSurface bool)

CheckSurface checks to see if the given voxel within the BinaryVolume is set, and if so, calculates a normal based on a Zucker-Hummel 3x3x3 convolution.

func (*BinaryVolume) ShiftUp

func (binvol *BinaryVolume) ShiftUp(dz int32)

Shift the buffer up by dz voxels.

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

Bool is a concurrency-safe bool.

func (*Bool) SetFalse

func (b *Bool) SetFalse()

func (*Bool) SetTrue

func (b *Bool) SetTrue()

func (*Bool) Value

func (b *Bool) Value() bool

type Checksum

type Checksum uint8

Checksum is the type of checksum employed for error checking stored data. NOTE: Should be no more than 4 (2 bits) of checksum types.

const (
	NoChecksum Checksum = 0
	CRC32               = 1 << (iota - 1)
)
var DefaultChecksum Checksum = NoChecksum

DefaultChecksum is the type of checksum employed for all data operations. Note that many database engines already implement some form of corruption test and checksum can be set on each datatype instance.

func (Checksum) String

func (checksum Checksum) String() string

type ChunkIndexer

type ChunkIndexer interface {
	Index

	ChunkPoint

	// Min returns a ChunkIndexer that is the minimum of its value and the passed one.
	Min(ChunkIndexer) (min ChunkIndexer, changed bool)

	// Max returns a ChunkIndexer that is the maximum of its value and the passed one.
	Max(ChunkIndexer) (max ChunkIndexer, changed bool)
}

ChunkIndexer adds chunk point access to an index.

type ChunkPoint

type ChunkPoint interface {
	SimplePoint

	// MinPoint returns the minimum point within a chunk and first in an iteration.
	MinPoint(size Point) Point

	// MaxPoint returns the maximum point within a chunk and last in an iteration.
	MaxPoint(size Point) Point
}

ChunkPoint describes a particular chunk in chunk space.

type ChunkPoint2d

type ChunkPoint2d [2]int32

ChunkPoint2d handles 2d signed chunk coordinates.

func (ChunkPoint2d) MaxPoint

func (c ChunkPoint2d) MaxPoint(size Point) Point

MaxPoint returns the maximum voxel coordinate of the given 2d chunk.

func (ChunkPoint2d) MinPoint

func (c ChunkPoint2d) MinPoint(size Point) Point

MinPoint returns the smallest voxel coordinate of the given 2d chunk.

func (ChunkPoint2d) NumDims

func (c ChunkPoint2d) NumDims() uint8

func (ChunkPoint2d) String

func (c ChunkPoint2d) String() string

func (ChunkPoint2d) Value

func (c ChunkPoint2d) Value(dim uint8) int32

Value returns the value at the specified dimension.

type ChunkPoint3d

type ChunkPoint3d [3]int32

ChunkPoint3d handles 3d signed chunk coordinates.

func (ChunkPoint3d) MaxPoint

func (c ChunkPoint3d) MaxPoint(size Point) Point

MaxPoint returns the maximum voxel coordinate of the given 3d chunk.

func (ChunkPoint3d) MinPoint

func (c ChunkPoint3d) MinPoint(size Point) Point

MinPoint returns the smallest voxel coordinate of the given 3d chunk.

func (ChunkPoint3d) NumDims

func (c ChunkPoint3d) NumDims() uint8

func (*ChunkPoint3d) SetMaximum

func (p *ChunkPoint3d) SetMaximum(p2 ChunkPoint3d)

SetMaximum sets the point to the maximum elements of current and passed points.

func (*ChunkPoint3d) SetMinimum

func (p *ChunkPoint3d) SetMinimum(p2 ChunkPoint3d)

SetMinimum sets the point to the minimum elements of current and passed points.

func (ChunkPoint3d) String

func (c ChunkPoint3d) String() string

func (ChunkPoint3d) Value

func (c ChunkPoint3d) Value(dim uint8) int32

Value returns the value at the specified dimension.

type ChunkPointNd

type ChunkPointNd []int32

ChunkPointNd handles N-dimensional signed chunk coordinates.

func (ChunkPointNd) MaxPoint

func (c ChunkPointNd) MaxPoint(size Point) Point

MaxPoint returns the maximum voxel coordinate of the given 3d chunk.

func (ChunkPointNd) MinPoint

func (c ChunkPointNd) MinPoint(size Point) Point

MinPoint returns the smallest voxel coordinate of the given 3d chunk.

func (ChunkPointNd) NumDims

func (c ChunkPointNd) NumDims() uint8

func (ChunkPointNd) String

func (c ChunkPointNd) String() string

func (ChunkPointNd) Value

func (c ChunkPointNd) Value(dim uint8) int32

Value returns the value at the specified dimension.

type Chunkable

type Chunkable interface {
	// Chunk returns a point in chunk space, the partition in which the given point falls.
	// For example, a chunk could be a tile (or a subvolume/block) and this returns the
	// tile's coordinate in tile space.
	Chunk(size Point) ChunkPoint

	// PointInChunk returns a point in a particular chunk's space.  For example, if a chunk
	// is a block of voxels, then the returned point is in that block coordinate space with
	// the first voxel in the block as the origin or zero point.
	PointInChunk(size Point) Point
}

Chunkable is an interface for n-dimensional points that can be partitioned into chunks.

type Command

type Command []string

Command supports command-line interaction with DVID. The first item in the string slice is the command, which may be "help" or the name of DVID data name ("grayscale8"). If the first item is the name of a data type, the second item will have a type-specific command like "get". The other arguments are command arguments or optional settings of the form "<key>=<value>".

func (Command) Argument

func (cmd Command) Argument(pos int) string

Returns the argument at the given position using zero indexing. Settings are not considered arguments. If no argument is at the given position, this returns the empty string.

func (Command) CommandArgs

func (cmd Command) CommandArgs(startPos int, targets ...*string) []string

CommandArgs sets a variadic argument set of string pointers to data command arguments, ignoring setting arguments of the form "<key>=<value>". If there aren't enough arguments to set a target, the target is set to the empty string. It returns an 'overflow' slice that has all arguments beyond those needed for targets.

Example: Given the command string "add param1 param2 42 data/*.png"

var s1, s2, s3, s4 string
filenames := CommandArgs(0, &s1, &s2, &s3, &s4)
fmt.Println(filenames)
fmt.Println(s1)
fmt.Println(s2, s3)
fmt.Println(s4)

Would print out:
   ["data/foo-1.png", "data/foo-2.png", "data/foo-3.png"]
   add
   param1 param2
   42

func (Command) FilenameArgs

func (cmd Command) FilenameArgs(startPos int, targets ...*string) (filenames []string, err error)

FilenameArgs is similar to CommandArgs except it can take filename glob patterns at the end of the string, and will find matches and return those.

func (Command) Name

func (cmd Command) Name() string

Name returns the first argument of the command (in lower case) which is assumed to be the name of the command.

func (Command) Setting

func (cmd Command) Setting(key string) (value string, found bool)

Setting scans a command for any "key=value" argument and returns the value of the passed 'key'. Key is case sensitive for this function.

func (Command) Settings

func (cmd Command) Settings() Config

Settings scans a command for any "key=value" argument and returns a Config, which is a map of key/value data. All keys are converted to lower case for case-insensitive matching.

func (Command) String

func (cmd Command) String() string

String returns a space-separated command line

func (Command) TypeCommand

func (cmd Command) TypeCommand() string

TypeCommand returns the name of a type-specific command (in lower case).

type Compression

type Compression struct {
	// contains filtered or unexported fields
}

Compression is the format of compression for storing data. NOTE: Should be no more than 8 (3 bits) compression types.

func NewCompression

func NewCompression(format CompressionFormat, level CompressionLevel) (Compression, error)

NewCompression returns a Compression struct that maps compression-specific details to a DVID-wide compression.

func (Compression) Format

func (c Compression) Format() CompressionFormat

func (Compression) Level

func (c Compression) Level() CompressionLevel

func (Compression) MarshalBinary

func (c Compression) MarshalBinary() ([]byte, error)

MarshalBinary fulfills the encoding.BinaryMarshaler interface.

func (Compression) MarshalJSON

func (c Compression) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Compression) String

func (c Compression) String() string

func (*Compression) UnmarshalBinary

func (c *Compression) UnmarshalBinary(data []byte) error

UnmarshalBinary fulfills the encoding.BinaryUnmarshaler interface.

func (*Compression) UnmarshalJSON

func (c *Compression) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type CompressionFormat

type CompressionFormat uint8

CompressionFormat specifies the compression algorithm.

func DeserializeData

func DeserializeData(s []byte, uncompress bool) ([]byte, CompressionFormat, error)

DeserializeData deserializes a slice of bytes using stored compression, checksum. If uncompress parameter is false, the data is not uncompressed.

func (CompressionFormat) String

func (format CompressionFormat) String() string

type CompressionLevel

type CompressionLevel int8

CompressionLevel goes from 1 (fastest) to 9 (highest compression) as in deflate. Default compression is -1 so need signed int8.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is a map of keyword to arbitrary data to specify configurations via keyword. Keywords are case-insensitive.

func NewConfig

func NewConfig() Config

func (Config) GetBool

func (c Config) GetBool(key string) (value, found bool, err error)

GetBool returns a bool value of the given key. If setting of key is not parseable as a bool ("false", "true", "0", or "1"), returns an error. If the key is not found, it will also return a false bool (the Go zero value for bool).

func (Config) GetInt

func (c Config) GetInt(key string) (i int, found bool, err error)

GetInt returns an int value of the given key. If setting of key is not parseable as an int, returns an error.

func (Config) GetShapes

func (c Config) GetShapes(key, separator string) ([]DataShape, error)

GetShapes returns DataShapes from a string where each shape specification is delimited by a separator. If the key is not found, nil is returned.

func (Config) GetString

func (c Config) GetString(key string) (s string, found bool, err error)

GetString returns a string value of the given key. If setting of key is not a string, returns an error.

func (Config) IsVersioned

func (c Config) IsVersioned() (versioned bool, err error)

IsVersioned returns true if we want this data versioned.

func (*Config) Set

func (c *Config) Set(key, value string)

func (*Config) SetByJSON

func (c *Config) SetByJSON(jsonData io.Reader) error

Sets a configuration using valid JSON. Since Config is case-insensitive, JSON object names are converted to lower case.

func (*Config) SetVersioned

func (c *Config) SetVersioned(versioned bool)

type DataLocalID

type DataLocalID LocalID

DataLocalID is a DVID server-specific ID that is more compact than a (UUID, Data URL).

type DataShape

type DataShape struct {
	// contains filtered or unexported fields
}

DataShape describes the number of dimensions and the ordering of the dimensions.

func BytesToDataShape

func BytesToDataShape(b []byte) (s DataShape, err error)

BytesToDataShape recovers a DataShape from a series of bytes.

func (DataShape) AxisName

func (s DataShape) AxisName(axis uint8) string

AxisName returns common axis descriptions like X, Y, and Z for a shapes dimensions.

func (DataShape) Bytes

func (s DataShape) Bytes() []byte

Bytes returns a fixed length byte representation that can be used for keys. Up to 5-d shapes can be used.

func (DataShape) ChunkPoint3d

func (s DataShape) ChunkPoint3d(p, size Point) (ChunkPoint3d, error)

ChunkPoint3d returns a chunk point where the XY is determined by the type of slice orientation of the DataShape, and the Z is the non-chunked coordinate. This is useful for tile generation where you have 2d tiles in a 3d space.

func (DataShape) Duplicate

func (s DataShape) Duplicate() DataShape

Duplicate returns a duplicate of the DataShape.

func (DataShape) Equals

func (s DataShape) Equals(s2 DataShape) bool

Equals returns true if the passed DataShape is identical.

func (DataShape) GetFloat2D

func (s DataShape) GetFloat2D(fslice NdFloat32) (x, y float32, err error)

GetFloat2D returns elements of a N-d float array given a 2d shape.

func (DataShape) GetSize2D

func (s DataShape) GetSize2D(size SimplePoint) (width, height int32, err error)

GetSize2D returns the width and height of a 2D shape given a n-D size.

func (DataShape) PlaneToChunkPoint3d

func (s DataShape) PlaneToChunkPoint3d(x, y int32, offset, size Point) (ChunkPoint3d, error)

PlaneToChunkPoint3d returns a chunk point corresponding to the given point on the DataShape's plane. If DataShape is not a plane, returns an error.

func (DataShape) ShapeDimension

func (s DataShape) ShapeDimension(axis uint8) (uint8, error)

ShapeDimension returns the axis number for a shape dimension.

func (DataShape) ShapeDimensions

func (s DataShape) ShapeDimensions() int8

ShapeDimensions returns the number of dimensions for this shape.

func (DataShape) String

func (s DataShape) String() string

func (DataShape) TotalDimensions

func (s DataShape) TotalDimensions() int8

TotalDimensions returns the full dimensionality of space within which there is this DataShape.

type DataShapeString

type DataShapeString string

String for specifying a slice orientation or subvolume

func (DataShapeString) DataShape

func (s DataShapeString) DataShape() (shape DataShape, err error)

DataShape returns the data shape constant associated with the string.

type DataShapes

type DataShapes []DataShape

DataShapes are a slice of DataShape.

type DataString

type DataString string

DataString is a string that is the name of DVID data.

type DataType

type DataType uint8

DataType is a unique ID for each type of data within DVID, e.g., a uint8 or a float32.

const (
	T_uint8 DataType = iota
	T_int8
	T_uint16
	T_int16
	T_uint32
	T_int32
	T_uint64
	T_int64
	T_float32
	T_float64
)

type DataValue

type DataValue struct {
	T     DataType
	Label string
}

DataValue describes the data type and label for each value within an element. Terminology: An "element" is some grouping, e.g., data associated with a voxel. A "value" is one component of the data for an element, or said another way, an element can have many values that may be of differing type and size.

func (DataValue) MarshalJSON

func (dv DataValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*DataValue) UnmarshalJSON

func (dv *DataValue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (DataValue) ValueBytes

func (dv DataValue) ValueBytes() int32

ValueBytes returns the number of bytes for this value

type DataValues

type DataValues []DataValue

DataValues describes the interleaved values within an element.

func (DataValues) AverageData

func (values DataValues) AverageData(src, dst []byte, srcW, dstW, dstH, reduceW, reduceH int32)

AverageData averages the source slice of data and stores the result in the dst slice.

func (DataValues) BytesPerElement

func (values DataValues) BytesPerElement() int32

func (DataValues) BytesPerValue

func (values DataValues) BytesPerValue() (int32, error)

BytesPerValue returns the # bytes for each value of an element if all values have equal size. An error is returned if values are varying sizes for an element. Use ValueBytes(dim) to get bytes/value for elements with varying # of bytes per value.

func (DataValues) MarshalBinary

func (values DataValues) MarshalBinary() ([]byte, error)

MarshalBinary fulfills the encoding.BinaryMarshaler interface.

func (*DataValues) UnmarshalBinary

func (values *DataValues) UnmarshalBinary(b []byte) error

UnmarshalBinary fulfills the encoding.BinaryUnmarshaler interface.

func (DataValues) ValueBytes

func (values DataValues) ValueBytes(n int) int32

ValueBytes returnes the size of the nth value in an element.

func (DataValues) ValueDataType

func (values DataValues) ValueDataType() (DataType, error)

ValueDataType returns the dvid.DataType used for all values in an element. If the data types vary, e.g., an int32 then a float32, this function will return an error.

func (DataValues) ValuesPerElement

func (values DataValues) ValuesPerElement() int32

type DatasetLocalID

type DatasetLocalID LocalID32

DatasetLocalID is a DVID server-specific ID that is more compact than a UUID.

type Dimension

type Dimension struct {
	Name  string
	Units string
	// contains filtered or unexported fields
}

type Filename

type Filename string

Filename has a base name + extension.

func (Filename) HasExtensionPrefix

func (fname Filename) HasExtensionPrefix(exts ...string) bool

HasExtensionPrefix returns true if the given string forms a prefix for the filename's extension.

type Geometry

type Geometry interface {
	// DataShape describes the shape of the data.
	DataShape() DataShape

	// Size returns the extent in each dimension.
	Size() Point

	// NumVoxels returns the number of voxels within this space.
	NumVoxels() int64

	// StartPoint returns the offset to first point of data.
	StartPoint() Point

	// EndPoint returns the last point.
	EndPoint() Point

	String() string
}

Geometry describes the shape, size, and position of data in the DVID volume.

func NewOrthogSlice

func NewOrthogSlice(s DataShape, offset Point, size Point2d) (Geometry, error)

NewOrthogSlice returns an OrthogSlice of chosen orientation, offset, and size.

func NewSliceFromStrings

func NewSliceFromStrings(str DataShapeString, offsetStr, sizeStr, sep string) (Geometry, error)

NewSliceFromStrings returns a Geometry object for a XY, XZ, or YZ slice given a data shape string, offset ("0,10,20"), and size ("250,250").

type Image

type Image struct {
	DataFormat   DataValues
	Interpolable bool

	Which   uint8
	Gray    *image.Gray
	Gray16  *image.Gray16
	NRGBA   *image.NRGBA
	NRGBA64 *image.NRGBA64
}

Image contains a standard Go image as well as a data format description so non-standard image values like uint64 labels or uint32 intensities can be handled. A DVID image also knows whether it should be interpolated on resizing or must keep pixel values without interpolation, e.g., when using labels. Better Gob serialization is handled by a union of possible image types compared to a generic image.Image interface: see https://groups.google.com/d/msg/golang-dev/_t4pqoeuflE/DbqSf41wr5EJ

func (*Image) Data

func (img *Image) Data() []uint8

Data returns a slice of bytes corresponding to the image pixels.

func (*Image) Deserialize

func (img *Image) Deserialize(b []byte) error

Deserialze deserializes an Image from a possibly compressioned, checksummed byte slice.

func (Image) Get

func (img Image) Get() image.Image

Get returns an image.Image from the union struct.

func (Image) GetDrawable

func (img Image) GetDrawable() draw.Image

Get returns an image.Image from the union struct.

func (Image) GetJPEG

func (img Image) GetJPEG(quality int) ([]byte, error)

GetJPEG returns bytes in JPEG format where quality is 1-100, higher is better, and quality 0 is default (50)

func (Image) GetPNG

func (img Image) GetPNG() ([]byte, error)

GetPNG returns bytes in PNG format.

func (*Image) InterpolateImage

func (img *Image) InterpolateImage(dstW, dstH int) (image.Image, error)

InterpolateImage returns an image scaled to the given geometry using simple nearest-neighbor interpolation.

func (*Image) MarshalBinary

func (img *Image) MarshalBinary() ([]byte, error)

MarshalBinary fulfills the encoding.BinaryMarshaler interface.

func (*Image) ResizeImage

func (img *Image) ResizeImage(dstW, dstH int) (image.Image, error)

ResizeImage returns an image scaled to the given geometry without doing interpolation.

func (*Image) ScaleImage

func (img *Image) ScaleImage(dstW, dstH int) (*Image, error)

ScaleImage scales a DVID image to the destination geometry size, using nearest-neighbor or interpolation depending on the type of data.

func (*Image) Serialize

func (img *Image) Serialize(compress Compression, checksum Checksum) ([]byte, error)

Serialize writes optional compressed and checksummed bytes representing image data.

func (*Image) Set

func (img *Image) Set(src image.Image, format DataValues, interpolable bool) error

Set initializes a DVID image from a go image and a data format specification. DVID images must have identical data type values within a pixel..

func (*Image) SubImage

func (img *Image) SubImage(r image.Rectangle) (*Image, error)

SubImage returns an image representing the portion of the image p visible through r. The returned image shares pixels with the original image.

func (*Image) UnmarshalBinary

func (img *Image) UnmarshalBinary(b []byte) error

UnmarshalBinary fulfills the encoding.BinaryUnmarshaler interface.

type Index

type Index interface {
	// Duplicate returns a duplicate Index
	Duplicate() Index

	// Bytes returns a byte representation of the Index.  Integer components of
	// the Index should probably be serialized in big endian for improved
	// lexicographic ordering.
	Bytes() []byte

	// BytesToIndex returns an Index from a byte representation
	IndexFromBytes(b []byte) (Index, error)

	// Hash provides a consistent mapping from an Index to an integer (0,n]
	Hash(n int) int

	// Scheme returns a string describing the indexing scheme.
	Scheme() string

	// String returns a hexadecimal string representation
	String() string
}

Index is a one-dimensional index, typically constructed using a space-filling curve that serves as a spatiotemporal indexing scheme. For example, Z-curves map n-D space to a 1-D index.

type IndexBytes

type IndexBytes []byte

IndexBytes satisfies an Index interface with a slice of bytes.

func (IndexBytes) Bytes

func (i IndexBytes) Bytes() []byte

func (IndexBytes) Duplicate

func (i IndexBytes) Duplicate() Index

func (IndexBytes) Hash

func (i IndexBytes) Hash(n int) int

func (IndexBytes) IndexFromBytes

func (i IndexBytes) IndexFromBytes(b []byte) (Index, error)

func (IndexBytes) Scheme

func (i IndexBytes) Scheme() string

func (IndexBytes) String

func (i IndexBytes) String() string

type IndexCZYX

type IndexCZYX struct {
	Channel int32
	IndexZYX
}

IndexCZYX implements the Index interface and provides simple indexing on "channel" C, then Z, then Y, then X. Since IndexZYX is embedded, we get ChunkIndexer interface.

func (IndexCZYX) Bytes

func (i IndexCZYX) Bytes() []byte

Bytes returns a byte representation of the Index.

func (IndexCZYX) Duplicate

func (i IndexCZYX) Duplicate() Index

func (IndexCZYX) IndexFromBytes

func (i IndexCZYX) IndexFromBytes(b []byte) (Index, error)

IndexFromBytes returns an index from bytes. The passed Index is used just to choose the appropriate byte decoding scheme.

func (IndexCZYX) Scheme

func (i IndexCZYX) Scheme() string

func (IndexCZYX) String

func (i IndexCZYX) String() string

type IndexCZYXIterator

type IndexCZYXIterator struct {
	// contains filtered or unexported fields
}

----- IndexIterator implementation ------------

func NewIndexCZYXIterator

func NewIndexCZYXIterator(channel int32, start, end ChunkPoint3d) *IndexCZYXIterator

NewIndexCZYXIterator returns an IndexIterator that iterates over XYZ space for a C.

func (*IndexCZYXIterator) IndexSpan

func (it *IndexCZYXIterator) IndexSpan() (beg, end Index, err error)

func (*IndexCZYXIterator) NextSpan

func (it *IndexCZYXIterator) NextSpan()

func (*IndexCZYXIterator) Valid

func (it *IndexCZYXIterator) Valid() bool

type IndexHilbert

type IndexHilbert []byte

TODO -- Hilbert curve

func (IndexHilbert) Scheme

func (i IndexHilbert) Scheme() string

type IndexIterator

type IndexIterator interface {
	Valid() bool
	IndexSpan() (beg, end Index, err error)
	NextSpan()
}

IndexIterator is a function that returns a sequence of indices and ends with nil.

type IndexMorton

type IndexMorton []byte

TODO -- Morton (Z-order) curve

func (IndexMorton) Scheme

func (i IndexMorton) Scheme() string

type IndexRange

type IndexRange struct {
	Minimum, Maximum Index
}

IndexRange defines the extent of data via minimum and maximum indices.

type IndexString

type IndexString string

IndexString satisfies an Index interface with a string.

func (IndexString) Bytes

func (i IndexString) Bytes() []byte

func (IndexString) Duplicate

func (i IndexString) Duplicate() Index

func (IndexString) Hash

func (i IndexString) Hash(n int) int

func (IndexString) IndexFromBytes

func (i IndexString) IndexFromBytes(b []byte) (Index, error)

func (IndexString) Scheme

func (i IndexString) Scheme() string

func (IndexString) String

func (i IndexString) String() string

type IndexUint8

type IndexUint8 uint8

IndexUint8 satisfies an Index interface with an 8-bit unsigned integer index.

func (IndexUint8) Bytes

func (i IndexUint8) Bytes() []byte

Bytes returns a byte representation of the Index.

func (IndexUint8) Duplicate

func (i IndexUint8) Duplicate() Index

func (IndexUint8) Hash

func (i IndexUint8) Hash(n int) int

Hash returns an integer [0, n)

func (IndexUint8) IndexFromBytes

func (i IndexUint8) IndexFromBytes(b []byte) (Index, error)

IndexFromBytes returns an index from bytes. The passed Index is used just to choose the appropriate byte decoding scheme.

func (IndexUint8) Scheme

func (i IndexUint8) Scheme() string

func (IndexUint8) String

func (i IndexUint8) String() string

type IndexZYX

type IndexZYX ChunkPoint3d

IndexZYX implements the Index interface and provides simple indexing on Z, then Y, then X. Note that index elements are unsigned to better handle sequential access of negative/positive coordinates. The binary representation of an index must behave reasonably for both negative and positive coordinates, e.g., when moving from -1 to 0 the binary representation isn't discontinous so the lexicographical ordering switches. The simplest way to achieve this is to convert to an unsigned (positive) integer space where all coordinates are greater or equal to (0,0,...).

func (IndexZYX) Bytes

func (i IndexZYX) Bytes() []byte

Bytes returns a byte representation of the Index. This should layout integer space as consecutive in binary representation so we use bigendian and convert signed integer space to unsigned integer space.

func (IndexZYX) Duplicate

func (i IndexZYX) Duplicate() Index

func (IndexZYX) Hash

func (i IndexZYX) Hash(n int) int

Hash returns an integer [0, n) where the returned values should be reasonably spread among the range of returned values. This implementation makes sure that any range query along x, y, or z direction will map to different handlers.

func (IndexZYX) IndexFromBytes

func (i IndexZYX) IndexFromBytes(b []byte) (Index, error)

IndexFromBytes returns an index from bytes. The passed Index is used just to choose the appropriate byte decoding scheme.

func (IndexZYX) Max

func (i IndexZYX) Max(idx ChunkIndexer) (ChunkIndexer, bool)

Max returns a ChunkIndexer that is the maximum of its value and the passed one.

func (IndexZYX) MaxPoint

func (i IndexZYX) MaxPoint(size Point) Point

MaxPoint returns the maximum voxel coordinate for a chunk.

func (IndexZYX) Min

func (i IndexZYX) Min(idx ChunkIndexer) (ChunkIndexer, bool)

Min returns a ChunkIndexer that is the minimum of its value and the passed one.

func (IndexZYX) MinPoint

func (i IndexZYX) MinPoint(size Point) Point

MinPoint returns the minimum voxel coordinate for a chunk.

func (IndexZYX) NumDims

func (i IndexZYX) NumDims() uint8

func (IndexZYX) Scheme

func (i IndexZYX) Scheme() string

func (IndexZYX) String

func (i IndexZYX) String() string

func (IndexZYX) Value

func (i IndexZYX) Value(dim uint8) int32

Value returns the value at the specified dimension for this index.

type IndexZYXIterator

type IndexZYXIterator struct {
	// contains filtered or unexported fields
}

----- IndexIterator implementation ------------

func NewIndexZYXIterator

func NewIndexZYXIterator(start, end ChunkPoint3d) *IndexZYXIterator

NewIndexZYXIterator returns an IndexIterator that iterates over XYZ space.

func (*IndexZYXIterator) IndexSpan

func (it *IndexZYXIterator) IndexSpan() (beg, end Index, err error)

func (*IndexZYXIterator) NextSpan

func (it *IndexZYXIterator) NextSpan()

func (*IndexZYXIterator) Valid

func (it *IndexZYXIterator) Valid() bool

type LocalID

type LocalID uint16

LocalID is a unique id for some data in a DVID instance. This unique id is a much smaller representation than the actual data (e.g., a version UUID or data type url) and can be represented with fewer bytes in keys.

func LocalIDFromBytes

func LocalIDFromBytes(b []byte) (id LocalID, length int)

LocalIDFromBytes returns a LocalID from the start of the slice and the number of bytes used. Note: No error checking is done to ensure byte slice has sufficient bytes for LocalID.

func (LocalID) Bytes

func (id LocalID) Bytes() []byte

Bytes returns a sequence of bytes encoding this LocalID.

type LocalID32

type LocalID32 uint32

LocalID32 is a 32-bit unique id within this DVID instance.

func LocalID32FromBytes

func LocalID32FromBytes(b []byte) (id LocalID32, length int)

LocalID32FromBytes returns a LocalID from the start of the slice and the number of bytes used. Note: No error checking is done to ensure byte slice has sufficient bytes for LocalID.

func (LocalID32) Bytes

func (id LocalID32) Bytes() []byte

Bytes returns a sequence of bytes encoding this LocalID32.

type ModeFlag

type ModeFlag uint
const (
	Normal ModeFlag = iota
	Debug
	Benchmark
)

type NdFloat32

type NdFloat32 []float32

NdFloat32 is an N-dimensional slice of float32

func StringToNdFloat32

func StringToNdFloat32(str, separator string) (nd NdFloat32, err error)

Parse a string of format "%f,%f,%f,..." into a slice of float32.

func (NdFloat32) GetMax

func (n NdFloat32) GetMax() float32

GetMax returns the maximum element of the N-dimensional float.

func (NdFloat32) GetMin

func (n NdFloat32) GetMin() float32

GetMin returns the minimum element of the N-dimensional float.

type NdString

type NdString []string

NdString is an N-dimensional slice of strings

func StringToNdString

func StringToNdString(str, separator string) (nd NdString, err error)

Parse a string of format "%f,%f,%f,..." into a slice of float32.

func (NdString) Point2d

func (n NdString) Point2d() (p Point2d, err error)

func (NdString) Point3d

func (n NdString) Point3d() (p Point3d, err error)

func (NdString) PointNd

func (n NdString) PointNd() (PointNd, error)

type OrthogSlice

type OrthogSlice struct {
	// contains filtered or unexported fields
}

OrthogSlice is a 2d rectangle orthogonal to two axis of the space that is slices. It fulfills a Geometry interface.

func (OrthogSlice) DataShape

func (s OrthogSlice) DataShape() DataShape

func (OrthogSlice) Duplicate

func (s OrthogSlice) Duplicate() OrthogSlice

func (OrthogSlice) EndPoint

func (s OrthogSlice) EndPoint() Point

func (OrthogSlice) NumVoxels

func (s OrthogSlice) NumVoxels() int64

func (*OrthogSlice) SetSize

func (s *OrthogSlice) SetSize(size Point2d)

func (OrthogSlice) Size

func (s OrthogSlice) Size() Point

func (OrthogSlice) StartPoint

func (s OrthogSlice) StartPoint() Point

func (OrthogSlice) String

func (s OrthogSlice) String() string

type Point

type Point interface {
	SimplePoint

	// CheckedValue returns the point's value for the specified dimension and checks dim bounds.
	CheckedValue(dim uint8) (int32, error)

	// Duplicate returns a copy of the point.
	Duplicate() Point

	// Modify returns a copy of the point with the given (dim, value) components modified.
	Modify(map[uint8]int32) Point

	// AddScalar adds a scalar value to this point.
	AddScalar(int32) Point

	// DivScalar divides this point by a scalar value.
	DivScalar(int32) Point

	// Add returns the addition of two points.
	Add(Point) Point

	// Sub returns the subtraction of the passed point from the receiver.
	Sub(Point) Point

	// Mod returns a point where each component is the receiver modulo the passed point's components.
	Mod(Point) Point

	// Div returns the division of the receiver by the passed point.
	Div(Point) Point

	// Mult returns the multiplication of the receiver by the passed point.
	Mult(Point) Point

	// Max returns a Point where each of its elements are the maximum of two points' elements.
	Max(Point) (Point, bool)

	// Min returns a Point where each of its elements are the minimum of two points' elements.
	Min(Point) (Point, bool)

	// Distance returns the integer distance (rounding down).
	Distance(Point) int32

	// Prod returns the product of the point elements.
	Prod() int64

	String() string
}

Point is an interface for n-dimensional points. Types that implement the interface can optimize for particular dimensionality.

func NewPoint

func NewPoint(values []int32) (Point, error)

NewPoint returns an appropriate Point implementation for the number of dimensions passed in.

func SliceToPoint

func SliceToPoint(coord []int32) (p Point, err error)

Convert a slice of int32 into an appropriate Point implementation.

func StringToPoint

func StringToPoint(str, separator string) (p Point, err error)

Parse a string of format "%d<sep>%d<sep>%d,..." into a Point

type Point2d

type Point2d [2]int32

Point2d is a 2d point.

func RectSize

func RectSize(rect image.Rectangle) (size Point2d)

RectSize returns the size of a rectangle as a Point2d.

func (Point2d) Add

func (p Point2d) Add(x Point) Point

Add returns the addition of two points.

func (Point2d) AddScalar

func (p Point2d) AddScalar(value int32) Point

AddScalar adds a scalar value to this point.

func (Point2d) CheckedValue

func (p Point2d) CheckedValue(dim uint8) (int32, error)

CheckedValue returns the point's value for the specified dimension and checks dim bounds.

func (Point2d) Chunk

func (p Point2d) Chunk(size Point) ChunkPoint

Chunk returns the chunk space coordinate of the chunk containing the point.

func (Point2d) Distance

func (p Point2d) Distance(x Point) int32

Distance returns the integer distance (rounding down).

func (Point2d) Div

func (p Point2d) Div(x Point) (result Point)

Div returns the division of the receiver by the passed point.

func (Point2d) DivScalar

func (p Point2d) DivScalar(value int32) Point

DivScalar divides this point by a scalar value.

func (Point2d) Duplicate

func (p Point2d) Duplicate() Point

Duplicate returns a copy of the point without any pointer references.

func (Point2d) Max

func (p Point2d) Max(x Point) (Point, bool)

Max returns a Point where each of its elements are the maximum of two points' elements.

func (Point2d) Min

func (p Point2d) Min(x Point) (Point, bool)

Min returns a Point where each of its elements are the minimum of two points' elements.

func (Point2d) Mod

func (p Point2d) Mod(x Point) (result Point)

Mod returns a point where each component is the receiver modulo the passed point's components.

func (Point2d) Modify

func (p Point2d) Modify(settings map[uint8]int32) Point

Modify returns a copy of the point with the given (dim, value) components modified.

func (Point2d) Mult

func (p Point2d) Mult(x Point) (result Point)

Mult returns the multiplication of the receiver by the passed point.

func (Point2d) NumDims

func (p Point2d) NumDims() uint8

NumDims returns the dimensionality of this point.

func (Point2d) PointInChunk

func (p Point2d) PointInChunk(size Point) Point

PointInChunk returns a point in containing block (chunk) space for the given point.

func (Point2d) Prod

func (p Point2d) Prod() int64

func (Point2d) String

func (pt Point2d) String() string

func (Point2d) Sub

func (p Point2d) Sub(x Point) Point

Sub returns the subtraction of the passed point from the receiver.

func (Point2d) Value

func (p Point2d) Value(dim uint8) int32

Value returns the point's value for the specified dimension without checking dim bounds.

type Point3d

type Point3d [3]int32

Point3d is an ordered list of three 32-bit signed integers that implements the Point interface.

func (Point3d) Add

func (p Point3d) Add(x Point) Point

Add returns the addition of two points.

func (Point3d) AddScalar

func (p Point3d) AddScalar(value int32) Point

AddScalar adds a scalar value to this point.

func (Point3d) Bytes

func (p Point3d) Bytes() []byte

Bytes returns a byte representation of the Point3d in little endian format.

func (Point3d) CheckedValue

func (p Point3d) CheckedValue(dim uint8) (int32, error)

CheckedValue returns the point's value for the specified dimension and checks dim bounds.

func (Point3d) Chunk

func (p Point3d) Chunk(size Point) ChunkPoint

Chunk returns the chunk space coordinate of the chunk containing the point.

func (Point3d) Distance

func (p Point3d) Distance(x Point) int32

Distance returns the integer distance (rounding down).

func (Point3d) Div

func (p Point3d) Div(x Point) (result Point)

Div returns the division of the receiver by the passed point.

func (Point3d) DivScalar

func (p Point3d) DivScalar(value int32) Point

DivScalar divides this point by a scalar value.

func (Point3d) Duplicate

func (p Point3d) Duplicate() Point

Duplicate returns a copy of the point without any pointer references.

func (Point3d) Max

func (p Point3d) Max(x Point) (Point, bool)

Max returns a Point where each of its elements are the maximum of two points' elements.

func (Point3d) Min

func (p Point3d) Min(x Point) (Point, bool)

Min returns a Point where each of its elements are the minimum of two points' elements.

func (Point3d) Mod

func (p Point3d) Mod(x Point) (result Point)

Mod returns a point where each component is the receiver modulo the passed point's components.

func (Point3d) Modify

func (p Point3d) Modify(settings map[uint8]int32) Point

Modify returns a copy of the point with the given (dim, value) components modified.

func (Point3d) Mult

func (p Point3d) Mult(x Point) (result Point)

Div returns the multiplication of the receiver by the passed point.

func (Point3d) NumDims

func (p Point3d) NumDims() uint8

NumDims returns the dimensionality of this point.

func (Point3d) PointFromBytes

func (p Point3d) PointFromBytes(b []byte) (readPt Point3d, err error)

PointFromBytes returns a Point3d from bytes. The passed point is used just to choose the appropriate byte decoding scheme.

func (Point3d) PointInChunk

func (p Point3d) PointInChunk(size Point) Point

PointInChunk returns a point in containing block (chunk) space for the given point.

func (Point3d) Prod

func (p Point3d) Prod() int64

func (*Point3d) SetMaximum

func (p *Point3d) SetMaximum(p2 Point3d)

SetMaximum sets the point to the maximum elements of current and passed points.

func (*Point3d) SetMinimum

func (p *Point3d) SetMinimum(p2 Point3d)

SetMinimum sets the point to the minimum elements of current and passed points.

func (Point3d) String

func (p Point3d) String() string

func (Point3d) Sub

func (p Point3d) Sub(x Point) Point

Sub returns the subtraction of the passed point from the receiver.

func (Point3d) Value

func (p Point3d) Value(dim uint8) int32

Value returns the point's value for the specified dimension without checking dim bounds.

type PointNd

type PointNd []int32

PointNd is a slice of N 32-bit signed integers that implements the Point interface.

func (PointNd) Add

func (p PointNd) Add(x Point) Point

Add returns the addition of two points.

func (PointNd) AddScalar

func (p PointNd) AddScalar(value int32) Point

AddScalar adds a scalar value to this point.

func (PointNd) CheckedValue

func (p PointNd) CheckedValue(dim uint8) (int32, error)

CheckedValue returns the point's value for the specified dimension and checks dim bounds.

func (PointNd) Chunk

func (p PointNd) Chunk(size Point) ChunkPoint

Chunk returns the chunk space coordinate of the chunk containing the point.

func (PointNd) Distance

func (p PointNd) Distance(x Point) int32

Distance returns the integer distance (rounding down).

func (PointNd) Div

func (p PointNd) Div(x Point) Point

Div returns the division of the receiver by the passed point.

func (PointNd) DivScalar

func (p PointNd) DivScalar(value int32) Point

DivScalar divides this point by a scalar value.

func (PointNd) Duplicate

func (p PointNd) Duplicate() Point

Duplicate returns a copy of the point without any pointer references.

func (PointNd) Max

func (p PointNd) Max(x Point) (Point, bool)

Max returns a Point where each of its elements are the maximum of two points' elements.

func (PointNd) Min

func (p PointNd) Min(x Point) (Point, bool)

Min returns a Point where each of its elements are the minimum of two points' elements.

func (PointNd) Mod

func (p PointNd) Mod(x Point) Point

Mod returns a point where each component is the receiver modulo the passed point's components.

func (PointNd) Modify

func (p PointNd) Modify(settings map[uint8]int32) Point

Modify returns a copy of the point with the given (dim, value) components modified.

func (PointNd) Mult

func (p PointNd) Mult(x Point) Point

Div returns the multiplication of the receiver by the passed point.

func (PointNd) NumDims

func (p PointNd) NumDims() uint8

NumDims returns the dimensionality of this point.

func (PointNd) PointInChunk

func (p PointNd) PointInChunk(size Point) Point

PointInChunk returns a point in containing block (chunk) space for the given point.

func (PointNd) Prod

func (p PointNd) Prod() int64

func (PointNd) String

func (p PointNd) String() string

func (PointNd) Sub

func (p PointNd) Sub(x Point) Point

Sub returns the subtraction of the passed point from the receiver.

func (PointNd) Value

func (p PointNd) Value(dim uint8) int32

Value returns the point's value for the specified dimension without checking dim bounds.

type RLE

type RLE struct {
	// contains filtered or unexported fields
}

RLE is a single run-length encoded span with a start coordinate and length along a coordinate (typically X).

func NewRLE

func NewRLE(start Point3d, length int32) RLE

type RLEs

type RLEs []RLE

RLEs are simply a slice of RLE.

func (RLEs) MarshalBinary

func (rles RLEs) MarshalBinary() ([]byte, error)

MarshalBinary fulfills the encoding.BinaryMarshaler interface.

func (RLEs) Stats

func (rles RLEs) Stats() (numVoxels, numRuns int32)

Stats returns the total number of voxels and runs.

func (*RLEs) UnmarshalBinary

func (rles *RLEs) UnmarshalBinary(b []byte) error

UnmarshalBinary fulfills the encoding.BinaryUnmarshaler interface.

type Response

type Response struct {
	ContentType string
	Text        string
	Status      string
}

Response provides a few string fields to pass information back from a remote operation.

type SerializationFormat

type SerializationFormat uint8

SerializationFormat combines both compression and checksum methods.

func EncodeSerializationFormat

func EncodeSerializationFormat(compress Compression, checksum Checksum) SerializationFormat

type SimplePoint

type SimplePoint interface {
	// NumDims returns the dimensionality of this point.
	NumDims() uint8

	// Value returns the point's value for the specified dimension without checking dim bounds.
	Value(dim uint8) int32
}

type SparseVol

type SparseVol struct {
	// contains filtered or unexported fields
}

SparseVol represents a collection of voxels that may be in an arbitrary shape and have a label. It is particularly good for storing sparse voxels that may traverse large amounts of space.

func (*SparseVol) AddRLEs

func (vol *SparseVol) AddRLEs(encoding []byte) error

AddRLEs adds binary encoding of RLEs to SparseVol.

func (*SparseVol) Clear

func (vol *SparseVol) Clear()

func (*SparseVol) Label

func (vol *SparseVol) Label() uint64

func (*SparseVol) MaximumPoint3d

func (vol *SparseVol) MaximumPoint3d() Point3d

func (*SparseVol) MinimumPoint3d

func (vol *SparseVol) MinimumPoint3d() Point3d

func (*SparseVol) SetLabel

func (vol *SparseVol) SetLabel(label uint64)

func (*SparseVol) Size

func (vol *SparseVol) Size() Point3d

func (*SparseVol) SurfaceSerialization

func (vol *SparseVol) SurfaceSerialization(blockNz int32, res NdFloat32) ([]byte, error)

SurfaceSerialization returns binary-encoded surface data with the following format:

First 4 bytes (little-endian) # voxels (N)
Array of N vertices, each with 3 little-endian float32 (x,y,z)
Array of N normals, each with 3 little-endian float32 (nx,ny,nz)

The blockNz parameter is necessary since underlying RLEs in the SparseVol are ordered by blocks in Z but not within a block, so RLEs can have different Z within a block.

type Subvolume

type Subvolume struct {
	// contains filtered or unexported fields
}

Subvolume describes a 3d box Geometry. The "Sub" prefix emphasizes that the data is usually a smaller portion of the volume held by the DVID datastore. Note that the 3d coordinate system is assumed to be a Right-Hand system like OpenGL.

func NewSubvolume

func NewSubvolume(offset, size Point) *Subvolume

NewSubvolume returns a Subvolume given a subvolume's origin and size.

func NewSubvolumeFromStrings

func NewSubvolumeFromStrings(offsetStr, sizeStr, sep string) (*Subvolume, error)

NewSubvolumeFromStrings returns a Subvolume given string representations of offset ("0,10,20") and size ("250,250,250").

func (*Subvolume) DataShape

func (s *Subvolume) DataShape() DataShape

func (*Subvolume) EndPoint

func (s *Subvolume) EndPoint() Point

func (*Subvolume) NumVoxels

func (s *Subvolume) NumVoxels() int64

func (*Subvolume) Size

func (s *Subvolume) Size() Point

func (*Subvolume) StartPoint

func (s *Subvolume) StartPoint() Point

func (*Subvolume) String

func (s *Subvolume) String() string

type TypeString

type TypeString string

TypeString is a string that is the name of a DVID data type.

type UUID

type UUID string

UUID is a 32 character hexidecimal string ("" if invalid) that uniquely identifies nodes in a datastore's DAG. We need universally unique identifiers to prevent collisions during creation of child nodes by distributed DVIDs: http://en.wikipedia.org/wiki/Universally_unique_identifier

func NewUUID

func NewUUID() UUID

NewUUID returns a UUID

type VersionLocalID

type VersionLocalID LocalID

VersionalLocalID is a DVID server-specific ID that is more compact than a UUID. We assume we do not need more than 16-bits to represent the number of nodes in a version DAG.

Jump to

Keyboard shortcuts

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