row

package
v0.0.0-...-7fe8aff Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package row defines row primitives that are used to construct a Frame.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnIndexer

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

ColumnIndexer indexes the given column names using the default indexing behavior of NewIndex. If a column does not exist for a given row, then the column indexer fails. The indexer keeps track of the types associated with each column, and fails if the underlying type changes for a given column.

TODO: ColumnIndexer is currently not threadsafe.

func NewColumnIndexer

func NewColumnIndexer(columns ...string) *ColumnIndexer

NewColumnIndexer returns a ColumnIndexer for the given columns.

func (ColumnIndexer) Index

func (c ColumnIndexer) Index(data Data) (Index, error)

Index returns the index value for the given row. Returns error if the row doesn't contain all necessary columns, or if the row contains values that cannot be automatically converted into indices.

type Data

type Data map[string]interface{}

Data maps column names to column values for a given row.

func Of

func Of(args ...interface{}) Data

Of wraps the given arguments into a Data. Arguments must be given as string keys followed by values. The function panics if the arguments are not consistent with this requirement.

type Index

type Index interface {
	// Less returns true if the index is less than the given Index or Row object.
	// If the argument is an Index, then it must be the same underlying type. If
	// the argument is a Row, then it must be indexed by an Index object with the
	// same underlying type.
	Less(item btree.Item) bool
}

Index compares rows.

func NewIndex

func NewIndex(vals ...interface{}) (Index, error)

NewIndex returns an index for the given generic values. Returns error if the values cannot be automatically converted to an index.

type Indexer

type Indexer interface {
	Index(data Data) (Index, error)
}

Indexer returns an Index for a given row of data.

type IntIndex

type IntIndex int

IntIndex is an int.

func (IntIndex) Less

func (s IntIndex) Less(item btree.Item) bool

Less returns true if the int is less than the given IntIndex or Row object. Ordering follows the standard int comparison function.

type MultiIndex

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

MultiIndex compares rows via a dictionary comparison on multiple Index objects.

func NewMultiIndex

func NewMultiIndex(indices ...Index) MultiIndex

NewMultiIndex returns a MultiIndex for the given indices.

func (MultiIndex) Less

func (m MultiIndex) Less(item btree.Item) bool

Less returns true if the index is less than the given MultiIndex object, or if it is less than the given Row object indexed by a MultiIndex. Comparision is performed in index order. For example, given MultiIndex objects ["a", "b"], ["a", "c"], the first index is less than the second index. A MultiIndex with fewer constituent indices is less than a MultiIndex that agrees on all existing values. For example, ["a"] is less than ["a", "b"].

func (MultiIndex) String

func (m MultiIndex) String() string

String formats the MultiIndex as a string.

type NullIndex

type NullIndex struct{}

NullIndex represents a missing index. It is considered less than any other index.

func (NullIndex) Less

func (n NullIndex) Less(btree.Item) bool

Less returns true for all arguments.

type Row

type Row struct {
	// Index contains the index for the row.
	Index Index

	// Data contains the columns of data for the row.
	Data Data
}

Row represents a single entry in a Frame.

func (Row) Less

func (r Row) Less(item btree.Item) bool

Less returns true if the row is less than the given Row sharing the same index type, or if the row index is less than the given Index sharing the same index type.

type StringIndex

type StringIndex string

StringIndex is a string.

func (StringIndex) Less

func (s StringIndex) Less(item btree.Item) bool

Less returns true if the string is less than the given StringIndex or Row object. Ordering follows the standard string comparison function.

Jump to

Keyboard shortcuts

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