Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CsvDataLoader ¶
type CsvDataLoader struct {
// contains filtered or unexported fields
}
CsvDataLoader is an implementation of DataLoader that reads data from chunks of CSV files and inserts them into a table.
func NewCsvDataLoader ¶
func NewCsvDataLoader(ctx *sql.Context, table sql.InsertableTable, delimiter string, header bool) (*CsvDataLoader, error)
NewCsvDataLoader creates a new DataLoader instance that will insert records from chunks of CSV data into |table|. If |header| is true, the first line of the data will be treated as a header and ignored. If |delimiter| is not the empty string, it will be used as the delimiter separating value.
func (*CsvDataLoader) Abort ¶
func (cdl *CsvDataLoader) Abort(ctx *sql.Context) error
Abort implements the DataLoader interface
func (*CsvDataLoader) Finish ¶
func (cdl *CsvDataLoader) Finish(ctx *sql.Context) (*LoadDataResults, error)
Finish implements the DataLoader interface
type DataLoader ¶
type DataLoader interface { // LoadChunk reads the records from |data| and inserts them into the previously configured table. Data records // are not guaranteed to stard and end cleanly on chunk boundaries, so implementations must recognize incomplete // records and save them to prepend on the next processed chunk. LoadChunk(ctx *sql.Context, data *bufio.Reader) error // Abort aborts the current load operation and releases all used resources. Abort(ctx *sql.Context) error // Finish finalizes the current load operation and commits the inserted rows so that the data becomes visibile // to clients. Implementations should check that the last call to LoadChunk did not end with an incomplete // record and return an error to the caller if so. The returned LoadDataResults describe the load operation, // including how many rows were inserted. Finish(ctx *sql.Context) (*LoadDataResults, error) }
DataLoader allows callers to insert rows from multiple chunks into a table. Rows encoded in each chunk will not necessarily end cleanly on a chunk boundary, so DataLoader implementations must handle recognizing partial, or incomplete records, and saving that partial record until the next call to LoadChunk, so that it may be prefixed with the incomplete record.
type LoadDataResults ¶
type LoadDataResults struct { // RowsLoaded contains the total number of rows inserted during a load data operation. RowsLoaded int32 }
LoadDataResults contains the results of a load data operation, including the number of rows loaded.
type TabularDataLoader ¶
type TabularDataLoader struct {
// contains filtered or unexported fields
}
TabularDataLoader tracks the state of a load data operation from a tabular data source.
func NewTabularDataLoader ¶
func NewTabularDataLoader(ctx *sql.Context, table sql.InsertableTable, delimiterChar, nullChar string, header bool) (*TabularDataLoader, error)
NewTabularDataLoader creates a new TabularDataLoader to insert into the specifeid |table| using the specified |delimiterChar| and |nullChar|. If |header| is true, the first line of the data will be treated as a header and ignored.
func (*TabularDataLoader) Abort ¶
func (tdl *TabularDataLoader) Abort(ctx *sql.Context) error
Abort ends the current load data operation and discards any changes that have been made.
func (*TabularDataLoader) Finish ¶
func (tdl *TabularDataLoader) Finish(ctx *sql.Context) (*LoadDataResults, error)
Finish completes the current load data operation and finalizes the data that has been inserted.