sstable

package
v0.0.0-...-762ccde Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIndexOutOfRange = errors.New("matrix: index out of range")
	ErrBadShape        = errors.New("matrix: non-positive dimension not allowed")
)

Functions

func Float32Serialize

func Float32Serialize(m *Float32Matrix, fn string) error

serialize data to file

func Float32VectorSum

func Float32VectorSum(data []float32) float32

float32 vector summation

func Uint32Serialize

func Uint32Serialize(m *Uint32Matrix, fn string) error

serialize data to file

func Uint32VectorSum

func Uint32VectorSum(data []uint32) uint32

uint32 vector summation

Types

type DocWord

type DocWord struct {
	DocId   uint32
	WordIdx uint32
}

key-value pair util

type Float32Matrix

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

internal Float32 matrix representation

func Float32Deserialize

func Float32Deserialize(fn string) (*Float32Matrix, error)

deserialize data from file

func NewFloat32Matrix

func NewFloat32Matrix(r, c uint32) *Float32Matrix

NewFloat32Matrix creates a new Float32Matrix with r rows and c columns which is mainly used for caching temporary results

func (*Float32Matrix) Get

func (m *Float32Matrix) Get(r, c uint32) float32

get the [r, c]-th element of the matrix

func (*Float32Matrix) Set

func (m *Float32Matrix) Set(r, c uint32, val float32)

set val to the [r, c]-th element of the matrix

func (*Float32Matrix) Shape

func (m *Float32Matrix) Shape() (uint32, uint32)

get the shape of the matrix

type SortedMap

type SortedMap struct {
	Data       map[uint32][]uint32
	RotateLen  uint32
	TopicMask  uint32
	MaxWordId  uint32
	MaxTopicId uint32
}
var (
	// Cache nonzero topic count of word and the values
	// are sorted by count in descending order. Each value
	// is represented by a uint32 number where the lower k
	// bits are the minimum bits needed to hold the max number
	// of topics and the upper 32-k bits are used to hold the
	// count number
	WordTopicMap *SortedMap
)

func NewSortedMap

func NewSortedMap(topicNum uint32) *SortedMap

func (*SortedMap) Decr

func (this *SortedMap) Decr(wordId uint32, topicId uint32, count uint32)

func (*SortedMap) Deserialize

func (this *SortedMap) Deserialize(fn string) error

deserialize data from file

func (*SortedMap) Get

func (this *SortedMap) Get(wordId uint32, idx int) (uint32, uint32)

get the i-th element of the value slice of wordId and return parsed value of topicId and count

func (*SortedMap) Incr

func (this *SortedMap) Incr(wordId uint32, topicId uint32, count uint32)

func (*SortedMap) Serialize

func (this *SortedMap) Serialize(fn string) error

serialize data to file

type Uint32Matrix

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

internal Uint32 matrix representation

func NewUint32Matrix

func NewUint32Matrix(r, c uint32) *Uint32Matrix

NewUint32Matrix creates a new Uint32Matrix with r rows and c columns. if r*c <= 0, it will panic. A uint32 slice is used as the underlying storage and the data layout is in row major order, i.e. the (i*c + j)-th element in the data slice is the [i, j]-th element in the matrix. Vector is defined as a matrix one column, i.e. a column vector.

func Uint32Deserialize

func Uint32Deserialize(fn string) (*Uint32Matrix, error)

deserialize data from file

func (*Uint32Matrix) Decr

func (m *Uint32Matrix) Decr(r, c uint32, val uint32)

decrement the [r, c]-th element of the matrix by val

func (*Uint32Matrix) Get

func (m *Uint32Matrix) Get(r, c uint32) uint32

get the [r, c]-th element of the matrix

func (*Uint32Matrix) GetCol

func (m *Uint32Matrix) GetCol(c uint32) []uint32

get the c-th column of the matrix

func (*Uint32Matrix) GetRow

func (m *Uint32Matrix) GetRow(r uint32) []uint32

get the r-th row of the matrix

func (*Uint32Matrix) Incr

func (m *Uint32Matrix) Incr(r, c uint32, val uint32)

increment the [r, c]-th element of the matrix by val

func (*Uint32Matrix) Set

func (m *Uint32Matrix) Set(r, c uint32, val uint32)

set val to the [r, c]-th element of the matrix

func (*Uint32Matrix) Shape

func (m *Uint32Matrix) Shape() (uint32, uint32)

get the shape of the matrix

Jump to

Keyboard shortcuts

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