query

package
v82.0.0-...-84d68f0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2017 License: AGPL-3.0, Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

func ApplyMutations(ctx context.Context, m *protos.Mutations) error

func AssignUids

func AssignUids(ctx context.Context, nquads gql.NQuads) (map[string]uint64, error)

func ConvertUidsToHex

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

convert the new UIDs to hex string.

func GetAllPredicates

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

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

func StripBlankNode

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

func ToJson

func ToJson(l *Latency, sgl []*SubGraph, w io.Writer, allocIds map[string]string,
	addLatency bool) error

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

func ToProtocolBuf

func ToProtocolBuf(l *Latency, sgl []*SubGraph) ([]*protos.Node, error)

ToProtocolBuf returns the list of protos.Node which would be returned to the go client.

Types

type Codec

type Codec struct{}

Codec implements the custom codec interface.

func (*Codec) Marshal

func (c *Codec) Marshal(v interface{}) ([]byte, error)

Marshal release the protos.Node pointers after marshalling the response.

func (*Codec) String

func (c *Codec) String() string

func (*Codec) Unmarshal

func (c *Codec) Unmarshal(data []byte, v interface{}) error

Unmarshal constructs protos.Request from the byte slice.

type ExecuteResult

type ExecuteResult struct {
	Subgraphs   []*SubGraph
	SchemaNode  []*protos.SchemaNode
	Allocations map[string]uint64 // Blank node => uid map returned for a mutation request.
}

type Extensions

type Extensions struct {
	Latency map[string]string `json:"server_latency"`
}

type Function

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

Function holds the information about gql functions.

type InternalError

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

func (*InternalError) Error

func (e *InternalError) Error() string

type InternalMutation

type InternalMutation struct {
	Edges []*protos.DirectedEdge
}

func ToInternal

func ToInternal(ctx context.Context,
	nquads gql.NQuads,
	vars map[string]varValue, newUids map[string]uint64) (InternalMutation, error)

func (*InternalMutation) AddEdge

type InvalidRequestError

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

func (*InvalidRequestError) Error

func (e *InvalidRequestError) Error() string

type Item

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"`
	ProtocolBuffer time.Duration `json:"pb_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.

func (*Latency) ToMap

func (l *Latency) ToMap() map[string]string

ToMap converts the latency object to a map.

type QueryRequest

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

	Subgraphs []*SubGraph

	SchemaUpdate []*protos.SchemaUpdate
	// 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) ProcessQuery

func (req *QueryRequest) ProcessQuery(ctx context.Context) (map[string]uint64, 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.

func (*QueryRequest) ProcessWithMutation

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

type SubGraph

type SubGraph struct {
	Attr   string
	Params params

	ExpandPreds []*protos.ValueList
	GroupbyRes  *groupResults

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

	FilterOp string
	Filters  []*SubGraph

	MathExp  *mathTree
	Children []*SubGraph

	// destUIDs is a list of destination UIDs, after applying filters, pagination.
	DestUIDs *protos.List
	// contains filtered or unexported fields
}

SubGraph is the way to represent data internally. 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

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

func ShortestPath

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 internal SubGraph instance type.

func (*SubGraph) ApplyIneqFunc

func (sg *SubGraph) ApplyIneqFunc() error

func (*SubGraph) DebugPrint

func (sg *SubGraph) DebugPrint(prefix string)

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

func (*SubGraph) IsGroupBy

func (sg *SubGraph) IsGroupBy() bool

func (*SubGraph) IsInternal

func (sg *SubGraph) IsInternal() bool

func (*SubGraph) ToProtocolBuffer

func (sg *SubGraph) ToProtocolBuffer(l *Latency) (*protos.Node, error)

ToProtocolBuffer does preorder traversal to build a proto buffer. We have used postorder traversal before, but preorder seems simpler and faster for most cases.

Jump to

Keyboard shortcuts

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