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 are individual database/source types, a few of which are implemented here (test, csv) and 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 OpenConn(sourceName, sourceConfig string) (schema.Conn, error)
- func Register(sourceName string, source schema.Source)
- func RowsForSession(ctx *plan.Context) [][]driver.Value
- func SourceIterChannel(iter schema.Iterator, sigCh <-chan bool) <-chan schema.Message
- type 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) 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) CreateIterator() schema.Iterator
- func (m *CsvDataSource) MesgChan() <-chan schema.Message
- func (m *CsvDataSource) Next() schema.Message
- func (m *CsvDataSource) Open(connInfo string) (schema.Conn, error)
- func (m *CsvDataSource) Table(tableName string) (*schema.Table, error)
- func (m *CsvDataSource) Tables() []string
- type JsonHelperScannable
- 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 Registry
- func (m *Registry) Conn(db string) schema.Conn
- func (m *Registry) DataSource(connInfo string) schema.Source
- func (m *Registry) Get(sourceName string) schema.Source
- func (m *Registry) Schema(schemaName string) (*schema.Schema, bool)
- func (m *Registry) SchemaAdd(s *schema.Schema)
- func (m *Registry) SourceSchemaAdd(ss *schema.SchemaSource) error
- func (m *Registry) String() string
- func (m *Registry) Tables() []string
- type SchemaDb
- 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 StaticSource
- func (m *StaticSource) Close() error
- func (m *StaticSource) Columns() []string
- func (m *StaticSource) CreateIterator() schema.Iterator
- func (m *StaticSource) MesgChan() <-chan schema.Message
- func (m *StaticSource) Next() schema.Message
- func (m *StaticSource) Open(_ string) (schema.Conn, error)
- func (m *StaticSource) Tables() []string
- type StringArray
- type TimeValue
- type UrlValuesMsg
- type ValueContextWrapper
Constants ¶
const (
// Default Max Allowed packets for connections
MaxAllowedPacket = 4194304
)
const (
SchemaDbSourceType = "schemadb"
)
Variables ¶
var ( DialectWriterCols = []string{"mysql"} DialectWriters = []schema.DialectWriter{&mysqlWriter{}} )
var ( // If disableRecover=true, we will not capture/suppress panics // Test only feature hopefully DisableRecover bool )
var (
IntrospectCount = 20
)
Functions ¶
func IntrospectSchema ¶
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.
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 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) 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)
Csv reader assumes we are getting first row as headers
func (*CsvDataSource) Close ¶
func (m *CsvDataSource) Close() error
func (*CsvDataSource) Columns ¶
func (m *CsvDataSource) Columns() []string
func (*CsvDataSource) CreateIterator ¶
func (m *CsvDataSource) CreateIterator() schema.Iterator
func (*CsvDataSource) MesgChan ¶
func (m *CsvDataSource) MesgChan() <-chan schema.Message
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
json Helper expects map[string]interface
func (*JsonHelperScannable) MarshalJSON ¶
func (m *JsonHelperScannable) MarshalJSON() ([]byte, error)
func (*JsonHelperScannable) Scan ¶
func (m *JsonHelperScannable) Scan(src interface{}) error
func (*JsonHelperScannable) UnmarshalJSON ¶
func (m *JsonHelperScannable) UnmarshalJSON(data []byte) error
Unmarshall bytes into this typed struct
type JsonWrapper ¶
type JsonWrapper json.RawMessage
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
Unmarshall 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 Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Our internal map of different types of datasources that are registered for our runtime system to use
func DataSourcesRegistry ¶
func DataSourcesRegistry() *Registry
get registry of all datasource types
func (*Registry) DataSource ¶
given connection info, get datasource
@connInfo = csv:///dev/stdin mockcsv
func (*Registry) Schema ¶
Get schema for given source
@schemaName = virtual database name made up of multiple backend-sources
func (*Registry) SourceSchemaAdd ¶
func (m *Registry) SourceSchemaAdd(ss *schema.SchemaSource) error
Add a new SourceSchema to a schema which will be created if it doesn't exist
type SchemaDb ¶
type SchemaDb struct {
// contains filtered or unexported fields
}
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 ¶
type SchemaSource ¶
type SchemaSource struct {
// contains filtered or unexported fields
}
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)
func (*SchemaSource) SetRows ¶
func (m *SchemaSource) SetRows(rows [][]driver.Value)
type 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 row 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 StaticSource ¶
type StaticSource struct {
// contains filtered or unexported fields
}
A static, non-thread safe, single-table data source
func NewStaticSource ¶
func NewStaticSource(name string, cols []string, msgs []schema.Message) *StaticSource
func (*StaticSource) Close ¶
func (m *StaticSource) Close() error
func (*StaticSource) Columns ¶
func (m *StaticSource) Columns() []string
func (*StaticSource) CreateIterator ¶
func (m *StaticSource) CreateIterator() schema.Iterator
func (*StaticSource) MesgChan ¶
func (m *StaticSource) MesgChan() <-chan schema.Message
func (*StaticSource) Next ¶
func (m *StaticSource) Next() schema.Message
func (*StaticSource) Tables ¶
func (m *StaticSource) Tables() []string
type StringArray ¶
type StringArray []string
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
func (*StringArray) UnmarshalJSON ¶
func (m *StringArray) UnmarshalJSON(data []byte) error
type TimeValue ¶
Convert string/bytes to time.Time
auto-parses a 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