Documentation
¶
Overview ¶
Package opencypher is an in-process openCypher engine over an in-memory property graph.
Supported: MATCH, OPTIONAL MATCH, WHERE, CREATE, MERGE (ON CREATE/ON MATCH SET), SET, REMOVE, DELETE, DETACH DELETE, WITH, UNWIND, RETURN with DISTINCT, ORDER BY, SKIP, LIMIT, parameters, variable-length relationships, CASE, list/map expressions, the common scalar functions and the count, collect, sum, avg, min and max aggregates, read-only UNION / UNION ALL, pattern predicates, size() of a pattern and list comprehensions, read-only CALL subqueries and reduce(). Not supported (as in Neptune): CALL procedures, FOREACH, LOAD CSV, shortestPath, constraints and indexes.
Index ¶
- Constants
- func Explain(src, mode string) (string, error)
- func ParseParameters(raw string) (map[string]any, error)
- type Access
- type EdgeStructure
- type Error
- type Graph
- func (g *Graph) Begin(ctx context.Context) (*Tx, error)
- func (g *Graph) Counts() (int, int)
- func (g *Graph) Execute(ctx context.Context, src string, params map[string]any) (*Result, error)
- func (g *Graph) Export(ctx context.Context) ([]byte, error)
- func (g *Graph) Import(ctx context.Context, data []byte) error
- func (g *Graph) RebuildIndexes()
- func (g *Graph) SetExtendedDatetime(enabled bool)
- func (g *Graph) Stats() (int, int, int)
- func (g *Graph) Storage() Storage
- func (g *Graph) Stream() *streamlog.Log
- func (g *Graph) Summary() Summary
- func (g *Graph) Update(ctx context.Context, fn func(*Store) error) error
- func (g *Graph) View(ctx context.Context, fn func(*Store) error) error
- func (g *Graph) Wipe(ctx context.Context) error
- type Node
- type NodeStructure
- type Path
- type Rel
- type Result
- type Storage
- type Store
- func (s *Store) AddNode(id string, labels []string, props map[string]any) (*Node, error)
- func (s *Store) AddRel(id, typ string, from, to *Node, props map[string]any) (*Rel, error)
- func (s *Store) DeleteNode(n *Node)
- func (s *Store) DeleteRel(r *Rel)
- func (s *Store) InRels(id string) []*Rel
- func (s *Store) Node(id string) *Node
- func (s *Store) Nodes() []*Node
- func (s *Store) OutRels(id string) []*Rel
- func (s *Store) Rel(id string) *Rel
- func (s *Store) Rels() []*Rel
- type Summary
- type Tx
Constants ¶
const ( CodeMalformedQuery = "MalformedQueryException" CodeUnsupported = "UnsupportedOperationException" CodeConstraintViolation = "ConstraintViolationException" CodeInvalidParameter = "InvalidParameterException" )
Error codes match the Neptune openCypher HTTP API.
const BlobThreshold = 1024
BlobThreshold is the term size from which a dictionary entry counts as a blob.
const IDProperty = "~id"
IDProperty is the property key that sets or reads an entity id.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Access ¶
Access is the extra permission a query needs beyond read; every query reads.
func QueryAccess ¶
QueryAccess classifies query by its clauses; an unparsable query needs only read (it fails when run).
type EdgeStructure ¶
type EdgeStructure struct {
EdgeProperties []string `json:"edgeProperties"`
Count int `json:"count"`
}
EdgeStructure is a distinct edge property-key signature and how many edges have it.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a thread-safe in-memory property graph with an openCypher executor.
func (*Graph) Execute ¶
Execute runs one openCypher query. Write queries are atomic: a failure leaves the graph unchanged.
func (*Graph) RebuildIndexes ¶
func (g *Graph) RebuildIndexes()
RebuildIndexes recreates the adjacency indexes from the relationships in creation order.
func (*Graph) SetExtendedDatetime ¶
SetExtendedDatetime switches the DatetimeMillisecond lab mode (Neptune 1.3.2.0+) for this graph.
func (*Graph) Stats ¶
Stats summarises the graph for the DFE statistics endpoints: distinct label and property-key sets (signatures), nodes (instances) and distinct property keys plus relationship types (predicates).
func (*Graph) Storage ¶
Storage describes the graph as Neptune's quad indexes and term dictionary would hold it: one entry per label, property value and edge.
func (*Graph) Summary ¶
Summary describes the graph's labels, property keys and structures for the graph summary endpoint.
type Node ¶
type Node struct {
Props map[string]any
ID string
Labels []string
// contains filtered or unexported fields
}
Node is a labelled vertex.
type NodeStructure ¶
type NodeStructure struct {
NodeProperties []string `json:"nodeProperties"`
DistinctOutgoingEdgeLabels []string `json:"distinctOutgoingEdgeLabels"`
Count int `json:"count"`
}
NodeStructure is a distinct property-key and outgoing-edge-label signature and how many nodes have it.
type Rel ¶
type Rel struct {
Props map[string]any
ID string
Type string
Start string
End string
// contains filtered or unexported fields
}
Rel is a directed, typed edge.
type Result ¶
Result is the table produced by RETURN; a query with no RETURN has no columns.
func (*Result) MarshalJSON ¶
MarshalJSON renders the rows as Neptune's openCypher results array (entities use ~id/~entityType shapes).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is exclusive access to a graph's entities, handed to other query languages (Gremlin) so they share the same data, locking and rollback as openCypher.
func (*Store) DeleteNode ¶
DeleteNode removes a node and its relationships.
type Summary ¶
type Summary struct {
NodeLabels []string `json:"nodeLabels"`
EdgeLabels []string `json:"edgeLabels"`
NodeProperties []map[string]int `json:"nodeProperties"`
EdgeProperties []map[string]int `json:"edgeProperties"`
NodeStructures []NodeStructure `json:"nodeStructures"`
EdgeStructures []EdgeStructure `json:"edgeStructures"`
NumNodes int `json:"numNodes"`
NumEdges int `json:"numEdges"`
NumNodeLabels int `json:"numNodeLabels"`
NumEdgeLabels int `json:"numEdgeLabels"`
NumNodeProperties int `json:"numNodeProperties"`
NumEdgeProperties int `json:"numEdgeProperties"`
TotalNodePropertyValues int `json:"totalNodePropertyValues"`
TotalEdgePropertyValues int `json:"totalEdgePropertyValues"`
}
Summary is the Neptune graph summary payload for a property graph.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is an explicit transaction holding the graph exclusively until Commit or Rollback.
func (*Tx) Commit ¶
func (t *Tx) Commit()
Commit keeps the transaction's writes and releases the graph.