datatable

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// This is for internal debugging only. DO NOT USE THIS in your code. Disable "fast filter" if this is true.
	DbgNoFastFilter = false
)

Functions

This section is empty.

Types

type CSVOptions

type CSVOptions struct {
	HasHeader        bool
	MapColumnsByName bool
	Namespace        []string
}

type DataIterContext

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

func NewDataIterContextWithCache

func NewDataIterContextWithCache(dt *DataTable) DataIterContext

Make a new data iterator context.

func (DataIterContext) RootObjectCols

func (s DataIterContext) RootObjectCols() []int

Get the number of columns of the root objects.

type DataRelation

type DataRelation struct {
	DataIterContext
	// contains filtered or unexported fields
}

func (DataRelation) ColLen

func (s DataRelation) ColLen() int

Get the number of columns of the current objects.

func (DataRelation) ForEachChildRelationDescribes

func (s DataRelation) ForEachChildRelationDescribes(iter func(i int, rel DataRelation) bool) bool

Iterate the child relations.

func (DataRelation) Names

func (s DataRelation) Names(ns [][]string) [][]string

Get the column names as a slice.

func (DataRelation) SimpleNames

func (s DataRelation) SimpleNames(ns []string) []string

Get the column names as a slice.

type DataRow

type DataRow struct {
	DataRowRange
	// contains filtered or unexported fields
}

DataRow represents a row in the data table.

func (DataRow) ForEachChildRelations

func (s DataRow) ForEachChildRelations(iter func(i int, rr DataRowRange) bool) bool

Iterate the child relations.

func (DataRow) ForEachColumns

func (s DataRow) ForEachColumns(iter func(c int, name []string, v interface{}))

Iterate the column.

func (DataRow) Get

func (s DataRow) Get(col int) interface{}

Get the column value at the index.

func (DataRow) RawValues

func (s DataRow) RawValues(vs []interface{}) []interface{}

Get the column raw values as a slice.

func (DataRow) Set

func (s DataRow) Set(col int, v interface{}) error

Set the column value at the index.

func (DataRow) Values

func (s DataRow) Values(vs []interface{}) []interface{}

Get the column values as a slice.

type DataRowRange

type DataRowRange struct {
	*DataRelation
	// contains filtered or unexported fields
}

func (DataRowRange) ForEachObjects

func (s DataRowRange) ForEachObjects(iter func(i int, row DataRow) bool) bool

Iterate the objects.

type DataTable

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

Data table

func NewDataTable

func NewDataTable(rtCtx *runtime.RuntimeContext, types ...DataColumnType) *DataTable

Create a new DataTable.

func NewDataTableFromCSV

func NewDataTableFromCSV(rtCtx *runtime.RuntimeContext, reader *csv.Reader, options CSVOptions) (*DataTable, error)

NewDataTableFromCSV creates a new data table from the CSV reader.

func NewDataTableWithSize

func NewDataTableWithSize(rtCtx *runtime.RuntimeContext, l, c int, types ...DataColumnType) *DataTable

Create a new DataTable with size and capacity.

func NewDatatableFromDescribe

func NewDatatableFromDescribe(rtCtx *runtime.RuntimeContext, describeObj *DescribeObject) (*DataTable, error)

func (*DataTable) Aggregate

func (p *DataTable) Aggregate(groupBy []int, having []FilterInfo, cols ...SelectInfo) (*DataTable, error)

Aggregate rows by `group-by` columns and apply aggregate functions to the other columns. Filter aggregated rows by `having` clause.

func (*DataTable) Append

func (p *DataTable) Append(iter func(i int, row DataRow) bool)

Append rows. The argument `i` of the lambda is a loop counter.

func (*DataTable) AppendFromCSV

func (p *DataTable) AppendFromCSV(reader *csv.Reader, options CSVOptions) error

AppendFromCSV appends the data from the CSV reader. TODO: null treating

func (*DataTable) AppendFromJSONLines

func (p *DataTable) AppendFromJSONLines(reader io.Reader) error

AppendFromJSON appends rows from JSON Lines stream.

func (*DataTable) Borrow

func (p *DataTable) Borrow() *DataTable

Borrow all columns and indices. The newly returned DataTable shares memory for columns and indices.

func (*DataTable) Cap

func (p *DataTable) Cap() int

Returns the capacity of columns and indexes.

func (*DataTable) ColLen

func (p *DataTable) ColLen() int

Returns the number of columns.

func (*DataTable) ColNames

func (p *DataTable) ColNames() [][]string

Returns the column names with namespaces.

func (*DataTable) ColSimpleNames

func (p *DataTable) ColSimpleNames() []string

Returns the column names without namespaces.

func (*DataTable) Filter

func (p *DataTable) Filter(filters ...FilterInfo) error

Filter rows. The index is changed. The order of the physical rows does not change. Destructive method.

func (*DataTable) ForEach

func (p *DataTable) ForEach(iter func(i int, row DataRow) bool)

Iterate rows. The argument `i` of the lambda is a loop counter.

func (*DataTable) FullJoin

func (p *DataTable) FullJoin(colL int, dtR *DataTable, colR int, relName string, options JoinOptions) (*DataTable, error)

Full join by colL and colR; colL must be primary key and colR must be foreign key.

func (*DataTable) GetDescribe

func (p *DataTable) GetDescribe() *DescribeObject

func (*DataTable) Grow

func (p *DataTable) Grow(n int)

Similar to Resize() but it is for extend rows.

func (*DataTable) InnerJoin

func (p *DataTable) InnerJoin(colL int, dtR *DataTable, colR int, relName string, options JoinOptions) (*DataTable, error)

Inner join by colL and colR; colL must be primary key and colR must be foreign key.

func (*DataTable) LeftJoin

func (p *DataTable) LeftJoin(colL int, dtR *DataTable, colR int, relName string, options JoinOptions) (*DataTable, error)

Left join by colL and colR; colL must be primary key and colR must be foreign key.

func (*DataTable) Len

func (p *DataTable) Len() int

Returns the number of rows in all columns and indices.

func (*DataTable) Materialize

func (p *DataTable) Materialize()

Convert the table to have physical columns of index order and size. Destructive method.

func (*DataTable) Own

func (p *DataTable) Own()

Take ownership of all columns and indices. Columns and indices that did not have ownership will be copied.

func (*DataTable) ResetIndex

func (p *DataTable) ResetIndex()

Reset the index to the same order as the physical rows. Destructive method.

func (*DataTable) Resize

func (p *DataTable) Resize(n int)

Physically resize the rows. Destructive method.

func (*DataTable) Reverse

func (p *DataTable) Reverse()

Index in reverse order.

func (*DataTable) RootObjectColLen

func (p *DataTable) RootObjectColLen() int

Get the number of columns of the root objects.

func (*DataTable) RootObjectsRowRange

func (p *DataTable) RootObjectsRowRange() DataRowRange

Get the root object iterator.

func (*DataTable) Select

func (p *DataTable) Select(cols ...SelectInfo) (*DataTable, error)

Returns a new data table with the columns transformed. If all columns of a new table are not populated by formulas, the columns are shared with the original data table.

func (*DataTable) SetHeader

func (p *DataTable) SetHeader(header [][]string) error

Name the colums with namespaces.

func (*DataTable) SetSimpleHeader

func (p *DataTable) SetSimpleHeader(header []string) error

Name the columns.

func (*DataTable) Slice

func (p *DataTable) Slice(offset, limit int) *DataTable

Returns a new data table with sliced rows. The columns are shared with the original data table.

func (*DataTable) Sort

func (p *DataTable) Sort(orders ...SortInfo) error

Sort rows. The index is changed. The order of the physical rows does not change. Destructive method.

func (*DataTable) ToUntyped

func (p *DataTable) ToUntyped(iter func(i int, record map[string]interface{}) bool) bool

ToUntyped converts the data table record to untyped object (`map[string]interface{}`). Object graph is recovered from the data table.

func (*DataTable) Unmarshal

func (p *DataTable) Unmarshal(to interface{}) error

Unmarshal the DataTable to the specified type array.

func (*DataTable) Walk

func (p *DataTable) Walk(
	iter func(lv, i int, path []string, fieldNames []string, vals []interface{}, row DataRow, cols []int) bool) bool

Iterate the object graph.

func (*DataTable) WriteToCSV

func (p *DataTable) WriteToCSV(writer *csv.Writer, options CSVOptions) error

WriteToCSV writes the data table to the CSV writer. TODO: null treating

type JoinOptions

type JoinOptions struct {
	RightMustZeroOrOnce bool
}

Directories

Path Synopsis
function

Jump to

Keyboard shortcuts

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