query

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: Apache-2.0 Imports: 28 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")
)
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")

Functions

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 ShortestPath added in v0.7.3

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

func ToJson added in v0.7.2

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

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

func ToProtocolBuf added in v0.7.2

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

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

Types

type Codec added in v0.4.3

type Codec struct{}

Codec implements the custom codec interface.

func (*Codec) Marshal added in v0.4.3

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

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

func (*Codec) String added in v0.4.3

func (c *Codec) String() string

func (*Codec) Unmarshal added in v0.4.3

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

Unmarshal constructs graph.Request from the byte slice.

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"`
	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 SubGraph

type SubGraph struct {
	Attr   string
	Params params

	// SrcUIDs is a list of unique source UIDs. They are always copies of destUIDs
	// of parent nodes in GraphQL structure.
	SrcUIDs *task.List
	SrcFunc []string

	FilterOp string
	Filters  []*SubGraph
	Children []*SubGraph

	// destUIDs is a list of destination UIDs, after applying filters, pagination.
	DestUIDs *task.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 ProcessQuery added in v0.7.2

func ProcessQuery(ctx context.Context, res gql.Result, l *Latency) ([]*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) 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) ToFastJSON added in v0.7.2

func (sg *SubGraph) ToFastJSON(l *Latency, w io.Writer, allocIds map[string]string) error

func (*SubGraph) ToProtocolBuffer

func (sg *SubGraph) ToProtocolBuffer(l *Latency) (*graph.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.

Directories

Path Synopsis
Package graph is a generated protocol buffer package.
Package graph is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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