Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToString ¶
ToString converts the given table to a string. To do this, it calls Table.Rows exactly once and drains the obtained RowIterator. The resulting string representation is a formatted table, where the column headers contain the type name of the column, and aliases are used over plain column names, if present.
col1 (Integer) col2 (String) 1 foobar 2 snafu
Types ¶
type Col ¶
Col is a header for a single column in a table, containing the qualified name of the col, a possible alias and the col data type.
func FindColumnForNameOrAlias ¶
FindColumnForNameOrAlias checks the given table for a column that has the given nameOrAlias as name or as an alias. Every column is first checked for its name, then for its alias. A nameOrAlias "*" will NOT yield a column.
type Error ¶
type Error string
Error is a sentinel error.
const ( // ErrEOT indicates, that a table iterator is fully drained and will not yield // any more results. ErrEOT Error = "end of table" )
type Row ¶
Row is a collection of values with no column information. To have column information available for the values, see table.RowWithColInfo.
type RowIterator ¶
RowIterator is an iterator that can be reset, which results in Next obtaining the rows in the beginning again. It must be closed after use.
type RowWithColInfo ¶
RowWithColInfo is a row with col information available.
func NewRowWithImplicitColData ¶
func NewRowWithImplicitColData(values []types.Value) RowWithColInfo
NewRowWithImplicitColData creates a new RowWithColInfo and implies the column information from the given values. That is, type information is extracted from the values, and column qualified names are of the form column<colIndex>, where colIndex is one-based. This results in generated column names such as column1, column5, column26 etc.
func (RowWithColInfo) ValueForColName ¶
func (r RowWithColInfo) ValueForColName(colName string) (types.Value, bool)
ValueForColName checks if this row has a value for the given col name. It has such a value, if any cols QualifiedName or Alias matches the given argument. If no such value is present, false is returned.
type Table ¶
type Table interface { // Cols returns all column information of this table. Cols() ([]Col, error) // Rows returns a resettable row iterator, which can be used to iterate over all // rows in this table. Multiple calls to this method result in different row iterator // objects. Rows() (RowIterator, error) }
Table describes a collection of rows, where each row consists of multiple columns. A column has a type, and that information is carried separately in the table. A table has a row iterator, which can be used to obtain all rows of the table in sequence. Multiple calls to RowIterator must result in different iterators.
var ( // Empty is an empty table with no cols and no rows. Empty Table = inMemoryTable{ // contains filtered or unexported fields } )
func NewFilteredCol ¶
NewFilteredCol returns a new table that will filter columns from the given underlying table.
tbl := getSevenColTable() len(tbl.Cols()) == 7 newTbl = table.NewFilteredCol(tbl, func(i int, c Col) bool { return i > 0 }) len(newTbl.Cols()) == 6 // first column is not present anymore
func NewFilteredRow ¶
func NewFilteredRow(underlying Table, keep func(RowWithColInfo) (bool, error)) Table
NewFilteredRow returns a new table that can filter rows from the given underlying table.
func NewInMemory ¶
NewInMemory returns a new in-memory table, consisting of the given cols and rows.