knowledge

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrVariableNotFound = errors.New("Unable to find variable")

Functions

func BuildAndOrExpression added in v0.0.6

func BuildAndOrExpression(tree AndOrExpression) (string, error)

func MeasureDuration

func MeasureDuration(Func func()) time.Duration

Types

type AndOrExpression added in v0.0.6

type AndOrExpression struct {
	And        bool // true for And and false for Or
	Children   []AndOrExpression
	Expression string
}

func CrossProductExpressions added in v0.0.6

func CrossProductExpressions(and1 []AndOrExpression, and2 []AndOrExpression) []AndOrExpression

func UnwindOrExpressions added in v0.0.6

func UnwindOrExpressions(tree AndOrExpression) ([]AndOrExpression, error)

UnwindOrExpressions in order to transform query with or relations into a union query which is more performant, an AndOrExpression is transformed into a list of AndExpressions

type Asset

type Asset AssetKey

Asset represent the asset with details

func NewAsset

func NewAsset(assetType schema.AssetType, assetKey string) Asset

NewAsset create a new asset from type and key

type AssetKey

type AssetKey struct {
	Type schema.AssetType `json:"type"`
	Key  string           `json:"key"`
}

AssetKey represent the key of the asset

type AssetWithID

type AssetWithID struct {
	ID    string `json:"_id"`
	Asset `json:",inline"`
}

AssetWithID represent an asset with an ID from the database

func (AssetWithID) String

func (a AssetWithID) String() string

type Cursor

type Cursor interface {
	HasMore() bool
	Read(ctx context.Context, doc interface{}) error
	Close() error
}

Cursor is a cursor over the results

type ExpressionBuilder

type ExpressionBuilder struct {
	QueryGraph *QueryGraph
	// contains filtered or unexported fields
}

func NewExpressionBuilder

func NewExpressionBuilder(queryGraph *QueryGraph) *ExpressionBuilder

func (*ExpressionBuilder) Build added in v0.0.6

type ExpressionParser added in v0.0.6

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

func NewExpressionParser added in v0.0.6

func NewExpressionParser(visitor ExpressionVisitor) *ExpressionParser

func (*ExpressionParser) ParseAddOrSubtractExpression added in v0.0.6

func (ep *ExpressionParser) ParseAddOrSubtractExpression(q *query.QueryAddOrSubtractExpression) error

func (*ExpressionParser) ParseComparisonExpression added in v0.0.6

func (ep *ExpressionParser) ParseComparisonExpression(q *query.QueryComparisonExpression) error

func (*ExpressionParser) ParseExpression added in v0.0.6

func (ep *ExpressionParser) ParseExpression(q *query.QueryExpression) error

func (*ExpressionParser) ParseMultipleDivideModuloExpression added in v0.0.6

func (ep *ExpressionParser) ParseMultipleDivideModuloExpression(q *query.QueryMultipleDivideModuloExpression) error

func (*ExpressionParser) ParseNotExpression added in v0.0.6

func (ep *ExpressionParser) ParseNotExpression(q *query.QueryNotExpression) error

func (*ExpressionParser) ParseOrExpression added in v0.0.6

func (ep *ExpressionParser) ParseOrExpression(q *query.QueryOrExpression) error

func (*ExpressionParser) ParsePowerOfExpression added in v0.0.6

func (ep *ExpressionParser) ParsePowerOfExpression(q *query.QueryPowerOfExpression) error

func (*ExpressionParser) ParsePropertyOrLabelsExpression added in v0.0.6

func (ep *ExpressionParser) ParsePropertyOrLabelsExpression(q *query.QueryPropertyOrLabelsExpression) error

func (*ExpressionParser) ParseStringListNullOperatorExpression added in v0.0.6

func (ep *ExpressionParser) ParseStringListNullOperatorExpression(q *query.QueryStringListNullOperatorExpression) error

func (*ExpressionParser) ParseUnaryAddOrSubtractExpression added in v0.0.6

func (ep *ExpressionParser) ParseUnaryAddOrSubtractExpression(q *query.QueryUnaryAddOrSubtractExpression) error

func (*ExpressionParser) ParseXorExpression added in v0.0.6

func (ep *ExpressionParser) ParseXorExpression(q *query.QueryXorExpression) error

type ExpressionType

type ExpressionType int
const (
	NodeExprType     ExpressionType = iota
	EdgeExprType     ExpressionType = iota
	PropertyExprType ExpressionType = iota
)

type ExpressionVisitor added in v0.0.6

type ExpressionVisitor interface {
	OnEnterPropertyOrLabelsExpression(e query.QueryPropertyOrLabelsExpression) error
	OnExitPropertyOrLabelsExpression(e query.QueryPropertyOrLabelsExpression) error

	OnEnterStringListNullOperatorExpression(e query.QueryStringListNullOperatorExpression) error
	OnExitStringListNullOperatorExpression(e query.QueryStringListNullOperatorExpression) error

	OnVariable(name string) error
	OnVariablePropertiesPath(propertiesPath []string) error

	OnStringLiteral(value string) error
	OnDoubleLiteral(value float64) error
	OnIntegerLiteral(value int64) error
	OnBooleanLiteral(value bool) error

	OnEnterFunctionInvocation(name string) error
	OnExitFunctionInvocation(name string) error

	OnEnterParenthesizedExpression() error
	OnExitParenthesizedExpression() error

	OnStringOperator(operator query.StringOperator) error

	OnEnterUnaryExpression() error
	OnExitUnaryExpression() error

	OnEnterPowerOfExpression() error
	OnExitPowerOfExpression() error

	OnEnterMultipleDivideModuloExpression() error
	OnExitMultipleDivideModuloExpression() error
	OnMultiplyDivideModuloOperator(operator query.MultiplyDivideModuloOperator) error

	OnEnterAddOrSubtractExpression() error
	OnExitAddOrSubtractExpression() error
	OnAddOrSubtractOperator(operator query.AddOrSubtractOperator) error

	OnEnterComparisonExpression() error
	OnExitComparisonExpression() error
	OnComparisonOperator(operator query.ComparisonOperator) error

	OnEnterNotExpression(not bool) error
	OnExitNotExpression(not bool) error

	OnEnterAndExpression() error
	OnExitAndExpression() error

	OnEnterXorExpression() error
	OnExitXorExpression() error

	OnEnterOrExpression() error
	OnExitOrExpression() error

	OnEnterExpression() error
	OnExitExpression() error
}

type ExpressionVisitorBase added in v0.0.6

type ExpressionVisitorBase struct{}

func (*ExpressionVisitorBase) OnAddOrSubtractOperator added in v0.0.6

func (evb *ExpressionVisitorBase) OnAddOrSubtractOperator(operator query.AddOrSubtractOperator) error

func (*ExpressionVisitorBase) OnBooleanLiteral added in v0.0.6

func (evb *ExpressionVisitorBase) OnBooleanLiteral(value bool) error

func (*ExpressionVisitorBase) OnComparisonOperator added in v0.0.6

func (evb *ExpressionVisitorBase) OnComparisonOperator(operator query.ComparisonOperator) error

func (*ExpressionVisitorBase) OnDoubleLiteral added in v0.0.6

func (evb *ExpressionVisitorBase) OnDoubleLiteral(value float64) error

func (*ExpressionVisitorBase) OnEnterAddOrSubtractExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterAddOrSubtractExpression() error

func (*ExpressionVisitorBase) OnEnterAndExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterAndExpression() error

func (*ExpressionVisitorBase) OnEnterComparisonExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterComparisonExpression() error

func (*ExpressionVisitorBase) OnEnterExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterExpression() error

func (*ExpressionVisitorBase) OnEnterFunctionInvocation added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterFunctionInvocation(name string) error

func (*ExpressionVisitorBase) OnEnterMultipleDivideModuloExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterMultipleDivideModuloExpression() error

func (*ExpressionVisitorBase) OnEnterNotExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterNotExpression(not bool) error

func (*ExpressionVisitorBase) OnEnterOrExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterOrExpression() error

func (*ExpressionVisitorBase) OnEnterParenthesizedExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterParenthesizedExpression() error

func (*ExpressionVisitorBase) OnEnterPowerOfExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterPowerOfExpression() error

func (*ExpressionVisitorBase) OnEnterPropertyOrLabelsExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterPropertyOrLabelsExpression(e query.QueryPropertyOrLabelsExpression) error

func (*ExpressionVisitorBase) OnEnterStringListNullOperatorExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterStringListNullOperatorExpression(e query.QueryStringListNullOperatorExpression) error

func (*ExpressionVisitorBase) OnEnterUnaryExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterUnaryExpression() error

func (*ExpressionVisitorBase) OnEnterXorExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnEnterXorExpression() error

func (*ExpressionVisitorBase) OnExitAddOrSubtractExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitAddOrSubtractExpression() error

func (*ExpressionVisitorBase) OnExitAndExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitAndExpression() error

func (*ExpressionVisitorBase) OnExitComparisonExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitComparisonExpression() error

func (*ExpressionVisitorBase) OnExitExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitExpression() error

func (*ExpressionVisitorBase) OnExitFunctionInvocation added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitFunctionInvocation(name string) error

func (*ExpressionVisitorBase) OnExitMultipleDivideModuloExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitMultipleDivideModuloExpression() error

func (*ExpressionVisitorBase) OnExitNotExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitNotExpression(not bool) error

func (*ExpressionVisitorBase) OnExitOrExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitOrExpression() error

func (*ExpressionVisitorBase) OnExitParenthesizedExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitParenthesizedExpression() error

func (*ExpressionVisitorBase) OnExitPowerOfExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitPowerOfExpression() error

func (*ExpressionVisitorBase) OnExitPropertyOrLabelsExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitPropertyOrLabelsExpression(e query.QueryPropertyOrLabelsExpression) error

func (*ExpressionVisitorBase) OnExitStringListNullOperatorExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitStringListNullOperatorExpression(e query.QueryStringListNullOperatorExpression) error

func (*ExpressionVisitorBase) OnExitUnaryExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitUnaryExpression() error

func (*ExpressionVisitorBase) OnExitXorExpression added in v0.0.6

func (evb *ExpressionVisitorBase) OnExitXorExpression() error

func (*ExpressionVisitorBase) OnIntegerLiteral added in v0.0.6

func (evb *ExpressionVisitorBase) OnIntegerLiteral(value int64) error

func (*ExpressionVisitorBase) OnMultiplyDivideModuloOperator added in v0.0.6

func (evb *ExpressionVisitorBase) OnMultiplyDivideModuloOperator(operator query.MultiplyDivideModuloOperator) error

func (*ExpressionVisitorBase) OnStringLiteral added in v0.0.6

func (evb *ExpressionVisitorBase) OnStringLiteral(value string) error

func (*ExpressionVisitorBase) OnStringOperator added in v0.0.6

func (evb *ExpressionVisitorBase) OnStringOperator(operator query.StringOperator) error

func (*ExpressionVisitorBase) OnVariable added in v0.0.6

func (evb *ExpressionVisitorBase) OnVariable(name string) error

func (*ExpressionVisitorBase) OnVariablePropertiesPath added in v0.0.6

func (evb *ExpressionVisitorBase) OnVariablePropertiesPath(propertiesPath []string) error

type Graph

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

Graph represent a Graph

func NewGraph

func NewGraph() *Graph

NewGraph create a graph

func (*Graph) AddAsset

func (g *Graph) AddAsset(assetType schema.AssetType, assetKey string) AssetKey

AddAsset add an asset to the graph

func (*Graph) AddRelation

func (g *Graph) AddRelation(from AssetKey, relationType schema.RelationKeyType, to AssetKey) Relation

AddRelation add a relation to the graph

func (*Graph) Assets

func (g *Graph) Assets() []Asset

Assets return the assets in the graph

func (*Graph) Copy

func (g *Graph) Copy() *Graph

Copy perform a deep copy of the graph

func (*Graph) Equal

func (g *Graph) Equal(other *Graph) bool

Equal return true if graphs are equal, otherwise return false

func (*Graph) ExtractSchema

func (g *Graph) ExtractSchema() schema.SchemaGraph

ExtractSchema extract the schema from the graph

func (*Graph) HasAsset

func (g *Graph) HasAsset(asset Asset) bool

HasAsset return true if the asset is in the graph, false otherwise.

func (*Graph) HasRelation

func (g *Graph) HasRelation(relation Relation) bool

HasRelation return true if the relation is in the graph, false otherwise.

func (*Graph) MarshalJSON

func (g *Graph) MarshalJSON() ([]byte, error)

MarshalJSON marshall the graph in JSON

func (*Graph) Merge

func (g *Graph) Merge(other *Graph)

Merge merge other graph into the current graph

func (*Graph) Relations

func (g *Graph) Relations() []Relation

Relations return the relations in the graph

func (*Graph) UnmarshalJSON

func (g *Graph) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a graph from JSON

type GraphBinder

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

GraphBinder represent a graph builder which bind assets and relations to graph schema provided by the source

func NewGraphBinder

func NewGraphBinder(graph *Graph) *GraphBinder

NewGraphBinder create an instance of graph binder

func (*GraphBinder) Bind

func (gb *GraphBinder) Bind(asset string, assetType schema.AssetType)

Bind bind one asset to a type

func (*GraphBinder) Relate

func (gb *GraphBinder) Relate(from string, relationType schema.RelationType, to string)

Relate relate one asset to another

type GraphDB

type GraphDB interface {
	Close() error

	InitializeSchema() error

	ReadGraph(source string, graph *Graph) error

	// Atomic operations on the graph
	UpsertAsset(source string, asset Asset) error
	UpsertRelation(source string, relation Relation) error
	RemoveAsset(source string, asset Asset) error
	RemoveRelation(source string, relation Relation) error

	FlushAll() error

	CountAssets() (int64, error)
	CountRelations() (int64, error)

	Query(ctx context.Context, query SQLTranslation) (*GraphQueryResult, error)
}

GraphDB an interface to a graph DB such as Arango or neo4j

type GraphJSON

type GraphJSON struct {
	Assets    []Asset    `json:"assets"`
	Relations []Relation `json:"relations"`
}

GraphJSON is the json representation of a graph

type GraphQueryResult

type GraphQueryResult struct {
	Cursor      Cursor
	Projections []Projection
}

GraphQueryResult represent a result from the database with the projection model

type GraphUpdater

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

GraphUpdater represents the updater of graph

func NewGraphUpdater

func NewGraphUpdater(graphDB GraphDB, schemaPersistor schema.Persistor) *GraphUpdater

NewGraphUpdater create a new instance of graph updater

func (*GraphUpdater) RemoveAsset added in v0.0.17

func (sl *GraphUpdater) RemoveAsset(source string, asset Asset) error

RemoveAsset upsert an asset in the graph of the data source

func (*GraphUpdater) RemoveRelation added in v0.0.17

func (sl *GraphUpdater) RemoveRelation(source string, relation Relation) error

RemoveRelation upsert a relation in the graph of the data source

func (*GraphUpdater) UpdateSchema added in v0.0.17

func (sl *GraphUpdater) UpdateSchema(source string, sg schema.SchemaGraph) error

UpdateSchema update the schema for the source with the one provided in the request

func (*GraphUpdater) UpsertAsset added in v0.0.17

func (sl *GraphUpdater) UpsertAsset(source string, asset Asset) error

UpsertAsset upsert an asset in the graph of the data source

func (*GraphUpdater) UpsertRelation added in v0.0.17

func (sl *GraphUpdater) UpsertRelation(source string, relation Relation) error

UpsertRelation upsert a relation in the graph of the data source

type GraphUpdatesBulk

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

GraphUpdatesBulk represent a bulk of asset and relation updates to perform on the graph

func GenerateGraphUpdatesBulk

func GenerateGraphUpdatesBulk(previousGraph *Graph, newGraph *Graph) *GraphUpdatesBulk

GenerateGraphUpdatesBulk generate a graph update bulk by taking the difference between new graph and previous graph. It means the updates would transform previous graph into new graph.

func NewGraphUpdatesBulk

func NewGraphUpdatesBulk() *GraphUpdatesBulk

NewGraphUpdatesBulk create an instance of graph updates

func (*GraphUpdatesBulk) Clear

func (gub *GraphUpdatesBulk) Clear()

Clear the bulk

func (*GraphUpdatesBulk) GetAssetRemovals

func (gub *GraphUpdatesBulk) GetAssetRemovals() []Asset

GetAssetRemovals retrieve all assets to be removed

func (*GraphUpdatesBulk) GetAssetUpserts

func (gub *GraphUpdatesBulk) GetAssetUpserts() []Asset

GetAssetUpserts retrieve the list of all assets to be upsered

func (*GraphUpdatesBulk) GetRelationRemovals

func (gub *GraphUpdatesBulk) GetRelationRemovals() []Relation

GetRelationRemovals retrieve all relations to be removed

func (*GraphUpdatesBulk) GetRelationUpserts

func (gub *GraphUpdatesBulk) GetRelationUpserts() []Relation

GetRelationUpserts retrieve all relations to be upserted

func (*GraphUpdatesBulk) HasAssetRemoval

func (gub *GraphUpdatesBulk) HasAssetRemoval(asset Asset) bool

HasAssetRemoval check whether this asset need to be removed

func (*GraphUpdatesBulk) HasAssetUpsert

func (gub *GraphUpdatesBulk) HasAssetUpsert(asset Asset) bool

HasAssetUpsert check whether asset needs to be upserted

func (*GraphUpdatesBulk) HasRelationRemoval

func (gub *GraphUpdatesBulk) HasRelationRemoval(relation Relation) bool

HasRelationRemoval check whether the bulk contains the removal of this relation

func (*GraphUpdatesBulk) HasRelationUpsert

func (gub *GraphUpdatesBulk) HasRelationUpsert(relation Relation) bool

HasRelationUpsert check whether the relation needs to be upserted

func (*GraphUpdatesBulk) MarshalJSON

func (gub *GraphUpdatesBulk) MarshalJSON() ([]byte, error)

MarshalJSON marshal a graph update bulk

func (*GraphUpdatesBulk) RemoveAsset

func (gub *GraphUpdatesBulk) RemoveAsset(asset Asset)

RemoveAsset create an operation to remove an asset

func (*GraphUpdatesBulk) RemoveAssets

func (gub *GraphUpdatesBulk) RemoveAssets(assets ...Asset)

RemoveAssets create multiple asset removal operations

func (*GraphUpdatesBulk) RemoveRelation

func (gub *GraphUpdatesBulk) RemoveRelation(relation Relation)

RemoveRelation create an operation to remove a relation

func (*GraphUpdatesBulk) RemoveRelations

func (gub *GraphUpdatesBulk) RemoveRelations(relations ...Relation)

RemoveRelations create multiple relation removal operations

func (*GraphUpdatesBulk) UnmarshalJSON

func (gub *GraphUpdatesBulk) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshal a graph updates bulk

func (*GraphUpdatesBulk) UpsertAsset

func (gub *GraphUpdatesBulk) UpsertAsset(asset Asset)

UpsertAsset create an operation to upsert an asset

func (*GraphUpdatesBulk) UpsertAssets

func (gub *GraphUpdatesBulk) UpsertAssets(assets ...Asset)

UpsertAssets append multiple assets to upsert

func (*GraphUpdatesBulk) UpsertRelation

func (gub *GraphUpdatesBulk) UpsertRelation(relation Relation)

UpsertRelation create an operation to upsert an relation

func (*GraphUpdatesBulk) UpsertRelations

func (gub *GraphUpdatesBulk) UpsertRelations(relations ...Relation)

UpsertRelations create multiple relation upsert operations

type GraphUpdatesBulkJSON

type GraphUpdatesBulkJSON struct {
	AssetUpserts     []Asset    `json:"asset_upserts"`
	AssetRemovals    []Asset    `json:"asset_removals"`
	RelationUpserts  []Relation `json:"relation_upserts"`
	RelationRemovals []Relation `json:"relation_removals"`
}

GraphUpdatesBulkJSON represent a bulk in JSON form

type GraphUpdatesQueue added in v0.0.17

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

GraphUpdatesQueue represent a graph updates queue with

func NewGraphUpdatesQueue added in v0.0.17

func NewGraphUpdatesQueue(length int) *GraphUpdatesQueue

NewGraphUpdatesQueue create a new instance of updates queue

func (*GraphUpdatesQueue) Dequeue added in v0.0.17

func (guq *GraphUpdatesQueue) Dequeue() (*SourceSubGraphUpdates, error)

Dequeue an item from the queue

func (*GraphUpdatesQueue) Dispose added in v0.0.17

func (guq *GraphUpdatesQueue) Dispose()

Dispose will dispose of this queue. Any subsequent calls to Get or Put will return an error.

func (*GraphUpdatesQueue) Enqueue added in v0.0.17

func (guq *GraphUpdatesQueue) Enqueue(update SourceSubGraphUpdates) error

Enqueue an item into the queue

func (*GraphUpdatesQueue) IsFull added in v0.0.17

func (guq *GraphUpdatesQueue) IsFull() bool

IsFull check if the queue is full

type Projection

type Projection struct {
	Alias          string
	ExpressionType ExpressionType
}

type ProjectionVisitor added in v0.0.6

type ProjectionVisitor struct {
	ExpressionVisitorBase

	QueryGraph *QueryGraph

	Aggregation    bool
	TypeAndIndex   TypeAndIndex
	ExpressionType ExpressionType
	// contains filtered or unexported fields
}

func (*ProjectionVisitor) OnEnterFunctionInvocation added in v0.0.6

func (pv *ProjectionVisitor) OnEnterFunctionInvocation(name string) error

func (*ProjectionVisitor) OnExitPropertyOrLabelsExpression added in v0.0.6

func (pv *ProjectionVisitor) OnExitPropertyOrLabelsExpression(e query.QueryPropertyOrLabelsExpression) error

func (*ProjectionVisitor) OnVariable added in v0.0.6

func (pv *ProjectionVisitor) OnVariable(name string) error

func (*ProjectionVisitor) OnVariablePropertiesPath added in v0.0.6

func (pv *ProjectionVisitor) OnVariablePropertiesPath(properties []string) error

func (*ProjectionVisitor) ParseExpression added in v0.0.6

func (pv *ProjectionVisitor) ParseExpression(q *query.QueryExpression) error

ParseExpression return whether the expression require aggregation

type Querier

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

func NewQuerier

func NewQuerier(db GraphDB, historizer history.Historizer) *Querier

func (*Querier) Query

func (q *Querier) Query(ctx context.Context, queryString string) (*QuerierResult, error)

type QuerierResult

type QuerierResult struct {
	Cursor      Cursor
	Projections []Projection
	Statistics  Statistics
}

type QueryGraph added in v0.0.6

type QueryGraph struct {
	Nodes     []QueryNode
	Relations []QueryRelation

	VariablesIndex map[string]TypeAndIndex
}

func NewQueryGraph added in v0.0.6

func NewQueryGraph() QueryGraph

func (*QueryGraph) FindNode added in v0.0.6

func (gq *QueryGraph) FindNode(idx int) (*QueryNode, error)

func (*QueryGraph) FindVariable added in v0.0.6

func (qg *QueryGraph) FindVariable(name string) (TypeAndIndex, error)

func (*QueryGraph) PushNode added in v0.0.6

func (qg *QueryGraph) PushNode(q query.QueryNodePattern) (*QueryNode, int, error)

func (*QueryGraph) PushRelation added in v0.0.6

func (qg *QueryGraph) PushRelation(q query.QueryRelationshipPattern, leftIdx, rightIdx int) (*QueryRelation, int, error)

type QueryLimitVisitor added in v0.0.6

type QueryLimitVisitor struct {
	ExpressionVisitorBase

	Limit int64
}

func (*QueryLimitVisitor) OnIntegerLiteral added in v0.0.6

func (qlv *QueryLimitVisitor) OnIntegerLiteral(value int64) error

func (*QueryLimitVisitor) ParseExpression added in v0.0.6

func (qlv *QueryLimitVisitor) ParseExpression(q *query.QueryExpression) error

ParseExpression return whether the expression require aggregation

type QueryNode

type QueryNode struct {
	Labels []string
	// Constraint expressions
	Constraints AndOrExpression
}

QueryNode represent a node and its constraints

type QueryRelation

type QueryRelation struct {
	Labels []string
	// Constraint expressions
	Constraints AndOrExpression

	LeftIdx   int
	RightIdx  int
	Direction RelationDirection
}

QueryRelation represent a relation and its constraints

type QuerySkipVisitor added in v0.0.6

type QuerySkipVisitor struct {
	ExpressionVisitorBase

	Skip int64
}

func (*QuerySkipVisitor) OnIntegerLiteral added in v0.0.6

func (qsv *QuerySkipVisitor) OnIntegerLiteral(value int64) error

func (*QuerySkipVisitor) ParseExpression added in v0.0.6

func (qsv *QuerySkipVisitor) ParseExpression(q *query.QueryExpression) error

ParseExpression return whether the expression require aggregation

type QueryWhereVisitor added in v0.0.6

type QueryWhereVisitor struct {
	ExpressionVisitorBase

	Variables []string
}

func (*QueryWhereVisitor) OnVariable added in v0.0.6

func (qwv *QueryWhereVisitor) OnVariable(name string) error

func (*QueryWhereVisitor) ParseExpression added in v0.0.6

func (qwv *QueryWhereVisitor) ParseExpression(q *query.QueryExpression, qg *QueryGraph) (string, error)

ParseExpression return whether the expression require aggregation

type Relation

type Relation RelationKey

Relation represent the relation with details

type RelationDirection added in v0.0.6

type RelationDirection int
const (
	// Left relation
	Left RelationDirection = iota
	// Right relation
	Right RelationDirection = iota
	// There is a relation but we don't know in which direction
	Either RelationDirection = iota
	// There is a relation in both directions
	Both RelationDirection = iota
)

type RelationKey

type RelationKey struct {
	Type schema.RelationKeyType `json:"type"`
	From AssetKey               `json:"from"`
	To   AssetKey               `json:"to"`
}

RelationKey a relation key of the KB

type RelationWithID

type RelationWithID struct {
	ID   string                 `json:"_id"`
	From string                 `json:"from_id"`
	To   string                 `json:"to_id"`
	Type schema.RelationKeyType `json:"type"`
}

RelationWithID represent a relation with an ID from the database

func (RelationWithID) String

func (r RelationWithID) String() string

type SQLExpressionVisitor added in v0.0.6

type SQLExpressionVisitor struct {
	ExpressionVisitorBase
	// contains filtered or unexported fields
}

func (*SQLExpressionVisitor) OnBooleanLiteral added in v0.0.6

func (sev *SQLExpressionVisitor) OnBooleanLiteral(value bool) error

func (*SQLExpressionVisitor) OnComparisonOperator added in v0.0.6

func (sev *SQLExpressionVisitor) OnComparisonOperator(operator query.ComparisonOperator) error

func (*SQLExpressionVisitor) OnDoubleLiteral added in v0.0.6

func (sev *SQLExpressionVisitor) OnDoubleLiteral(value float64) error

func (*SQLExpressionVisitor) OnExitAndExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitAndExpression() error

func (*SQLExpressionVisitor) OnExitComparisonExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitComparisonExpression() error

func (*SQLExpressionVisitor) OnExitExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitExpression() error

func (*SQLExpressionVisitor) OnExitFunctionInvocation added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitFunctionInvocation(name string) error

func (*SQLExpressionVisitor) OnExitNotExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitNotExpression(not bool) error

func (*SQLExpressionVisitor) OnExitOrExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitOrExpression() error

func (*SQLExpressionVisitor) OnExitParenthesizedExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitParenthesizedExpression() error

func (*SQLExpressionVisitor) OnExitPropertyOrLabelsExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitPropertyOrLabelsExpression(e query.QueryPropertyOrLabelsExpression) error

func (*SQLExpressionVisitor) OnExitStringListNullOperatorExpression added in v0.0.6

func (sev *SQLExpressionVisitor) OnExitStringListNullOperatorExpression(e query.QueryStringListNullOperatorExpression) error

func (*SQLExpressionVisitor) OnIntegerLiteral added in v0.0.6

func (sev *SQLExpressionVisitor) OnIntegerLiteral(value int64) error

func (*SQLExpressionVisitor) OnStringLiteral added in v0.0.6

func (sev *SQLExpressionVisitor) OnStringLiteral(value string) error

func (*SQLExpressionVisitor) OnStringOperator added in v0.0.6

func (sev *SQLExpressionVisitor) OnStringOperator(operator query.StringOperator) error

func (*SQLExpressionVisitor) OnVariable added in v0.0.6

func (sev *SQLExpressionVisitor) OnVariable(name string) error

func (*SQLExpressionVisitor) OnVariablePropertiesPath added in v0.0.6

func (sev *SQLExpressionVisitor) OnVariablePropertiesPath(propertiesPath []string) error

type SQLQueryTranslator

type SQLQueryTranslator struct {
	QueryGraph QueryGraph
}

func NewSQLQueryTranslator

func NewSQLQueryTranslator() *SQLQueryTranslator

func (*SQLQueryTranslator) Translate

func (sqt *SQLQueryTranslator) Translate(query *query.QueryCypher) (*SQLTranslation, error)

type SQLTranslation

type SQLTranslation struct {
	Query           string
	ProjectionTypes []Projection
}

type SourceSubGraphUpdates

type SourceSubGraphUpdates struct {
	Updates GraphUpdatesBulk
	Schema  schema.SchemaGraph
	Source  string
}

SourceSubGraphUpdates represents the updates to perform on a source subgraph

type Statistics

type Statistics struct {
	Parsing   time.Duration
	Execution time.Duration
}

type TypeAndIndex added in v0.0.6

type TypeAndIndex struct {
	Type  VariableType
	Index int
}

type VariableType added in v0.0.6

type VariableType int
const (
	NodeType     VariableType = iota
	RelationType VariableType = iota
)

Jump to

Keyboard shortcuts

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