knowledge

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 18 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"`
}

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 DataSource added in v0.0.13

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

DataSource an interface for data source allowing to read current graph and push graph updates

func NewDataSource added in v0.0.13

func NewDataSource(api *GraphAPI) *DataSource

NewDataSource create an emitter of graph

func (*DataSource) CreateTransaction added in v0.0.13

func (ds *DataSource) CreateTransaction(currentGraph *Graph) *Transaction

CreateTransaction create a full graph transaction. This kind of transaction will diff the new graph with previous version of it.

func (*DataSource) ReadCurrentGraph added in v0.0.13

func (ds *DataSource) ReadCurrentGraph() (*Graph, error)

ReadCurrentGraph read the graph related to that data source

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

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 (sg *Graph) MarshalJSON() ([]byte, error)

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 (sg *Graph) UnmarshalJSON(b []byte) error

type GraphAPI

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

GraphEmitter an emitter of full source graph

func NewGraphAPI

func NewGraphAPI(url, authToken string, skipVerify bool) *GraphAPI

NewGraphEmitter create an emitter of graph

func (*GraphAPI) ReadCurrentGraph

func (gapi *GraphAPI) ReadCurrentGraph() (*Graph, error)

ReadCurrentGraph read the current graph stored in graph kb

func (*GraphAPI) UpdateGraph

func (gapi *GraphAPI) UpdateGraph(sg schema.SchemaGraph, updates GraphUpdatesBulk) error

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

	UpdateGraph(source string, bulk *GraphUpdatesBulk) error
	ReadGraph(source string, graph *Graph) 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
}

type GraphUpdateRequestBody

type GraphUpdateRequestBody struct {
	Updates *GraphUpdatesBulk  `json:"updates"`
	Schema  schema.SchemaGraph `json:"schema"`
}

type GraphUpdater

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

SourceListener represents the source listener waiting for source events

func NewGraphUpdater

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

NewGraphUpdater create a new instance of graph updater

func (*GraphUpdater) Listen

func (sl *GraphUpdater) Listen(updatesC chan SourceSubGraphUpdates) chan struct{}

Listen events coming from the event bus

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()

func (*GraphUpdatesBulk) GetAssetRemovals

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

func (*GraphUpdatesBulk) GetAssetUpserts

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

func (*GraphUpdatesBulk) GetRelationRemovals

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

func (*GraphUpdatesBulk) GetRelationUpserts

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

func (*GraphUpdatesBulk) HasAssetRemoval

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

func (*GraphUpdatesBulk) HasAssetUpsert

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

func (*GraphUpdatesBulk) HasRelationRemoval

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

func (*GraphUpdatesBulk) HasRelationUpsert

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

func (*GraphUpdatesBulk) MarshalJSON

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

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

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 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"`
}

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 Transaction

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

Transaction represent a transaction generating updates by diffing the provided graph against the previous version.

func (*Transaction) Bind

func (cgt *Transaction) Bind(asset string, assetType schema.AssetType)

Bind bind one asset to an asset type from the schema

func (*Transaction) Commit

func (cgt *Transaction) Commit() (*Graph, error)

Commit commit the transaction and gives ownership to the source for caching.

func (*Transaction) Relate

func (cgt *Transaction) Relate(from string, relationType schema.RelationType, to string)

Relate create a relation between two assets

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