esql

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: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGraphDB

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

NewGraphDB creates a new GraphDB graph database interface

func ValidateSchema

func ValidateSchema(schema *Schema) error

ValidateSchema validates a Schema

Types

type Config

type Config struct {
	// the driver-specific data source name, usually consisting of at least
	// a database name and connection information
	DataSourceName string
	// The driver name ("mysql", "postgres", etc)
	Driver string
	// The graph definitions
	Graphs []*Schema
}

Config describes the configuration for the sql driver.

type Edge

type Edge struct {
	Table    string
	GidField string
	Label    string
	From     *ForeignKey
	To       *ForeignKey
}

Edge describes the mapping between two tables. It may also describe a relational table containing edge properties.

type ForeignKey

type ForeignKey struct {
	SourceField string
	DestTable   string
	DestField   string
}

ForeignKey describes a relation to another table

type Graph

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

Graph is the interface to a single graph

func (*Graph) AddEdge

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

AddEdge is not implemented in the SQL driver

func (*Graph) AddVertex

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

AddVertex is not implemented in the SQL driver

func (*Graph) AddVertexIndex

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

AddVertexIndex add index to vertices

func (*Graph) BulkAdd

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

func (*Graph) Compiler

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

Compiler returns a query compiler that uses the graph

func (*Graph) DelEdge

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

DelEdge is not implemented in the SQL driver

func (*Graph) DelVertex

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

DelVertex is not implemented in the SQL driver

func (*Graph) DeleteVertexIndex

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

DeleteVertexIndex delete index from vertices

func (*Graph) GetEdge

func (g *Graph) GetEdge(key string, load bool) *gdbi.Edge

GetEdge loads an edge given an id. It returns nil if not found Keys are expected to be of the form: <table>:<primary_key>

func (*Graph) GetEdgeList

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

GetEdgeList produces a channel of all edges in the graph

func (*Graph) GetInChannel

func (g *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 (g *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 (g *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 (g *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 (g *Graph) GetTimestamp() string

GetTimestamp gets the timestamp of last update

func (*Graph) GetVertex

func (g *Graph) GetVertex(key string, load bool) *gdbi.Vertex

GetVertex loads a vertex given an id. It returns a nil if not found. Keys are expected to be of the form: <table>:<primary_key>

func (*Graph) GetVertexChannel

func (g *Graph) GetVertexChannel(ctx context.Context, reqChan 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 (g *Graph) GetVertexIndexList() <-chan *gripql.IndexID

GetVertexIndexList lists indices

func (*Graph) GetVertexList

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

GetVertexList produces a channel of all vertices in the graph

func (*Graph) ListEdgeLabels

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

ListEdgeLabels returns a list of edge types in the graph

func (*Graph) ListVertexLabels

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

ListVertexLabels returns a list of vertex types in the graph

func (*Graph) VertexLabelScan

func (g *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 manages graphs in the database

func (*GraphDB) AddGraph

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

AddGraph creates a new graph named `graph`

func (*GraphDB) BuildSchema

func (db *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 (db *GraphDB) Close() error

Close the connection

func (*GraphDB) DeleteGraph

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

DeleteGraph deletes an existing graph named `graph`

func (*GraphDB) Graph

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

Graph obtains the gdbi.DBI for a particular graph

func (*GraphDB) ListGraphs

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

ListGraphs lists the graphs managed by this driver

type Schema

type Schema struct {
	Graph    string
	Vertices []*Vertex
	Edges    []*Edge
}

Schema describes the mapping of tables to the graph.

func (*Schema) GetEdge

func (s *Schema) GetEdge(table string) *Edge

GetEdge searches for an Edge schema entry by table name

func (*Schema) GetEdgeFrom

func (s *Schema) GetEdgeFrom(table string) *ForeignKey

GetEdgeFrom finds the Edge schema for the given table and returns the ForeignKey instance in From

func (*Schema) GetEdgeGid

func (s *Schema) GetEdgeGid(table string) string

GetEdgeGid finds the Edge schema for the given table and returns the GidField

func (*Schema) GetEdgeLabel

func (s *Schema) GetEdgeLabel(table string) string

GetEdgeLabel finds the Edge schema for the given table and returns the Label

func (*Schema) GetEdgeTables

func (s *Schema) GetEdgeTables(label string) []string

GetEdgeTables searches for Edge schema with the provided label and returns an array of table names for those edges

func (*Schema) GetEdgeTo

func (s *Schema) GetEdgeTo(table string) *ForeignKey

GetEdgeTo finds the Edge schema for the given table and returns the ForeignKey instance in To

func (*Schema) GetIncomingEdges

func (s *Schema) GetIncomingEdges(table string, labels []string) []*Edge

GetIncomingEdges returns all Edge schema with To.DestTable matching 'table'. If one or more labels are provided only those Edges with those labels will be returned.

func (*Schema) GetOutgoingEdges

func (s *Schema) GetOutgoingEdges(table string, labels []string) []*Edge

GetOutgoingEdges returns all Edge schema with From.DestTable matching 'table' If one or more labels are provided only those Edges with those labels will be returned.

func (*Schema) GetVertex

func (s *Schema) GetVertex(table string) *Vertex

GetVertex searches for a Vertex schema entry by table name

func (*Schema) GetVertexGid

func (s *Schema) GetVertexGid(table string) string

GetVertexGid finds the Vertex schema for the given table and returns the GidField

func (*Schema) GetVertexLabel

func (s *Schema) GetVertexLabel(table string) string

GetVertexLabel finds the Vertex schema for the given table and returns the Label

func (*Schema) GetVertexTables

func (s *Schema) GetVertexTables(label string) []string

GetVertexTables searches for Vertex schema with the provided label and returns an array of table names for those vertices

type Vertex

type Vertex struct {
	Table    string
	GidField string
	Label    string
}

Vertex describes the mapping of a table to the graph

Jump to

Keyboard shortcuts

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