wrapper

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package wrapper provides the functionalities for the objects being passed to oracles during evaluation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context is a thread safe object passed to oracles during execution in order to allow them to signal an error.

func NewContext

func NewContext() *Context

NewContext creates a new *Context object.

func (*Context) Error

func (ctx *Context) Error(msg string)

Error sets this context to an error state with the given message.

func (*Context) IsError

func (ctx *Context) IsError() bool

IsError returns true if an error has been set in this context.

func (*Context) Message

func (ctx *Context) Message() string

Message returns the error message for this context.

func (*Context) Reset

func (ctx *Context) Reset()

Reset resets this context instance to a neutral state.

type Record

type Record struct {
	// ID can be used to read the record identifier.
	ID uint64
	// Number of elements in the vector data.
	Size int
	// contains filtered or unexported fields
}

Record is the wrapper for a single *pb.Record object used to allow access to specific records to oracles during execution. Every oracle will have this read-only view of the dataset while being evaulated.

func WrapRecord

func WrapRecord(record *pb.Record) *Record

WrapRecord creates a Record wrapper around a raw *pb.Record object.

func (*Record) Cosine

func (w *Record) Cosine(b *Record) float64

Cosine returns the cosine similarity between a vector and another.

func (*Record) CosineRange added in v1.1.0

func (w *Record) CosineRange(b *Record, start uint, end uint) float64

CosineRange returns the cosine similarity between a vector and another within a range of elements.

func (*Record) CosineSub

func (w *Record) CosineSub(b *Record, elems uint) float64

CosineSub returns the cosine similarity between a vector and another using up until the specificed number of elements.

func (*Record) Dot

func (w *Record) Dot(b *Record) float64

Dot performs the dot product between a vector and another.

func (*Record) DotRange added in v1.1.0

func (w *Record) DotRange(b *Record, start uint, end uint) float64

DotRange performs the dot product between a vector and another using a range of elements.

func (*Record) DotSub

func (w *Record) DotSub(b *Record, elems uint) float64

DotSub performs the dot product between a vector and another using up until the specificed number of elements.

func (*Record) Equal added in v1.2.0

func (w *Record) Equal(b *Record) bool

Equal returns whether the vectors have the same size and are element-wise equal.

func (*Record) Get

func (w *Record) Get(index int) float32

Get returns the index-th elements of the *pb.Record contained by this wrapper.

func (*Record) Is

func (w *Record) Is(b *Record) bool

Is returns true if this wrapped record and another wrapped record have the same identifier, in other words if they are just two wrappers around the same *pb.Record object.

func (*Record) IsNull

func (w *Record) IsNull() bool

IsNull returns true if the record wrapped by this object is nil.

func (*Record) Jaccard added in v1.1.0

func (w *Record) Jaccard(b *Record) float64

Jaccard returns the Jaccard distance between a vector and another.

func (*Record) JaccardRange added in v1.1.0

func (w *Record) JaccardRange(b *Record, start uint, end uint) float64

JaccardRange returns the Jaccard distance between a vector and another within a range of elements.

func (*Record) Magnitude

func (w *Record) Magnitude() float64

Magnitude returns the magnitude of the vector.

func (*Record) Meta

func (w *Record) Meta(name string) string

Meta returns the value of a record meta data given its name or an empty string if not found.

func (*Record) SetData added in v1.2.0

func (w *Record) SetData(data []float32)

type Records

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

Records is an object that wraps *storage.Records in order to give access to those records to oracles during execution.

func WrapRecords

func WrapRecords(records *storage.Records) Records

WrapRecords creates a Records wrapper around a *storage.Records object.

func (Records) All

func (w Records) All() []*Record

All returns a wrapped list of records in the current storage.

func (Records) AllBut

func (w Records) AllBut(exclude *Record) []*Record

AllBut returns a wrapped list of records in the current storage but the one specified.

func (Records) CreateRecord added in v1.1.0

func (w Records) CreateRecord(data []float32) *Record

CreateRecord creates a new record from raw data.

func (Records) Find

func (w Records) Find(id uint64) *Record

Find returns a wrapped Record given its identifier. If not found, the resulting record will result as null (record.IsNull() will be true).

Jump to

Keyboard shortcuts

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