query

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: AGPL-3.0, Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FacetDelimeter = "|"
)

Variables

View Source
var (
	ErrEmptyVal = errors.New("query: harmless error, e.g. task.Val is nil")
	ErrWrongAgg = errors.New("Wrong level for var aggregation.")
)
View Source
var ErrFacet = x.Errorf("Skip the edge")
View Source
var ErrStop = x.Errorf("STOP")
View Source
var ErrTooBig = x.Errorf("Query exceeded memory limit. Please modify the query")
View Source
var MutationNotAllowedErr = x.Errorf("Mutations are forbidden on this server.")

Functions

func ApplyMutations added in v0.8.2

func ApplyMutations(ctx context.Context, m *intern.Mutations) (*api.TxnContext, error)

func AssignUids added in v0.8.2

func AssignUids(ctx context.Context, nquads []*api.NQuad) (map[string]uint64, error)

func ConvertUidsToHex added in v0.8.2

func ConvertUidsToHex(m map[string]uint64) (res map[string]string)

convert the new UIDs to hex string.

func GetAllPredicates added in v0.8.2

func GetAllPredicates(subGraphs []*SubGraph) (predicates []string)

func ProcessGraph

func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error)

ProcessGraph processes the SubGraph instance accumulating result for the query from different instances. Note: taskQuery is nil for root node.

func Recurse added in v0.8.2

func Recurse(ctx context.Context, sg *SubGraph) error

func StripBlankNode added in v0.8.2

func StripBlankNode(mp map[string]uint64) map[string]uint64

func ToInternal added in v0.8.2

func ToInternal(gmu *gql.Mutation,
	newUids map[string]uint64) (edges []*intern.DirectedEdge, err error)

func ToJson added in v0.7.2

func ToJson(l *Latency, sgl []*SubGraph) ([]byte, error)

ToJson converts the list of subgraph into a JSON response by calling toFastJSON.

Types

type ExecuteResult added in v0.8.2

type ExecuteResult struct {
	Subgraphs  []*SubGraph
	SchemaNode []*api.SchemaNode
}

TODO: This looks unnecessary.

type Extensions added in v0.8.2

type Extensions struct {
	Latency *api.Latency    `json:"server_latency,omitempty"`
	Txn     *api.TxnContext `json:"txn,omitempty"`
}

type Function added in v0.8.2

type Function struct {
	Name       string    // Specifies the name of the function.
	Args       []gql.Arg // Contains the arguments of the function.
	IsCount    bool      // gt(count(friends),0)
	IsValueVar bool      // eq(val(s), 10)
}

Function holds the information about gql functions.

type InternalError added in v0.8.2

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

func (*InternalError) Error added in v0.8.2

func (e *InternalError) Error() string

type InvalidRequestError added in v0.8.2

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

func (*InvalidRequestError) Error added in v0.8.2

func (e *InvalidRequestError) Error() string

type Item added in v0.7.3

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

type Latency

type Latency struct {
	Start      time.Time     `json:"-"`
	Parsing    time.Duration `json:"query_parsing"`
	Processing time.Duration `json:"processing"`
	Json       time.Duration `json:"json_conversion"`
}

Latency is used to keep track of the latency involved in parsing and processing the query. It also contains information about the time it took to convert the result into a format(JSON/Protocol Buffer) that the client expects.

type QueryRequest added in v0.8.2

type QueryRequest struct {
	ReadTs   uint64
	Latency  *Latency
	GqlQuery *gql.Result

	Subgraphs []*SubGraph

	LinRead *api.LinRead
	// contains filtered or unexported fields
}

QueryRequest wraps the state that is used when executing query. Initially Latency and GqlQuery needs to be set. Subgraphs, Vars and schemaUpdate are filled when processing query.

func (*QueryRequest) Process added in v0.9.0

func (qr *QueryRequest) Process(ctx context.Context) (er ExecuteResult, err error)

func (*QueryRequest) ProcessQuery added in v0.8.2

func (req *QueryRequest) ProcessQuery(ctx context.Context) (err error)

ProcessQuery processes query part of the request (without mutations). Fills Subgraphs and Vars. It optionally also returns a map of the allocated uids in case of an upsert request.

type SubGraph

type SubGraph struct {
	ReadTs  uint64
	LinRead *api.LinRead
	Attr    string
	Params  params

	ExpandPreds []*intern.ValueList
	GroupbyRes  []*groupResults // one result for each uid list.
	LangTags    []*intern.LangList

	// SrcUIDs is a list of unique source UIDs. They are always copies of destUIDs
	// of parent nodes in GraphQL structure.
	SrcUIDs *intern.List
	SrcFunc *Function

	FilterOp string
	Filters  []*SubGraph

	MathExp  *mathTree
	Children []*SubGraph

	// destUIDs is a list of destination UIDs, after applying filters, pagination.
	DestUIDs *intern.List
	List     bool // whether predicate is of list type
	// contains filtered or unexported fields
}

SubGraph is the way to represent data intern.y. It contains both the query and the response. Once generated, this can then be encoded to other client convenient formats, like GraphQL / JSON.

func KShortestPath added in v0.8.2

func KShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error)

func ShortestPath added in v0.7.3

func ShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error)

func ToSubGraph

func ToSubGraph(ctx context.Context, gq *gql.GraphQuery) (*SubGraph, error)

ToSubGraph converts the GraphQuery into the intern.SubGraph instance type.

func (*SubGraph) ApplyIneqFunc added in v0.8.2

func (sg *SubGraph) ApplyIneqFunc() error

func (*SubGraph) DebugPrint added in v0.7.0

func (sg *SubGraph) DebugPrint(prefix string)

DebugPrint prints out the SubGraph tree in a nice format for debugging purposes.

func (*SubGraph) IsGroupBy added in v0.8.2

func (sg *SubGraph) IsGroupBy() bool

func (*SubGraph) IsInternal added in v0.8.2

func (sg *SubGraph) IsInternal() bool

Jump to

Keyboard shortcuts

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