Documentation
¶
Index ¶
- Variables
- type Config
- type Conn
- type ExternalTable
- type ExternalTableReader
- type Gateway
- func (g *Gateway) Clone() *Gateway
- func (g *Gateway) Close() error
- func (g *Gateway) Closed() bool
- func (g *Gateway) InsertArgs(ctx context.Context, query string, batchSize int, args ...interface{}) error
- func (g *Gateway) InsertFromReader(ctx context.Context, query string, file io.Reader) (int, error)
- func (g *Gateway) InsertTable(ctx context.Context, query string, table [][]interface{}, batchSize int) error
- func (g *Gateway) InsertWithData(ctx context.Context, query string, dataReader io.Reader, dataFmt string, ...) (*QueryResult, error)
- func (g *Gateway) InsertWithDataFormatAuto(ctx context.Context, query string, dataReader io.Reader) (*QueryResult, error)
- func (g *Gateway) Ping() error
- func (g *Gateway) PrepareContext(ctx context.Context, query string) (Stmt, error)
- func (g *Gateway) PrepareInsert(ctx context.Context, query string, batchSize int) (*InsertStmt, error)
- func (g *Gateway) PrepareMultiConnectionInsert(ctx context.Context, query string, batchSize, connCount int) (*MultiInsertStatement, error)
- func (g *Gateway) Query(query string) (*QueryResult, error)
- func (g *Gateway) QueryContext(ctx context.Context, query string) (*QueryResult, error)
- func (g *Gateway) QueryContextWithExternalTable(ctx context.Context, query string, externalTable *ExternalTable) (*QueryResult, error)
- func (g *Gateway) QueryContextWithExternalTableReader(ctx context.Context, query string, externalTable *ExternalTableReader) (*QueryResult, error)
- func (g *Gateway) SendInsertQuery(ctx context.Context, query string) error
- type HostOverride
- type InsertStmt
- type Logf
- type MultiInsertStatement
- type QueryResult
- func (q *QueryResult) Close() error
- func (q *QueryResult) Columns() []*column.CHColumn
- func (q *QueryResult) Exception() error
- func (q *QueryResult) ExportToReader(fmtType string) io.Reader
- func (q *QueryResult) GetAllLogs() []*response.LogPacket
- func (q *QueryResult) GetAllMeta() []response.Packet
- func (q *QueryResult) NextRow() ([]interface{}, bool)
- func (q *QueryResult) NextRowAsString() ([]interface{}, bool)
- type Stmt
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a configuration parsed from a DSN string.
type Conn ¶
type Conn interface { // QueryContext sends a query and returns a QueryResult // The query result can be used to export to a file QueryContext(ctx context.Context, query string) (*QueryResult, error) // QueryContextWithExternalTable sends a query with an external table // The name of the external table in the query has to correspond to that in the externalTable you are sending QueryContextWithExternalTable(ctx context.Context, query string, externalTable *ExternalTable) (*QueryResult, error) // QueryContextWithExternalTable sends a query with an external table from an io.Reader (can be a file) // The name of the external table in the query has to correspond to that in the externalTable you are sending QueryContextWithExternalTableReader(ctx context.Context, query string, externalTable *ExternalTableReader) (*QueryResult, error) // PrepareContext is used for batch insertion // PrepareContext sends the query to the database and return a Stmt interface // The Stmt interface can be used to send the arguments for the query PrepareContext(ctx context.Context, query string) (Stmt, error) // InsertFromReader inserts data from io.Reader // Can be used for insert with files such as csv or json // DataPacket will be read from the reader until io.EOF is returned as an error from reader.Read() InsertFromReader(ctx context.Context, query string, reader io.Reader) (int, error) }
type ExternalTable ¶
type ExternalTable struct {
// contains filtered or unexported fields
}
func NewExternalTable ¶
func NewExternalTable(name string, values [][]interface{}, columnNames []string, columnTypes []column.CHColumnType) *ExternalTable
ExternalTableFromReader creates an external table columnTypes are the clickhouse column type for each column in the table, e.g. UInt8, Uint32, etc values are the table values The type of each column in values table must correspond to the columnTypes specified
func (*ExternalTable) ToSingleBlockStream ¶
func (e *ExternalTable) ToSingleBlockStream() (<-chan *data.Block, error)
type ExternalTableReader ¶
type ExternalTableReader struct {
// contains filtered or unexported fields
}
func NewExternalTableReader ¶
func NewExternalTableReader(name string, reader io.Reader, columnNames []string, columnTypes []column.CHColumnType, fileType string) *ExternalTableReader
NewExternalTableReader creates an external table from a file It parses the data according to the fileType The type of each column in the file must correspond to the columnTypes specified Column types are the clickhouse column type for each column in the table, e.g. UInt8, Uint32, etc Supported fileType values are CSV, CSVWithNames, JSON, VALUES
type Gateway ¶
type Gateway struct {
Conn *conn.GatewayConn
}
func OpenConfig ¶
func (*Gateway) InsertArgs ¶
func (*Gateway) InsertFromReader ¶
func (*Gateway) InsertTable ¶
func (*Gateway) InsertWithData ¶
func (*Gateway) InsertWithDataFormatAuto ¶
func (g *Gateway) InsertWithDataFormatAuto(ctx context.Context, query string, dataReader io.Reader) (*QueryResult, error)
InsertWithDataFormatAuto handles insert Query with data reader
func (*Gateway) PrepareContext ¶
func (*Gateway) PrepareInsert ¶
func (g *Gateway) PrepareInsert(ctx context.Context, query string, batchSize int) (*InsertStmt, error)
PrepareInsert returns an Insert Statement that must be closed after use.
func (*Gateway) PrepareMultiConnectionInsert ¶
func (*Gateway) QueryContext ¶
func (*Gateway) QueryContextWithExternalTable ¶
func (g *Gateway) QueryContextWithExternalTable(ctx context.Context, query string, externalTable *ExternalTable) (*QueryResult, error)
func (*Gateway) QueryContextWithExternalTableReader ¶
func (g *Gateway) QueryContextWithExternalTableReader(ctx context.Context, query string, externalTable *ExternalTableReader) (*QueryResult, error)
type HostOverride ¶
type InsertStmt ¶
type InsertStmt struct {
// contains filtered or unexported fields
}
func NewInsertStatement ¶
func NewInsertStatement( ctx context.Context, sample *data.Block, sendBlock stream.SendBlock, cancelInsert stream.CancelInsert, serverResponseStream <-chan response.Packet, opts ...stream.InsertOption, ) *InsertStmt
func (*InsertStmt) Close ¶
func (s *InsertStmt) Close() error
func (*InsertStmt) Exec ¶
func (s *InsertStmt) Exec(args ...interface{}) (err error)
func (*InsertStmt) ExecContext ¶
func (s *InsertStmt) ExecContext(ctx context.Context, args ...interface{}) (err error)
type MultiInsertStatement ¶
type MultiInsertStatement struct {
// contains filtered or unexported fields
}
MultiInsertStatement that stores multiple Insert Statements attached to multiple connection. ExecContext can be done asynchronously. insertion load is distributed across insert stmts, switching from insert stmts happens when the columns buffer is at its full capacity(batch size).
func NewMultiInsertStatement ¶
func NewMultiInsertStatement(stmts []*InsertStmt, close closeAllConnection) (*MultiInsertStatement, error)
func (*MultiInsertStatement) Close ¶
func (m *MultiInsertStatement) Close() error
func (*MultiInsertStatement) ExecContext ¶
func (m *MultiInsertStatement) ExecContext(ctx context.Context, args ...interface{}) error
func (*MultiInsertStatement) Switch ¶
func (m *MultiInsertStatement) Switch()
type QueryResult ¶
type QueryResult struct {
// contains filtered or unexported fields
}
func NewInsertQueryResult ¶
func NewInsertQueryResult(responses <-chan response.Packet) *QueryResult
func NewQueryResult ¶
func NewQueryResult(responses <-chan response.Packet, finish func()) *QueryResult
func (*QueryResult) Close ¶
func (q *QueryResult) Close() error
func (*QueryResult) Columns ¶
func (q *QueryResult) Columns() []*column.CHColumn
func (*QueryResult) Exception ¶
func (q *QueryResult) Exception() error
func (*QueryResult) ExportToReader ¶
func (q *QueryResult) ExportToReader(fmtType string) io.Reader
func (*QueryResult) GetAllLogs ¶
func (q *QueryResult) GetAllLogs() []*response.LogPacket
func (*QueryResult) GetAllMeta ¶
func (q *QueryResult) GetAllMeta() []response.Packet
func (*QueryResult) NextRow ¶
func (q *QueryResult) NextRow() ([]interface{}, bool)
func (*QueryResult) NextRowAsString ¶
func (q *QueryResult) NextRowAsString() ([]interface{}, bool)
type Stmt ¶
type Stmt interface { // ExecContext is used to send a row of query argument to the clickhouse server ExecContext(ctx context.Context, args ...interface{}) error // Close sends leftover queued query arguments to the clickhouse server and closes the stmt // Close has to be called at the end for each Stmt Close() error }