mongo

package
v0.0.0-...-fa720cf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMongoGraph

func AddMongoGraph(client *mgo.Client, database string, graph string) error

func GetEdgeCollection

func GetEdgeCollection(session *mgo.Client, database string, graph string) *mgo.Collection

func GetVertexCollection

func GetVertexCollection(session *mgo.Client, database string, graph string) *mgo.Collection

func NewCompiler

func NewCompiler(db *Graph) gdbi.Compiler

NewCompiler creates a new compiler that runs using the provided GraphInterface

func NewGraphDB

func NewGraphDB(conf Config) (gdbi.GraphDB, error)

NewGraphDB creates a new mongo graph database interface

func PackEdge

func PackEdge(e *gdbi.Edge) map[string]interface{}

PackEdge takes a GRIP edge and converts it to a mongo doc

func PackVertex

func PackVertex(v *gdbi.Vertex) map[string]interface{}

PackVertex take a GRIP vertex and convert it to a mongo doc

func UnpackEdge

func UnpackEdge(i map[string]interface{}) *gdbi.Edge

UnpackEdge takes a mongo doc and convertes it into an gripql.Edge

func UnpackVertex

func UnpackVertex(i map[string]interface{}) *gdbi.Vertex

UnpackVertex takes a mongo doc and converts it into an gripql.Vertex

Types

type Compiler

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

Compiler is a mongo specific compiler that works with default graph interface

func (*Compiler) Compile

func (comp *Compiler) Compile(stmts []*gripql.GraphStatement, opts *gdbi.CompileOptions) (gdbi.Pipeline, error)

Compile compiles a set of graph traversal statements into a mongo aggregation pipeline

type Config

type Config struct {
	URL             string
	DBName          string
	Username        string
	Password        string
	BatchSize       int
	UseCorePipeline bool
}

Config describes the configuration for the mongodb driver.

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type Graph

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

Graph is the interface to a single graph

func (*Graph) AddEdge

func (mg *Graph) AddEdge(edges []*gdbi.Edge) error

AddEdge adds an edge to the graph, if it already exists in the graph, it is replaced

func (*Graph) AddVertex

func (mg *Graph) AddVertex(vertices []*gdbi.Vertex) error

AddVertex adds an edge to the graph, if it already exists in the graph, it is replaced

func (*Graph) AddVertexIndex

func (mg *Graph) AddVertexIndex(label string, field string) error

AddVertexIndex add index to vertices

func (*Graph) BulkAdd

func (mg *Graph) BulkAdd(stream <-chan *gdbi.GraphElement) error

func (*Graph) Compiler

func (mg *Graph) Compiler() gdbi.Compiler

Compiler returns a query compiler that uses the graph

func (*Graph) DelEdge

func (mg *Graph) DelEdge(key string) error

DelEdge deletes edge with id `key`

func (*Graph) DelVertex

func (mg *Graph) DelVertex(key string) error

DelVertex deletes vertex with id `key`

func (*Graph) DeleteVertexIndex

func (mg *Graph) DeleteVertexIndex(label string, field string) error

DeleteVertexIndex delete index from vertices

func (*Graph) GetEdge

func (mg *Graph) GetEdge(id string, load bool) *gdbi.Edge

GetEdge loads an edge given an id. It returns nil if not found

func (*Graph) GetEdgeList

func (mg *Graph) GetEdgeList(ctx context.Context, loadProp bool) <-chan *gdbi.Edge

GetEdgeList produces a channel of all edges in the graph

func (*Graph) GetInChannel

func (mg *Graph) GetInChannel(ctx context.Context, reqChan chan gdbi.ElementLookup, load bool, emitNull bool, edgeLabels []string) chan gdbi.ElementLookup

GetInChannel process requests of vertex ids and find the connected vertices on incoming edges

func (*Graph) GetInEdgeChannel

func (mg *Graph) GetInEdgeChannel(ctx context.Context, reqChan chan gdbi.ElementLookup, load bool, emitNull bool, edgeLabels []string) chan gdbi.ElementLookup

GetInEdgeChannel process requests of vertex ids and find the connected incoming edges

func (*Graph) GetOutChannel

func (mg *Graph) GetOutChannel(ctx context.Context, reqChan chan gdbi.ElementLookup, load bool, emitNull bool, edgeLabels []string) chan gdbi.ElementLookup

GetOutChannel process requests of vertex ids and find the connected vertices on outgoing edges

func (*Graph) GetOutEdgeChannel

func (mg *Graph) GetOutEdgeChannel(ctx context.Context, reqChan chan gdbi.ElementLookup, load bool, emitNull bool, edgeLabels []string) chan gdbi.ElementLookup

GetOutEdgeChannel process requests of vertex ids and find the connected outgoing edges

func (*Graph) GetTimestamp

func (mg *Graph) GetTimestamp() string

GetTimestamp gets the timestamp of last update

func (*Graph) GetVertex

func (mg *Graph) GetVertex(id string, load bool) *gdbi.Vertex

GetVertex loads a vertex given an id. It returns a nil if not found

func (*Graph) GetVertexChannel

func (mg *Graph) GetVertexChannel(ctx context.Context, ids chan gdbi.ElementLookup, load bool) chan gdbi.ElementLookup

GetVertexChannel is passed a channel of vertex ids and it produces a channel of vertices

func (*Graph) GetVertexIndexList

func (mg *Graph) GetVertexIndexList() <-chan *gripql.IndexID

GetVertexIndexList lists indices

func (*Graph) GetVertexList

func (mg *Graph) GetVertexList(ctx context.Context, load bool) <-chan *gdbi.Vertex

GetVertexList produces a channel of all vertices in the graph

func (*Graph) ListEdgeLabels

func (mg *Graph) ListEdgeLabels() ([]string, error)

ListEdgeLabels returns a list of edge types in the graph

func (*Graph) ListVertexLabels

func (mg *Graph) ListVertexLabels() ([]string, error)

ListVertexLabels returns a list of vertex types in the graph

func (*Graph) VertexLabelScan

func (mg *Graph) VertexLabelScan(ctx context.Context, label string) chan string

VertexLabelScan produces a channel of all vertex ids where the vertex label matches `label`

type GraphDB

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

GraphDB is the base driver that manages multiple graphs in mongo

func (*GraphDB) AddGraph

func (ma *GraphDB) AddGraph(graph string) error

AddGraph creates a new graph named `graph`

func (*GraphDB) BuildSchema

func (ma *GraphDB) BuildSchema(ctx context.Context, graph string, sampleN uint32, random bool) (*gripql.Graph, error)

BuildSchema returns the schema of a specific graph in the database

func (*GraphDB) Close

func (ma *GraphDB) Close() error

Close the connection

func (*GraphDB) DeleteGraph

func (ma *GraphDB) DeleteGraph(graph string) error

DeleteGraph deletes `graph`

func (*GraphDB) EdgeCollection

func (ma *GraphDB) EdgeCollection(graph string) *mongo.Collection

EdgeCollection returns a *mgo.Collection

func (*GraphDB) Graph

func (ma *GraphDB) Graph(graph string) (gdbi.GraphInterface, error)

Graph obtains the gdbi.DBI for a particular graph

func (*GraphDB) ListGraphs

func (ma *GraphDB) ListGraphs() []string

ListGraphs lists the graphs managed by this driver

func (*GraphDB) VertexCollection

func (ma *GraphDB) VertexCollection(graph string) *mongo.Collection

VertexCollection returns a *mgo.Collection

type Pipeline

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

Pipeline a set of runnable query operations

func (*Pipeline) DataType

func (pipe *Pipeline) DataType() gdbi.DataType

DataType return the datatype

func (*Pipeline) Graph

func (pipe *Pipeline) Graph() gdbi.GraphInterface

Graph gets the graph interface

func (*Pipeline) MarkTypes

func (pipe *Pipeline) MarkTypes() map[string]gdbi.DataType

MarkTypes get the mark types

func (*Pipeline) Processors

func (pipe *Pipeline) Processors() []gdbi.Processor

Processors gets the list of processors

type Processor

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

Processor stores the information for a mongo aggregation pipeline

func (*Processor) Process

func (proc *Processor) Process(ctx context.Context, man gdbi.Manager, in gdbi.InPipe, out gdbi.OutPipe) context.Context

Process runs the mongo aggregation pipeline

Jump to

Keyboard shortcuts

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