Documentation ¶
Overview ¶
Copyright 2011 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Datasource package contains database/source type related. A few datasources are implemented here (test, csv). This package also includes schema base services (datasource registry).
Index ¶
- Constants
- Variables
- func IntrospectSchema(s *schema.Schema, name string, iter schema.Iterator) error
- func IntrospectTable(tbl *schema.Table, iter schema.Iterator) error
- func KeyFromWhere(wh interface{}) schema.Key
- func MessageConversion(vals []interface{}) []schema.Message
- func MysqlValueString(t value.ValueType) string
- func NewMySqlSessionVars() expr.ContextReadWriter
- func NewNamespacedContextReader(basereader expr.ContextReader, namespace string) expr.ContextReader
- func NewNestedContextReadWriter(readers []expr.ContextReader, writer expr.ContextWriter, ts time.Time) expr.ContextReadWriter
- func NewNestedContextReader(readers []expr.ContextReader, ts time.Time) expr.ContextReader
- func RowsForSession(ctx *plan.Context) [][]driver.Value
- func SchemaDBStoreProvider(s *schema.Schema) schema.Source
- type ContextSimple
- func NewContextMap(data map[string]interface{}, namespacing bool) *ContextSimple
- func NewContextMapTs(data map[string]interface{}, namespacing bool, ts time.Time) *ContextSimple
- func NewContextSimple() *ContextSimple
- func NewContextSimpleData(data map[string]value.Value) *ContextSimple
- func NewContextSimpleNative(data map[string]interface{}) *ContextSimple
- func NewContextSimpleTs(data map[string]value.Value, ts time.Time) *ContextSimple
- func NewMySqlGlobalVars() *ContextSimple
- func (m *ContextSimple) All() map[string]value.Value
- func (m *ContextSimple) Body() interface{}
- func (m *ContextSimple) Commit(rowInfo []expr.SchemaInfo, row expr.RowWriter) error
- func (m *ContextSimple) Delete(row map[string]value.Value) error
- func (m ContextSimple) Get(key string) (value.Value, bool)
- func (m *ContextSimple) Id() uint64
- func (m *ContextSimple) Put(col expr.SchemaInfo, rctx expr.ContextReader, v value.Value) error
- func (m *ContextSimple) Row() map[string]value.Value
- func (m *ContextSimple) SupportNamespacing()
- func (m *ContextSimple) Ts() time.Time
- type ContextUrlValues
- func (m *ContextUrlValues) Body() interface{}
- func (m *ContextUrlValues) Delete(delRow map[string]value.Value) error
- func (m ContextUrlValues) Get(key string) (value.Value, bool)
- func (m *ContextUrlValues) Id() uint64
- func (m ContextUrlValues) Put(col expr.SchemaInfo, rctx expr.ContextReader, v value.Value) error
- func (m ContextUrlValues) Row() map[string]value.Value
- func (m *ContextUrlValues) String() string
- func (m ContextUrlValues) Ts() time.Time
- type ContextWrapper
- type ContextWriterEmpty
- type CsvDataSource
- func (m *CsvDataSource) Close() error
- func (m *CsvDataSource) Columns() []string
- func (m *CsvDataSource) Init()
- func (m *CsvDataSource) Next() schema.Message
- func (m *CsvDataSource) Open(connInfo string) (schema.Conn, error)
- func (m *CsvDataSource) Setup(*schema.Schema) error
- func (m *CsvDataSource) Table(tableName string) (*schema.Table, error)
- func (m *CsvDataSource) Tables() []string
- type FileLineHandler
- type JsonHelperScannable
- type JsonSource
- func (m *JsonSource) Close() error
- func (m *JsonSource) Columns() []string
- func (m *JsonSource) CreateIterator() schema.Iterator
- func (m *JsonSource) Init()
- func (m *JsonSource) Next() schema.Message
- func (m *JsonSource) Open(connInfo string) (schema.Conn, error)
- func (m *JsonSource) Setup(*schema.Schema) error
- func (m *JsonSource) Table(tableName string) (*schema.Table, error)
- func (m *JsonSource) Tables() []string
- type JsonWrapper
- type KeyCol
- type KeyInt
- type KeyInt64
- type MessageArray
- type NamespacedContextReader
- type NestedContextReader
- func (n *NestedContextReader) Delete(delRow map[string]value.Value) error
- func (n *NestedContextReader) Get(key string) (value.Value, bool)
- func (n *NestedContextReader) Put(col expr.SchemaInfo, readCtx expr.ContextReader, v value.Value) error
- func (n *NestedContextReader) Row() map[string]value.Value
- func (n *NestedContextReader) Ts() time.Time
- type SchemaDb
- func (m *SchemaDb) Close() error
- func (m *SchemaDb) DropTable(t string) error
- func (m *SchemaDb) Init()
- func (m *SchemaDb) Open(schemaObjectName string) (schema.Conn, error)
- func (m *SchemaDb) Setup(*schema.Schema) error
- func (m *SchemaDb) Table(table string) (*schema.Table, error)
- func (m *SchemaDb) Tables() []string
- type SchemaSource
- type SqlDriverMessage
- type SqlDriverMessageMap
- func NewSqlDriverMessageMap(id uint64, row []driver.Value, colindex map[string]int) *SqlDriverMessageMap
- func NewSqlDriverMessageMapCtx(id uint64, ctx expr.ContextReader, colindex map[string]int) *SqlDriverMessageMap
- func NewSqlDriverMessageMapEmpty() *SqlDriverMessageMap
- func NewSqlDriverMessageMapVals(id uint64, row []driver.Value, cols []string) *SqlDriverMessageMap
- func (m *SqlDriverMessageMap) Body() interface{}
- func (m *SqlDriverMessageMap) Copy() *SqlDriverMessageMap
- func (m *SqlDriverMessageMap) Get(key string) (value.Value, bool)
- func (m *SqlDriverMessageMap) Id() uint64
- func (m *SqlDriverMessageMap) Key() string
- func (m *SqlDriverMessageMap) Row() map[string]value.Value
- func (m *SqlDriverMessageMap) SetKey(key string)
- func (m *SqlDriverMessageMap) SetKeyHashed(key string)
- func (m *SqlDriverMessageMap) SetRow(row []driver.Value)
- func (m *SqlDriverMessageMap) Ts() time.Time
- func (m *SqlDriverMessageMap) Values() []driver.Value
- type StringArray
- type TimeValue
- type UrlValuesMsg
- type ValueContextWrapper
Constants ¶
const (
// Default Max Allowed packets for connections
MaxAllowedPacket = 4194304
)
const (
// SchemaDbSourceType is schemadb source type name
SchemaDbSourceType = "schemadb"
)
Variables ¶
var ( // DialectWriterCols list of columns for dialectwriter. DialectWriterCols = []string{"mysql"} // DialectWriters list of differnt writers. DialectWriters = []schema.DialectWriter{&mysqlWriter{}} )
var ( // ErrNotDate an error for trying to corece/convert to Time a field that is not a time. ErrNotDate = errors.New("Unable to conver to time value") )
var ( // IntrospectCount is default number of rows to evaluate for introspection // based schema discovery. IntrospectCount = 20 )
Functions ¶
func IntrospectSchema ¶
IntrospectSchema discover schema from contents of row introspection.
func IntrospectTable ¶
IntrospectTable accepts a table and schema Iterator and will read a representative sample of rows, introspecting the results to create a schema. Generally used for CSV, Json files to create strongly typed schemas.
func KeyFromWhere ¶
Given a Where expression, lets try to create a key which
requires form `idenity = "value"`
func MessageConversion ¶
func MysqlValueString ¶
func NewMySqlSessionVars ¶
func NewMySqlSessionVars() expr.ContextReadWriter
func NewNamespacedContextReader ¶
func NewNamespacedContextReader(basereader expr.ContextReader, namespace string) expr.ContextReader
NewNestedContextReader provides a context reader which prefixes all keys with a name space. This is useful if you have overlapping field names between ContextReaders within a NestedContextReader.
msg.Get("foo.key")
func NewNestedContextReadWriter ¶
func NewNestedContextReadWriter(readers []expr.ContextReader, writer expr.ContextWriter, ts time.Time) expr.ContextReadWriter
NewNestedContextReader provides a context reader which is a composite of ordered child readers the first reader with a key will be used
func NewNestedContextReader ¶
func NewNestedContextReader(readers []expr.ContextReader, ts time.Time) expr.ContextReader
NewNestedContextReader provides a context reader which is a composite of ordered child readers the first reader with a key will be used
Types ¶
type ContextSimple ¶
func NewContextMap ¶
func NewContextMap(data map[string]interface{}, namespacing bool) *ContextSimple
func NewContextMapTs ¶
func NewContextMapTs(data map[string]interface{}, namespacing bool, ts time.Time) *ContextSimple
func NewContextSimple ¶
func NewContextSimple() *ContextSimple
func NewContextSimpleData ¶
func NewContextSimpleData(data map[string]value.Value) *ContextSimple
func NewContextSimpleNative ¶
func NewContextSimpleNative(data map[string]interface{}) *ContextSimple
func NewContextSimpleTs ¶
func NewMySqlGlobalVars ¶
func NewMySqlGlobalVars() *ContextSimple
func (*ContextSimple) Body ¶
func (m *ContextSimple) Body() interface{}
func (*ContextSimple) Commit ¶
func (m *ContextSimple) Commit(rowInfo []expr.SchemaInfo, row expr.RowWriter) error
func (*ContextSimple) Id ¶
func (m *ContextSimple) Id() uint64
func (*ContextSimple) Put ¶
func (m *ContextSimple) Put(col expr.SchemaInfo, rctx expr.ContextReader, v value.Value) error
func (*ContextSimple) SupportNamespacing ¶
func (m *ContextSimple) SupportNamespacing()
func (*ContextSimple) Ts ¶
func (m *ContextSimple) Ts() time.Time
type ContextUrlValues ¶
func NewContextUrlValues ¶
func NewContextUrlValues(uv url.Values) *ContextUrlValues
func NewContextUrlValuesTs ¶
func NewContextUrlValuesTs(uv url.Values, ts time.Time) *ContextUrlValues
func (*ContextUrlValues) Body ¶
func (m *ContextUrlValues) Body() interface{}
func (*ContextUrlValues) Delete ¶
func (m *ContextUrlValues) Delete(delRow map[string]value.Value) error
func (*ContextUrlValues) Id ¶
func (m *ContextUrlValues) Id() uint64
func (ContextUrlValues) Put ¶
func (m ContextUrlValues) Put(col expr.SchemaInfo, rctx expr.ContextReader, v value.Value) error
func (*ContextUrlValues) String ¶
func (m *ContextUrlValues) String() string
func (ContextUrlValues) Ts ¶
func (m ContextUrlValues) Ts() time.Time
type ContextWrapper ¶
type ContextWrapper struct {
// contains filtered or unexported fields
}
func NewContextWrapper ¶
func NewContextWrapper(val interface{}) *ContextWrapper
func (*ContextWrapper) Ts ¶
func (m *ContextWrapper) Ts() time.Time
type ContextWriterEmpty ¶
type ContextWriterEmpty struct{}
func (*ContextWriterEmpty) Delete ¶
func (m *ContextWriterEmpty) Delete(delRow map[string]value.Value) error
func (*ContextWriterEmpty) Put ¶
func (m *ContextWriterEmpty) Put(col expr.SchemaInfo, rctx expr.ContextReader, v value.Value) error
type CsvDataSource ¶
type CsvDataSource struct {
// contains filtered or unexported fields
}
Csv DataSource, implements qlbridge schema DataSource, SourceConn, Scanner
to allow csv files to be full featured databases. - very, very naive scanner, forward only single pass - can open a file with .Open() - assumes comma delimited - not thread-safe - does not implement write operations
func NewCsvSource ¶
func NewCsvSource(table string, indexCol int, ior io.Reader, exit <-chan bool) (*CsvDataSource, error)
NewCsvSource reader assumes we are getting first row as headers - optionally may be gzipped
func (*CsvDataSource) Close ¶
func (m *CsvDataSource) Close() error
func (*CsvDataSource) Columns ¶
func (m *CsvDataSource) Columns() []string
func (*CsvDataSource) Init ¶
func (m *CsvDataSource) Init()
func (*CsvDataSource) Next ¶
func (m *CsvDataSource) Next() schema.Message
func (*CsvDataSource) Table ¶
func (m *CsvDataSource) Table(tableName string) (*schema.Table, error)
func (*CsvDataSource) Tables ¶
func (m *CsvDataSource) Tables() []string
type JsonHelperScannable ¶
type JsonHelperScannable u.JsonHelper
JsonHelperScannable expects map json's (not array) map[string]interface
func (*JsonHelperScannable) MarshalJSON ¶
func (m *JsonHelperScannable) MarshalJSON() ([]byte, error)
func (*JsonHelperScannable) Scan ¶
func (m *JsonHelperScannable) Scan(src interface{}) error
Scan the database/sql interface for scanning sql byte vals into this typed structure.
func (*JsonHelperScannable) UnmarshalJSON ¶
func (m *JsonHelperScannable) UnmarshalJSON(data []byte) error
UnmarshalJSON bytes into this typed struct
type JsonSource ¶
type JsonSource struct {
// contains filtered or unexported fields
}
JsonSource implements qlbridge schema DataSource, SourceConn, Scanner to allow new line delimited json files to be full featured databases. - very, very naive scanner, forward only single pass - can open a file with .Open() - not thread-safe - does not implement write operations
func NewJsonSource ¶
func NewJsonSource(table string, rc io.ReadCloser, exit <-chan bool, lh FileLineHandler) (*JsonSource, error)
NewJsonSource reader assumes we are getting NEW LINE delimted json file - optionally may be gzipped
func (*JsonSource) Close ¶
func (m *JsonSource) Close() error
func (*JsonSource) Columns ¶
func (m *JsonSource) Columns() []string
func (*JsonSource) CreateIterator ¶
func (m *JsonSource) CreateIterator() schema.Iterator
func (*JsonSource) Init ¶
func (m *JsonSource) Init()
func (*JsonSource) Next ¶
func (m *JsonSource) Next() schema.Message
func (*JsonSource) Tables ¶
func (m *JsonSource) Tables() []string
type JsonWrapper ¶
type JsonWrapper json.RawMessage
JsonWrapper json data
func (*JsonWrapper) MarshalJSON ¶
func (m *JsonWrapper) MarshalJSON() ([]byte, error)
func (*JsonWrapper) Scan ¶
func (m *JsonWrapper) Scan(src interface{}) error
func (*JsonWrapper) Unmarshal ¶
func (m *JsonWrapper) Unmarshal(v interface{}) error
func (*JsonWrapper) UnmarshalJSON ¶
func (m *JsonWrapper) UnmarshalJSON(data []byte) error
UnmarshalJSON bytes into this typed struct
type MessageArray ¶
type MessageArray struct { Idv uint64 Items []*SqlDriverMessageMap }
func (*MessageArray) Body ¶
func (m *MessageArray) Body() interface{}
func (*MessageArray) Id ¶
func (m *MessageArray) Id() uint64
type NamespacedContextReader ¶
type NamespacedContextReader struct {
// contains filtered or unexported fields
}
func (*NamespacedContextReader) Get ¶
func (n *NamespacedContextReader) Get(key string) (value.Value, bool)
func (*NamespacedContextReader) Row ¶
func (n *NamespacedContextReader) Row() map[string]value.Value
func (*NamespacedContextReader) Ts ¶
func (n *NamespacedContextReader) Ts() time.Time
type NestedContextReader ¶
type NestedContextReader struct {
// contains filtered or unexported fields
}
func (*NestedContextReader) Delete ¶
func (n *NestedContextReader) Delete(delRow map[string]value.Value) error
func (*NestedContextReader) Put ¶
func (n *NestedContextReader) Put(col expr.SchemaInfo, readCtx expr.ContextReader, v value.Value) error
func (*NestedContextReader) Ts ¶
func (n *NestedContextReader) Ts() time.Time
type SchemaDb ¶
type SchemaDb struct {
// contains filtered or unexported fields
}
SchemaDb Static Schema Source, implements qlbridge DataSource to allow in-memory native go data to have a Schema and implement and be operated on by Sql Operations.
func NewSchemaDb ¶
NewSchemaDb create new db for storing schema.
type SchemaSource ¶
type SchemaSource struct {
// contains filtered or unexported fields
}
SchemaSource type for the schemadb connection (thread-safe).
func (*SchemaSource) Close ¶
func (m *SchemaSource) Close() error
func (*SchemaSource) Columns ¶
func (m *SchemaSource) Columns() []string
func (*SchemaSource) Next ¶
func (m *SchemaSource) Next() schema.Message
func (*SchemaSource) SetContext ¶
func (m *SchemaSource) SetContext(ctx *plan.Context)
SetContext set the plan context
func (*SchemaSource) SetRows ¶
func (m *SchemaSource) SetRows(rows [][]driver.Value)
type SqlDriverMessage ¶
func NewSqlDriverMessage ¶
func NewSqlDriverMessage(id uint64, row []driver.Value) *SqlDriverMessage
func (*SqlDriverMessage) Body ¶
func (m *SqlDriverMessage) Body() interface{}
func (*SqlDriverMessage) Id ¶
func (m *SqlDriverMessage) Id() uint64
func (*SqlDriverMessage) ToMsgMap ¶
func (m *SqlDriverMessage) ToMsgMap(colidx map[string]int) *SqlDriverMessageMap
type SqlDriverMessageMap ¶
type SqlDriverMessageMap struct { Vals []driver.Value // Values ColIndex map[string]int // Map of column names to ordinal position in vals IdVal uint64 // id() // contains filtered or unexported fields }
func NewSqlDriverMessageMap ¶
func NewSqlDriverMessageMapCtx ¶
func NewSqlDriverMessageMapCtx(id uint64, ctx expr.ContextReader, colindex map[string]int) *SqlDriverMessageMap
func NewSqlDriverMessageMapEmpty ¶
func NewSqlDriverMessageMapEmpty() *SqlDriverMessageMap
func NewSqlDriverMessageMapVals ¶
func NewSqlDriverMessageMapVals(id uint64, row []driver.Value, cols []string) *SqlDriverMessageMap
func (*SqlDriverMessageMap) Body ¶
func (m *SqlDriverMessageMap) Body() interface{}
func (*SqlDriverMessageMap) Copy ¶
func (m *SqlDriverMessageMap) Copy() *SqlDriverMessageMap
func (*SqlDriverMessageMap) Id ¶
func (m *SqlDriverMessageMap) Id() uint64
func (*SqlDriverMessageMap) Key ¶
func (m *SqlDriverMessageMap) Key() string
func (*SqlDriverMessageMap) SetKey ¶
func (m *SqlDriverMessageMap) SetKey(key string)
func (*SqlDriverMessageMap) SetKeyHashed ¶
func (m *SqlDriverMessageMap) SetKeyHashed(key string)
func (*SqlDriverMessageMap) SetRow ¶
func (m *SqlDriverMessageMap) SetRow(row []driver.Value)
func (*SqlDriverMessageMap) Ts ¶
func (m *SqlDriverMessageMap) Ts() time.Time
func (*SqlDriverMessageMap) Values ¶
func (m *SqlDriverMessageMap) Values() []driver.Value
type StringArray ¶
type StringArray []string
StringArray Convert json to array of strings
func (*StringArray) MarshalJSON ¶
func (m *StringArray) MarshalJSON() ([]byte, error)
func (*StringArray) Scan ¶
func (m *StringArray) Scan(src interface{}) error
Scan the database/sql interface for scanning sql byte vals into this typed structure.
func (*StringArray) UnmarshalJSON ¶
func (m *StringArray) UnmarshalJSON(data []byte) error
type TimeValue ¶
TimeValue Convert a string/bytes to time.Time by parsing the string with a wide variety of different date formats that are supported in http://godoc.org/github.com/araddon/dateparse
func (*TimeValue) MarshalJSON ¶
func (*TimeValue) UnmarshalJSON ¶
type UrlValuesMsg ¶
type UrlValuesMsg struct {
// contains filtered or unexported fields
}
func NewUrlValuesMsg ¶
func NewUrlValuesMsg(id uint64, body *ContextUrlValues) *UrlValuesMsg
func (*UrlValuesMsg) Body ¶
func (m *UrlValuesMsg) Body() interface{}
func (*UrlValuesMsg) Id ¶
func (m *UrlValuesMsg) Id() uint64
func (*UrlValuesMsg) String ¶
func (m *UrlValuesMsg) String() string
type ValueContextWrapper ¶
type ValueContextWrapper struct { *SqlDriverMessage // contains filtered or unexported fields }
func NewValueContextWrapper ¶
func NewValueContextWrapper(msg *SqlDriverMessage, cols map[string]*rel.Column) *ValueContextWrapper
func (*ValueContextWrapper) Ts ¶
func (m *ValueContextWrapper) Ts() time.Time
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package files is a cloud (gcs, s3) and local file datasource that translates json, csv, files into appropriate interface for qlbridge DataSource so we can run queries.
|
Package files is a cloud (gcs, s3) and local file datasource that translates json, csv, files into appropriate interface for qlbridge DataSource so we can run queries. |
Membtree implements a Datasource in-memory implemenation using the google btree.
|
Membtree implements a Datasource in-memory implemenation using the google btree. |
Memdb package implements a Qlbridge Datasource in-memory implemenation using the hashicorp go-memdb (immuteable radix tree's).
|
Memdb package implements a Qlbridge Datasource in-memory implemenation using the hashicorp go-memdb (immuteable radix tree's). |
Mockcsv implements an in-memory csv data source for testing usage implemented by wrapping the mem-b-tree.
|
Mockcsv implements an in-memory csv data source for testing usage implemented by wrapping the mem-b-tree. |
Package mockcsvtestdata is csv test data only used for tests.
|
Package mockcsvtestdata is csv test data only used for tests. |