Documentation ¶
Overview ¶
Package table provides a framework for interacting with row based table data.
Index ¶
- func GetBadRowRow(err error) row.Row
- func IsBadRow(err error) bool
- func PipeRows(ctx context.Context, rd TableReader, wr TableWriter, contOnBadRow bool) (int, int, error)
- func ReadAllRows(ctx context.Context, rd TableReader, contOnBadRow bool) ([]row.Row, int, error)
- type AsyncReadAheadTableReader
- func (tr *AsyncReadAheadTableReader) Close(ctx context.Context) error
- func (tr *AsyncReadAheadTableReader) GetSchema() schema.Schema
- func (tr *AsyncReadAheadTableReader) ReadRow(ctx context.Context) (row.Row, error)
- func (tr *AsyncReadAheadTableReader) Start(ctx context.Context) error
- func (tr *AsyncReadAheadTableReader) VerifySchema(outSch schema.Schema) (bool, error)
- type BadRow
- type CompositeTableReader
- type InMemTable
- type InMemTableReader
- type InMemTableWriter
- type TableCloser
- type TableReadCloser
- type TableReader
- type TableWriteCloser
- type TableWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBadRowRow ¶
GetBadRow will retrieve the Row from the BadRow error
func PipeRows ¶
func PipeRows(ctx context.Context, rd TableReader, wr TableWriter, contOnBadRow bool) (int, int, error)
PipeRows will read a row from given TableReader and write it to the provided TableWriter. It will do this for every row until the TableReader's ReadRow method returns io.EOF or encounters an error in either reading or writing. The caller will need to handle closing the tables as necessary. If contOnBadRow is true, errors reading or writing will be ignored and the pipe operation will continue.
Returns a tuple: (number of rows written, number of errors ignored, error). In the case that err is non-nil, the row counter fields in the tuple will be set to -1.
func ReadAllRows ¶
ReadAllRows reads all rows from a TableReader and returns a slice containing those rows. Usually this is used for testing, or with very small data sets.
Types ¶
type AsyncReadAheadTableReader ¶
type AsyncReadAheadTableReader struct {
// contains filtered or unexported fields
}
AsyncReadAheadTableReader is a TableReadCloser implementation that spins up a go routine to keep reading data into a buffered channel so that it is ready when the caller wants it.
func NewAsyncReadAheadTableReader ¶
func NewAsyncReadAheadTableReader(tr TableReadCloser, bufferSize int) *AsyncReadAheadTableReader
NewAsyncReadAheadTableReader creates a new AsyncReadAheadTableReader
func (*AsyncReadAheadTableReader) Close ¶
func (tr *AsyncReadAheadTableReader) Close(ctx context.Context) error
Close releases resources being held
func (*AsyncReadAheadTableReader) GetSchema ¶
func (tr *AsyncReadAheadTableReader) GetSchema() schema.Schema
GetSchema gets the schema of the rows that this reader will return
func (*AsyncReadAheadTableReader) ReadRow ¶
ReadRow reads a row from a table. If there is a bad row the returned error will be non nil, and calling IsBadRow(err) will be return true. This is a potentially non-fatal error and callers can decide if they want to continue on a bad row, or fail.
func (*AsyncReadAheadTableReader) Start ¶
func (tr *AsyncReadAheadTableReader) Start(ctx context.Context) error
Start the worker routine reading rows to the channel
func (*AsyncReadAheadTableReader) VerifySchema ¶
func (tr *AsyncReadAheadTableReader) VerifySchema(outSch schema.Schema) (bool, error)
VerifySchema checks that the incoming schema matches the schema from the existing table
type BadRow ¶
BadRow is an error which contains the row and details about what is wrong with it.
type CompositeTableReader ¶
type CompositeTableReader struct {
// contains filtered or unexported fields
}
CompositeTableReader is a TableReader implementation which will concatenate the results of multiple TableReader instances into a single set of results.
func NewCompositeTableReader ¶
func NewCompositeTableReader(readers []TableReadCloser) (*CompositeTableReader, error)
NewCompositeTableReader creates a new CompositeTableReader instance from a slice of TableReadClosers.
func (*CompositeTableReader) Close ¶
func (rd *CompositeTableReader) Close(ctx context.Context) error
Close should release resources being held
func (*CompositeTableReader) GetSchema ¶
func (rd *CompositeTableReader) GetSchema() schema.Schema
GetSchema gets the schema of the rows that this reader will return
func (*CompositeTableReader) ReadRow ¶
ReadRow reads a row from a table. If there is a bad row the returned error will be non nil, and calling IsBadRow(err) will be return true. This is a potentially non-fatal error and callers can decide if they want to continue on a bad row, or fail.
func (*CompositeTableReader) VerifySchema ¶
func (rd *CompositeTableReader) VerifySchema(outSch schema.Schema) (bool, error)
VerifySchema checks that the incoming schema matches the schema from the existing table
type InMemTable ¶
type InMemTable struct {
// contains filtered or unexported fields
}
InMemTable holds a simple list of rows that can be retrieved, or appended to. It is meant primarily for testing.
func NewInMemTable ¶
func NewInMemTable(sch schema.Schema) *InMemTable
NewInMemTable creates an empty Table with the expectation that any rows added will have the given Schema
func NewInMemTableWithData ¶
func NewInMemTableWithData(sch schema.Schema, rows []row.Row) *InMemTable
NewInMemTableWithData creates a Table with the riven rows
func NewInMemTableWithDataAndValidationType ¶
func NewInMemTableWithDataAndValidationType(sch schema.Schema, rows []row.Row) *InMemTable
func (*InMemTable) AppendRow ¶
func (imt *InMemTable) AppendRow(r row.Row) error
AppendRow appends a row. Appended rows must be valid for the table's schema. Sorts rows as they are inserted.
func (*InMemTable) GetRow ¶
func (imt *InMemTable) GetRow(index int) (row.Row, error)
GetRow gets a row by index
func (*InMemTable) GetSchema ¶
func (imt *InMemTable) GetSchema() schema.Schema
GetSchema gets the table's schema
func (*InMemTable) NumRows ¶
func (imt *InMemTable) NumRows() int
NumRows returns the number of rows in the table
type InMemTableReader ¶
type InMemTableReader struct {
// contains filtered or unexported fields
}
InMemTableReader is an implementation of a TableReader for an InMemTable
func NewInMemTableReader ¶
func NewInMemTableReader(imt *InMemTable) *InMemTableReader
NewInMemTableReader creates an instance of a TableReader from an InMemTable
func (*InMemTableReader) Close ¶
func (rd *InMemTableReader) Close(ctx context.Context) error
Close should release resources being held
func (*InMemTableReader) GetSchema ¶
func (rd *InMemTableReader) GetSchema() schema.Schema
GetSchema gets the schema of the rows that this reader will return
func (*InMemTableReader) ReadRow ¶
ReadRow reads a row from a table. If there is a bad row the returned error will be non nil, and callin IsBadRow(err) will be return true. This is a potentially non-fatal error and callers can decide if they want to continue on a bad row, or fail.
func (*InMemTableReader) VerifySchema ¶
func (rd *InMemTableReader) VerifySchema(outSch schema.Schema) (bool, error)
VerifySchema checks that the incoming schema matches the schema from the existing table
type InMemTableWriter ¶
type InMemTableWriter struct {
// contains filtered or unexported fields
}
InMemTableWriter is an implementation of a TableWriter for an InMemTable
func NewInMemTableWriter ¶
func NewInMemTableWriter(imt *InMemTable) *InMemTableWriter
NewInMemTableWriter creates an instance of a TableWriter from an InMemTable
func (*InMemTableWriter) Close ¶
func (w *InMemTableWriter) Close(ctx context.Context) error
Close should flush all writes, release resources being held
func (*InMemTableWriter) GetSchema ¶
func (w *InMemTableWriter) GetSchema() schema.Schema
GetSchema gets the schema of the rows that this writer writes
type TableCloser ¶
type TableCloser interface { // Close should release resources being held Close(ctx context.Context) error }
TableCloser is an interface for a table stream that can be closed to release resources
type TableReadCloser ¶
type TableReadCloser interface { TableReader TableCloser }
TableReadCloser is an interface for reading rows from a table, that can be closed.
type TableReader ¶
type TableReader interface { // GetSchema gets the schema of the rows that this reader will return GetSchema() schema.Schema // ReadRow reads a row from a table. If there is a bad row the returned error will be non nil, and calling // IsBadRow(err) will be return true. This is a potentially non-fatal error and callers can decide if they want to // continue on a bad row, or fail. ReadRow(ctx context.Context) (row.Row, error) // VerifySchema checks that the incoming schema matches the schema from the existing table VerifySchema(outSch schema.Schema) (bool, error) }
TableReader is an interface for reading rows from a table
type TableWriteCloser ¶
type TableWriteCloser interface { TableWriter TableCloser }
TableWriteCloser is an interface for writing rows to a table, that can be closed
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package typed provides helper functions and utility classes for working with typed table data.
|
Package typed provides helper functions and utility classes for working with typed table data. |
noms
Package nbf provides TableReadCloser and TableWriteCloser implementations for working with dolt tables in noms.
|
Package nbf provides TableReadCloser and TableWriteCloser implementations for working with dolt tables in noms. |
Package untyped provides helper functions for working with untyped table data.
|
Package untyped provides helper functions for working with untyped table data. |
csv
Package csv provides TableReadCloser and TableWriteCloser implementations for working with csvs.
|
Package csv provides TableReadCloser and TableWriteCloser implementations for working with csvs. |
tabular
Package tabular provides writer implementations for working with tabular output for display
|
Package tabular provides writer implementations for working with tabular output for display |