Documentation ¶
Index ¶
- Constants
- func DefaultPostgresValueFromD3MType(typ string) interface{}
- func GetIndexStatement(tableName string, fieldName string, typ string) string
- func GetValidTypes() []string
- func GetViewField(variable *model.Variable) string
- func IsColumnType(client DatabaseDriver, tableName string, variable *model.Variable, ...) bool
- func IsNullable(typ string) bool
- func MapD3MTypeToPostgresType(typ string) string
- func MapPostgresTypeToD3MType(pType string) ([]string, error)
- func ValueForFieldType(typ string, field string) string
- type ClientCtor
- type Config
- type CopyFromSource
- type Database
- func (d *Database) AddWordStems(data []string) error
- func (d *Database) CreateIndex(tableName string, fieldName string, typ string) error
- func (d *Database) CreateResultTable(tableName string) error
- func (d *Database) CreateSolutionMetadataTables() error
- func (d *Database) DeleteDataset(name string)
- func (d *Database) DropTable(tableName string) error
- func (d *Database) DropView(viewName string) error
- func (d *Database) IngestRow(tableName string, data []string) error
- func (d *Database) InitializeDataset(meta *model.Metadata) (*Dataset, error)
- func (d *Database) InitializeTable(tableName string, ds *Dataset) error
- func (d *Database) InsertRemainingRows() error
- func (d *Database) IsArray(typ string) bool
- func (d *Database) StoreMetadata(tableName string) error
- type DatabaseDriver
- type Dataset
- func (ds *Dataset) AddInsert(statement string, args []interface{})
- func (ds *Dataset) AddInsertFromSource(values []interface{})
- func (ds *Dataset) AddVariable(variable *model.Variable)
- func (ds *Dataset) GetBatch() *pgx.Batch
- func (ds *Dataset) GetBatchSize() int
- func (ds *Dataset) GetColumns() []string
- func (ds *Dataset) GetInsertSource() [][]interface{}
- func (ds *Dataset) GetInsertSourceLength() int
- func (ds *Dataset) GetPrimaryKey() string
- func (ds *Dataset) HasVariable(variable *model.Variable) bool
- func (ds *Dataset) ResetBatch()
- type IntegratedClient
- func (ic IntegratedClient) Begin() (pgx.Tx, error)
- func (ic IntegratedClient) CopyFrom(storageName string, columns []string, rows [][]interface{}) (int64, error)
- func (ic IntegratedClient) Exec(sql string, params ...interface{}) (pgconn.CommandTag, error)
- func (ic IntegratedClient) Query(sql string, params ...interface{}) (pgx.Rows, error)
- func (ic IntegratedClient) QueryRow(sql string, params ...interface{}) pgx.Row
- func (ic IntegratedClient) SendBatch(batch *pgx.Batch) pgx.BatchResults
- type WordStem
Constants ¶
const ( // PredictionTableName is the name of the table for prediction requests. PredictionTableName = "prediction" // RequestTableName is the name of the table for solution requests. RequestTableName = "request" // SolutionTableName is the name of the table for solutions. SolutionTableName = "solution" // SolutionFeatureWeightTableName is the name of the table for solution feature weights. SolutionFeatureWeightTableName = "solution_weight" // SolutionStateTableName is the name of the table for solution state. SolutionStateTableName = "solution_state" // SolutionResultTableName is the name of the table for the result. SolutionResultTableName = "solution_result" // SolutionResultExplainOutputTableName is the name of the table for the result explain output. SolutionResultExplainOutputTableName = "solution_result_explain" // SolutionScoreTableName is the name of the table for the score. SolutionScoreTableName = "solution_score" // RequestFeatureTableName is the name of the table for the request features. RequestFeatureTableName = "request_feature" // RequestFilterTableName is the name of the table for the request filters. RequestFilterTableName = "request_filter" // WordStemTableName is the name of the table for the word stems. WordStemTableName = "word_stem" )
Variables ¶
This section is empty.
Functions ¶
func DefaultPostgresValueFromD3MType ¶
func DefaultPostgresValueFromD3MType(typ string) interface{}
DefaultPostgresValueFromD3MType generates a default postgres value from a d3m type.
func GetIndexStatement ¶
GetIndexStatement returns the index SQL statement for a field of the provided type.
func GetValidTypes ¶
func GetValidTypes() []string
GetValidTypes returns all of the supported types in the DB
func GetViewField ¶
GetViewField returns a SQL string that does a typed select, defaulting as necessary.
func IsColumnType ¶
func IsColumnType(client DatabaseDriver, tableName string, variable *model.Variable, colType string) bool
IsColumnType can be use to check columns potential types
func IsNullable ¶
IsNullable indicates whether or not a database type can be empty.
func MapD3MTypeToPostgresType ¶
MapD3MTypeToPostgresType generates a postgres type from a d3m type.
func MapPostgresTypeToD3MType ¶
MapPostgresTypeToD3MType converts postgres types to D3M types
func ValueForFieldType ¶
ValueForFieldType generates the select field value for a given variable type.
Types ¶
type ClientCtor ¶
type ClientCtor func() (DatabaseDriver, error)
ClientCtor repressents a client constructor to instantiate a postgres client.
type Config ¶
type Config struct { Database string Table string User string Password string Port int Host string BatchSize int PostgresLogLevel string }
Config has the necessary configuration values for a postgres connection.
type CopyFromSource ¶
CopyFromSource represents a function that can use the CopyFrom operation to bulk load the data to SQL.
type Database ¶
type Database struct { Client DatabaseDriver Tables map[string]*Dataset BatchSize int BatchSizeStemWord int // contains filtered or unexported fields }
Database is a struct representing a full logical database.
func NewDatabase ¶
NewDatabase creates a new database instance.
func (*Database) AddWordStems ¶
AddWordStems builds the word stemming lookup in the database.
func (*Database) CreateIndex ¶
CreateIndex will create an index in postgres on the specified field.
func (*Database) CreateResultTable ¶
CreateResultTable creates an empty table for the solution results.
func (*Database) CreateSolutionMetadataTables ¶
CreateSolutionMetadataTables creates an empty table for the solution results.
func (*Database) DeleteDataset ¶
DeleteDataset deletes all tables & views for a dataset.
func (*Database) IngestRow ¶
IngestRow parses the raw csv data and stores it to the table specified. The previously parsed metadata is used to map columns.
func (*Database) InitializeDataset ¶
InitializeDataset initializes the dataset with the provided metadata.
func (*Database) InitializeTable ¶
InitializeTable generates and runs a table create statement based on the schema.
func (*Database) InsertRemainingRows ¶
InsertRemainingRows empties all batches and inserts the data to the database.
func (*Database) StoreMetadata ¶
StoreMetadata stores the variable information to the specified table.
type DatabaseDriver ¶
type DatabaseDriver interface { Begin() (pgx.Tx, error) Query(string, ...interface{}) (pgx.Rows, error) QueryRow(string, ...interface{}) pgx.Row Exec(string, ...interface{}) (pgconn.CommandTag, error) SendBatch(batch *pgx.Batch) pgx.BatchResults CopyFrom(string, []string, [][]interface{}) (int64, error) }
DatabaseDriver defines the behaviour of the querying engine.
type Dataset ¶
type Dataset struct { ID string Name string Description string Variables []*model.Variable // contains filtered or unexported fields }
Dataset is a struct containing the metadata of a dataset being processed.
func NewDataset ¶
func NewDataset(id, name, description string, variables []*model.Variable, primaryKey string) *Dataset
NewDataset creates a new dataset instance.
func (*Dataset) AddInsertFromSource ¶
func (ds *Dataset) AddInsertFromSource(values []interface{})
AddInsertFromSource adds a row to insert using the copy protocol.
func (*Dataset) AddVariable ¶
AddVariable adds a variable to the dataset.
func (*Dataset) GetBatch ¶
func (ds *Dataset) GetBatch() *pgx.Batch
GetBatch returns the insert statement batch.
func (*Dataset) GetBatchSize ¶
GetBatchSize gets the insert batch count.
func (*Dataset) GetColumns ¶
GetColumns builds captures the variable names in a string slice.
func (*Dataset) GetInsertSource ¶
func (ds *Dataset) GetInsertSource() [][]interface{}
GetInsertSource returns the insert from source batch.
func (*Dataset) GetInsertSourceLength ¶
GetInsertSourceLength gets the insert from source size.
func (*Dataset) GetPrimaryKey ¶
GetPrimaryKey returns the primary key of the dataset.
func (*Dataset) HasVariable ¶
HasVariable checks to see if a variable is already contained in the dataset.
type IntegratedClient ¶
type IntegratedClient struct {
// contains filtered or unexported fields
}
IntegratedClient is a postgres client that can be used to query a postgres database.
func (IntegratedClient) Begin ¶
func (ic IntegratedClient) Begin() (pgx.Tx, error)
Begin creates a new transaction.
func (IntegratedClient) CopyFrom ¶
func (ic IntegratedClient) CopyFrom(storageName string, columns []string, rows [][]interface{}) (int64, error)
CopyFrom copies data using the Postgres copy protocol for bulk data insertion.
func (IntegratedClient) Exec ¶
func (ic IntegratedClient) Exec(sql string, params ...interface{}) (pgconn.CommandTag, error)
Exec executes the sql command.
func (IntegratedClient) Query ¶
func (ic IntegratedClient) Query(sql string, params ...interface{}) (pgx.Rows, error)
Query queries the database and returns the matching rows.
func (IntegratedClient) QueryRow ¶
func (ic IntegratedClient) QueryRow(sql string, params ...interface{}) pgx.Row
QueryRow returns the first row from the query execution.
func (IntegratedClient) SendBatch ¶
func (ic IntegratedClient) SendBatch(batch *pgx.Batch) pgx.BatchResults
SendBatch submits a batch.