query

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package query defines the graph session interface general to all query languages.

Index

Constants

View Source
const (
	// Raw collates results as maps or arrays of graph.Refs or any other query-native or graph-native data type.
	Raw = Collation(iota)
	// REPL collates results as strings which will be used in CLI.
	REPL = Collation(iota)
	// JSON collates results as maps, arrays and values, that can be encoded to JSON.
	JSON
	// JSONLD collates results as maps, arrays and values compatible with JSON-LD spec.
	JSONLD
)

Variables

View Source
var ErrParseMore = errors.New("query: more input required")

Functions

func Languages added in v0.6.0

func Languages() []string

Languages returns names of registered query languages.

func RegisterLanguage added in v0.6.0

func RegisterLanguage(lang Language)

RegisterLanguage register a new query language.

Types

type Collation added in v0.7.8

type Collation int

Collation of results.

type ErrUnsupportedCollation added in v0.7.8

type ErrUnsupportedCollation struct {
	Collation Collation
}

func (*ErrUnsupportedCollation) Error added in v0.7.8

func (e *ErrUnsupportedCollation) Error() string

type Iterator added in v0.7.8

type Iterator interface {
	// Next advances the iterator to the next value, which will then be available through
	// the Result method. It returns false if no further advancement is possible, or if an
	// error was encountered during iteration.  Err should be consulted to distinguish
	// between the two cases.
	Next(ctx context.Context) bool
	// Results returns the current result. The type depends on the collation mode of the query.
	Result() interface{}
	// Err returns any error that was encountered by the Iterator.
	Err() error
	// Close the iterator and do internal cleanup.
	Close() error
}

Iterator for query results.

func Execute added in v0.7.8

func Execute(ctx context.Context, qs graph.QuadStore, lang, query string, opt Options) (Iterator, error)

Execute runs the query in a given language and returns an iterator over the results. Type of results depends on Collation. See Options for details.

type Language added in v0.6.0

type Language struct {
	Name    string
	Session func(graph.QuadStore) Session

	HTTPQuery func(ctx context.Context, qs graph.QuadStore, w ResponseWriter, r io.Reader)
	HTTPError func(w ResponseWriter, err error)
}

Language is a description of query language.

func GetLanguage added in v0.6.0

func GetLanguage(lang string) *Language

GetLanguage returns a query language description. It returns nil if language was not registered.

type Options added in v0.7.8

type Options struct {
	Limit     int
	Collation Collation
}

Options for the query execution.

type REPLSession added in v0.6.0

type REPLSession = Session

type ResponseWriter added in v0.6.0

type ResponseWriter interface {
	Write([]byte) (int, error)
	WriteHeader(int)
}

ResponseWriter is a subset of http.ResponseWriter

type Session

type Session interface {
	// Execute runs the query and returns an iterator over the results.
	// Type of results depends on Collation. See Options for details.
	Execute(ctx context.Context, query string, opt Options) (Iterator, error)
}

func NewSession added in v0.6.0

func NewSession(qs graph.QuadStore, lang string) Session

NewSession creates a new session for specified query language. It returns nil if language was not registered.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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