mongo

package
v0.0.0-...-a18f44e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2016 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListenerType = "mongo"
)

Variables

View Source
var (
	DefaultLimit = 20
)

Functions

func NewMongoDataSource

func NewMongoDataSource() schema.Source

Types

type MongoDataSource

type MongoDataSource struct {
	// contains filtered or unexported fields
}

Mongo Data Source implements qlbridge DataSource interfaces to mongo server

  • singleton shared across all sessions/connections
  • creates connections by mgo.Session.Clone()

func (*MongoDataSource) Close

func (m *MongoDataSource) Close() error

func (*MongoDataSource) DataSource

func (m *MongoDataSource) DataSource() schema.Source

func (*MongoDataSource) Open

func (m *MongoDataSource) Open(collectionName string) (schema.Conn, error)

func (*MongoDataSource) Setup

func (m *MongoDataSource) Setup(ss *schema.SchemaSource) error

func (*MongoDataSource) Table

func (m *MongoDataSource) Table(table string) (*schema.Table, error)

func (*MongoDataSource) Tables

func (m *MongoDataSource) Tables() []string

type ResultReader

type ResultReader struct {
	*exec.TaskBase

	Docs     []u.JsonHelper
	Vals     [][]driver.Value
	Total    int
	Aggs     u.JsonHelper
	ScrollId string
	// contains filtered or unexported fields
}

Mongo ResultReader implements result paging, reading - driver.Rows

func NewResultReader

func NewResultReader(req *SqlToMgo, q *mgo.Query, limit int) *ResultReader

func (*ResultReader) Close

func (m *ResultReader) Close() error

func (*ResultReader) Run

func (m *ResultReader) Run() error

type ResultReaderNext

type ResultReaderNext struct {
	*ResultReader
}

A wrapper, allowing us to implement sql/driver Next() interface

which is different than qlbridge/datasource Next()

type SqlToMgo

type SqlToMgo struct {
	*exec.TaskBase
	// contains filtered or unexported fields
}

SqlToMgo Rewrite a Sql AST statement to a Mongo request

  • Walk the AST and see what can be pushed down and what can't
  • try to poly-fill the missing pieces.

func NewSqlToMgo

func NewSqlToMgo(table *schema.Table, sess *mgo.Session) *SqlToMgo

func (*SqlToMgo) Columns

func (m *SqlToMgo) Columns() []string

Columns return list of column names

func (*SqlToMgo) WalkAggs

func (m *SqlToMgo) WalkAggs(cur expr.Node) (q bson.M, _ error)

WalkAggs() aggregate expressions when used ast part of <select_list>

  • For Aggregates (functions) it builds appropriate underlying mongo aggregation/map-reduce
  • For Projections (non-functions) it does nothing, that will be done later during projection

func (*SqlToMgo) WalkExecSource

func (m *SqlToMgo) WalkExecSource(p *plan.Source) (exec.Task, error)

func (*SqlToMgo) WalkGroupBy

func (m *SqlToMgo) WalkGroupBy() error

Group By Clause: Mongo is a little weird where they move the

group by expressions INTO the aggregation clause

operation(field) FROM x GROUP BY x,y,z

db.article.aggregate([{"$group":{_id: "$author", count: {"$sum":1}}}]);

func (*SqlToMgo) WalkNode

func (m *SqlToMgo) WalkNode(cur expr.Node, q *bson.M) (value.Value, error)

Walk() an expression, and its logic to create an appropriately

nested bson document for mongo queries if possible.

- if can't express logic we need to allow qlbridge to poly-fill

func (*SqlToMgo) WalkSelectList

func (m *SqlToMgo) WalkSelectList() error

Aggregations from the <select_list>

SELECT <select_list> FROM ... WHERE

func (*SqlToMgo) WalkSourceSelect

func (m *SqlToMgo) WalkSourceSelect(planner plan.Planner, p *plan.Source) (plan.Task, error)

WalkSourceSelect An interface implemented by this connection allowing the planner to push down as much logic into mongo as possible

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL