sulpher

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrJobNotFound    = jobError("job not found")
	ErrJobNotComplete = jobError("job not completed")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm string

Algorithm represents traversal algorithm

const (
	BFS Algorithm = "BFS"
	DFS Algorithm = "DFS"
)

type Condition

type Condition struct {
	VarPath  string      // e.g., "u.name"
	Operator Operator    // e.g., "="
	Value    interface{} // e.g., "Alice" or 123
}

Condition represents a WHERE condition

type ConditionGroup

type ConditionGroup struct {
	Conditions []Condition
}

ConditionGroup represents conditions joined by AND (groups are joined by OR)

type Executor

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

Executor executes Sulpher queries against a graph

func NewExecutor

func NewExecutor(g *graph.IndexedGraph, maxDepth int) *Executor

NewExecutor creates a new query executor

func (*Executor) Execute

func (e *Executor) Execute(query *Query) (*QueryResult, error)

Execute runs a parsed query and returns results

type Job

type Job struct {
	ID        string       `json:"id"`
	Query     string       `json:"query"`
	Status    JobStatus    `json:"status"`
	Result    *QueryResult `json:"result,omitempty"`
	Error     string       `json:"error,omitempty"`
	CreatedAt time.Time    `json:"created_at"`
	StartedAt *time.Time   `json:"started_at,omitempty"`
	EndedAt   *time.Time   `json:"ended_at,omitempty"`
	MaxDepth  int          `json:"max_depth"`
}

Job represents an async query job

type JobManager

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

JobManager manages async query jobs

func NewJobManager

func NewJobManager(executor *Executor, ttl time.Duration) *JobManager

NewJobManager creates a new job manager

func (*JobManager) ExecuteSync

func (jm *JobManager) ExecuteSync(queryStr string, maxDepth int) (*QueryResult, error)

ExecuteSync executes a query synchronously

func (*JobManager) GetJob

func (jm *JobManager) GetJob(id string) (*Job, bool)

GetJob retrieves a job by ID

func (*JobManager) GetJobResult

func (jm *JobManager) GetJobResult(id string) (*QueryResult, error)

GetJobResult retrieves the result of a completed job

func (*JobManager) Submit

func (jm *JobManager) Submit(queryStr string, maxDepth int) (*Job, error)

Submit submits a new query job and returns immediately

type JobStatus

type JobStatus string

JobStatus represents the status of a query job

const (
	StatusPending   JobStatus = "pending"
	StatusRunning   JobStatus = "running"
	StatusCompleted JobStatus = "completed"
	StatusFailed    JobStatus = "failed"
)

type NodePattern

type NodePattern struct {
	Variable   string                 // e.g., "u"
	Type       string                 // e.g., "User" (optional)
	Properties map[string]interface{} // inline properties like {id: 123}
}

NodePattern represents a node in the query pattern

type Operator

type Operator string

Operator represents comparison operator

const (
	OpEq  Operator = "="
	OpNe  Operator = "!="
	OpLt  Operator = "<"
	OpGt  Operator = ">"
	OpLte Operator = "<="
	OpGte Operator = ">="
)

type OrderByItem

type OrderByItem struct {
	VarPath   string         // e.g., "u.name"
	Direction OrderDirection // ASC or DESC
}

OrderByItem represents an ORDER BY clause item

type OrderDirection

type OrderDirection string

OrderDirection represents sort direction

const (
	OrderAsc  OrderDirection = "ASC"
	OrderDesc OrderDirection = "DESC"
)

type Parser

type Parser struct{}

Parser parses Sulpher queries

func NewParser

func NewParser() *Parser

NewParser creates a new Sulpher parser

func (*Parser) Parse

func (p *Parser) Parse(query string) (*Query, error)

Parse parses a Sulpher query string

type PathElement

type PathElement struct {
	Node         NodePattern
	Relationship *RelPattern // nil for the last node
}

PathElement represents one step in the path pattern

type Query

type Query struct {
	Algorithm       Algorithm
	Path            []PathElement
	Conditions      []Condition      // Legacy: simple AND-joined conditions
	ConditionGroups []ConditionGroup // OR-joined groups of AND-joined conditions
	ReturnItems     []ReturnItem
	Distinct        bool          // RETURN DISTINCT
	OrderBy         []OrderByItem // ORDER BY clause
	Limit           int           // LIMIT clause (0 = no limit)
	RawQuery        string
}

Query represents a parsed Sulpher query

type QueryResult

type QueryResult struct {
	Data  []map[string]interface{} `json:"data"`
	Stats QueryStats               `json:"stats"`
}

QueryResult represents the result of a query execution

type QueryStats

type QueryStats struct {
	NodesTraversed int           `json:"nodes_traversed"`
	PathsFound     int           `json:"paths_found"`
	ExecutionTime  time.Duration `json:"execution_time_ms"`
}

QueryStats contains execution statistics

type RelDirection

type RelDirection int

RelDirection represents relationship direction

const (
	RelOutgoing      RelDirection = iota // -[r]->
	RelIncoming                          // <-[r]-
	RelBidirectional                     // -[r]- or <-[r]->
)

type RelPattern

type RelPattern struct {
	Variable   string       // e.g., "r" (optional)
	Type       string       // e.g., "FOLLOWS" (optional)
	MinHops    int          // Minimum hops (0 = no minimum, default 1)
	MaxHops    int          // Maximum hops (0 = unlimited, use query max_depth)
	IsVariable bool         // True if *min..max syntax was used
	Direction  RelDirection // Direction of traversal
}

RelPattern represents a relationship in the query pattern

type ReturnItem

type ReturnItem struct {
	Variable string // e.g., "u"
	Property string // e.g., "name" (empty if returning whole node)
}

ReturnItem represents an item in the RETURN clause

Jump to

Keyboard shortcuts

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