gremlin

package
v0.0.0-...-8832f83 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

_       _

*__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate. All rights reserved. * LICENSE: https://github.com/creativesoftwarefdn/weaviate/blob/develop/LICENSE.md * DESIGN & CONCEPT: Bob van Luijt (@bobvanluijt) * CONTACT: hello@creativesoftwarefdn.org

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(str string) string

Escape a string so that it can be used without risk of SQL-injection like escapes. TODO gh-614: figure out other ways of doing string interpolation in Groovy and escape them.

Types

type Datum

type Datum struct {
	Datum interface{}
}

A single piece of data returned by a Gremlin query.

func (*Datum) AssertEdge

func (d *Datum) AssertEdge() *Edge

func (*Datum) AssertKey

func (d *Datum) AssertKey(key string) *Datum

func (*Datum) AssertPath

func (d *Datum) AssertPath() *Path

func (*Datum) AssertStringSlice

func (d *Datum) AssertStringSlice() []string

func (*Datum) AssertVertex

func (d *Datum) AssertVertex() *Vertex

func (*Datum) Edge

func (d *Datum) Edge() (*Edge, error)

Attempt to extract a edge from this datum.

func (*Datum) Key

func (d *Datum) Key(key string) (*Datum, error)

If the Datum is a map, look up the key and return a datum for that key.

func (*Datum) Path

func (d *Datum) Path() (*Path, error)

func (*Datum) Type

func (d *Datum) Type() string

Extract the type of a datum. This method is intended to be a debugging tool, don't use it in a critical path.

func (*Datum) Vertex

func (d *Datum) Vertex() (*Vertex, error)

Attempt to extract a Vertex from this datum.

type Edge

type Edge struct {
	Id         string
	Label      string
	Properties map[string]PropertyValue
}

func (*Edge) AssertPropertyValue

func (e *Edge) AssertPropertyValue(name string) *PropertyValue

func (*Edge) PropertyValue

func (e *Edge) PropertyValue(name string) *PropertyValue

type Graph

type Graph struct{}
var G Graph

This is the starting point for building queries.

func (*Graph) AddE

func (g *Graph) AddE(label string) *Query

func (*Graph) AddV

func (g *Graph) AddV(label string) *Query

func (*Graph) E

func (g *Graph) E() *Query

func (*Graph) V

func (g *Graph) V() *Query

type Gremlin

type Gremlin interface {
	// Convert the gremlin code to a string.
	String() string
}

type Path

type Path struct {
	Segments []Datum
}

type Property

type Property struct {
	Id    string
	Value PropertyValue
}

type PropertyValue

type PropertyValue struct {
	Value interface{}
}

func (*PropertyValue) AssertBool

func (p *PropertyValue) AssertBool() bool

func (*PropertyValue) AssertFloat

func (p *PropertyValue) AssertFloat() float64

func (*PropertyValue) AssertGeoCoordinates

func (p *PropertyValue) AssertGeoCoordinates() *models.GeoCoordinates

func (*PropertyValue) AssertInt

func (p *PropertyValue) AssertInt() int

func (*PropertyValue) AssertInt64

func (p *PropertyValue) AssertInt64() int64

func (*PropertyValue) AssertString

func (p *PropertyValue) AssertString() string

func (*PropertyValue) Bool

func (p *PropertyValue) Bool() (bool, bool)

func (*PropertyValue) Float

func (p *PropertyValue) Float() (float64, bool)

func (*PropertyValue) GeoCoordinates

func (p *PropertyValue) GeoCoordinates() (*models.GeoCoordinates, error)

func (*PropertyValue) Int

func (p *PropertyValue) Int() (int, bool)

func (*PropertyValue) Int64

func (p *PropertyValue) Int64() (int64, bool)

func (*PropertyValue) String

func (p *PropertyValue) String() (string, bool)

type Query

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

A query represents the (partial) query build with the DSL

func Current

func Current() *Query

func EqBool

func EqBool(value bool) *Query

EqBool returns a testing predicate such as eq(<bool>), e.g. eq(1000)

func EqDate

func EqDate(value time.Time) *Query

EqDate returns a testing predicate such as eq(<time.Time>), e.g. eq(1000)

func EqFloat

func EqFloat(value float64) *Query

EqFloat returns a testing predicate such as eq(<float64>), e.g. eq(1000)

func EqInt

func EqInt(value int) *Query

EqInt returns a testing predicate such as eq(<int>), e.g. eq(1000)

func EqString

func EqString(value string) *Query

EqString returns a testing predicate such as eq(<string>), e.g. eq(1000)

func GeoWithinCircle

func GeoWithinCircle(lat, lon, dist float32) *Query

GeoWithinCircle returns a testing predicate such as geoWithin(Geoshape.Circle(x,y,d))

func GtDate

func GtDate(value time.Time) *Query

GtDate returns a testing predicate such as gt(<time.Time>), e.g. gt(1000)

func GtFloat

func GtFloat(value float64) *Query

GtFloat returns a testing predicate such as gt(<float64>), e.g. gt(1000)

func GtInt

func GtInt(value int) *Query

GtInt returns a testing predicate such as gt(<int>), e.g. gt(1000)

func GteDate

func GteDate(value time.Time) *Query

GteDate returns a testing predicate such as gte(<time.Time>), e.g. gte(1000)

func GteFloat

func GteFloat(value float64) *Query

GteFloat returns a testing predicate such as gte(<float64>), e.g. gte(1000)

func GteInt

func GteInt(value int) *Query

GteInt returns a testing predicate such as gte(<int>), e.g. gte(1000)

func LtDate

func LtDate(value time.Time) *Query

LtDate returns a testing predicate such as lt(<time.Time>), e.g. lt(1000)

func LtFloat

func LtFloat(value float64) *Query

LtFloat returns a testing predicate such as lt(<float64>), e.g. lt(1000)

func LtInt

func LtInt(value int) *Query

LtInt returns a testing predicate such as lt(<int>), e.g. lt(1000)

func LteDate

func LteDate(value time.Time) *Query

LteDate returns a testing predicate such as lte(<time.Time>), e.g. lte(1000)

func LteFloat

func LteFloat(value float64) *Query

LteFloat returns a testing predicate such as lte(<float64>), e.g. lte(1000)

func LteInt

func LteInt(value int) *Query

LteInt returns a testing predicate such as lte(<int>), e.g. lte(1000)

func NeqBool

func NeqBool(value bool) *Query

NeqBool returns a testing predicate such as neq(<bool>), e.g. neq(1000)

func NeqDate

func NeqDate(value time.Time) *Query

NeqDate returns a testing predicate such as neq(<time.Time>), e.g. neq(1000)

func NeqFloat

func NeqFloat(value float64) *Query

NeqFloat returns a testing predicate such as neq(<float64>), e.g. neq(1000)

func NeqInt

func NeqInt(value int) *Query

NeqInt returns a testing predicate such as neq(<int>), e.g. neq(1000)

func NeqString

func NeqString(value string) *Query

NeqString returns a testing predicate such as neq(<string>), e.g. neq(1000)

func New

func New() *Query

New returns a new (empty) query. Most useful for subqueries which don't start with g.V() or g.E().

func RawQuery

func RawQuery(query string) *Query

func (*Query) AddE

func (q *Query) AddE(label string) *Query

func (*Query) AddV

func (q *Query) AddV(label string) *Query

func (*Query) Aggregate

func (q *Query) Aggregate(label string) *Query

Aggregate results to perform analyses on them

func (*Query) And

func (q *Query) And(queries ...*Query) *Query

And can combine 0..n queries together

If used on an existing query it will lead with a dot, e.g:

existingQuery().and(<some joined queries>)

Otherwise it will not lead with a dot, e.g.:

and(<some joined queries>)

func (*Query) As

func (q *Query) As(names ...string) *Query

As create a reference or label

As is a special case in that it cannot lead a query in Gremlin, because it is a reserved word in Groovy. That means it's fine if it is appended to an existing query like so: existingQuery.as(), but it cannot start a query like so: as().somethingElse(). That's why there is a workaround in Germlin to start a query with as like so: __.as()

func (*Query) AsProjectBy

func (q *Query) AsProjectBy(labels ...string) *Query

AsProjectBy is a helper construct to wrap a result in a map, it a query like so: .as("isCapital").project("isCapital").by(select("isCapital")))

func (*Query) BoolProperty

func (q *Query) BoolProperty(key string, value bool) *Query

func (*Query) By

func (q *Query) By(label string) *Query

By filters down previous segement, most likely used after a count, groupCount or select statement

func (*Query) ByQuery

func (q *Query) ByQuery(subquery *Query) *Query

ByQuery filters down previous segement, most likely used after a group(), count(), groupCount() or select() statement. It takes a query rather than a label string

func (*Query) Cap

func (q *Query) Cap(label string) *Query

Cap runs queries up until this point

func (*Query) Coalesce

func (q *Query) Coalesce(query *Query) *Query

Coalesce can be used in Upsert or GetOrCreate scenarios

func (*Query) Count

func (q *Query) Count() *Query

Count how many vertices or edges are selected by the previous query.

func (*Query) CountLocal

func (q *Query) CountLocal() *Query

CountLocal is most likely used in conjuction with an aggregation query and wrapped in a By() statement

func (*Query) Drop

func (q *Query) Drop() *Query

func (*Query) E

func (q *Query) E() *Query

func (*Query) Float64Property

func (q *Query) Float64Property(key string, value float64) *Query

func (*Query) Fold

func (q *Query) Fold() *Query

func (*Query) FromRef

func (q *Query) FromRef(reference string) *Query

Point to a reference

func (*Query) GeoshapePointProperty

func (q *Query) GeoshapePointProperty(key string, lat float32, lon float32) *Query

func (*Query) Group

func (q *Query) Group() *Query

Group by values. Will most likely be followed by a `By()`

func (*Query) GroupCount

func (q *Query) GroupCount() *Query

GroupCount by values. Will most likely be followed by a `By()`

func (*Query) Has

func (q *Query) Has(key string, query *Query) *Query

Has can be used for arbitrary filtering on props

Example: Has("population", EqInt(1000))

for population == 1000

which in turn translates to Gremlin: .has("population", eq(1000))

func (*Query) HasBool

func (q *Query) HasBool(key string, value bool) *Query

func (*Query) HasLabel

func (q *Query) HasLabel(label string) *Query

Set the expected label of the vertex/edge.

func (*Query) HasProperty

func (q *Query) HasProperty(key string) *Query

Has Property checks if a property is set, regardless of its value

func (*Query) HasString

func (q *Query) HasString(key string, value string) *Query

func (*Query) In

func (q *Query) In() *Query

func (*Query) InE

func (q *Query) InE() *Query

func (*Query) InEWithLabel

func (q *Query) InEWithLabel(label string) *Query

func (*Query) InV

func (q *Query) InV() *Query

func (*Query) InWithLabel

func (q *Query) InWithLabel(label string) *Query

func (*Query) Int64Property

func (q *Query) Int64Property(key string, value int64) *Query

func (*Query) Limit

func (q *Query) Limit(limit int) *Query

Limit results

func (*Query) Match

func (q *Query) Match(queries ...*Query) *Query

Match can combine 0..n queries together

func (*Query) Max

func (q *Query) Max() *Query

Max of the underlying values

func (*Query) MaxLocal

func (q *Query) MaxLocal() *Query

MaxLocal is most likely used in conjuction with an aggregation query and wrapped in a By() statement

func (*Query) Mean

func (q *Query) Mean() *Query

Mean of the underlying values

func (*Query) MeanLocal

func (q *Query) MeanLocal() *Query

MeanLocal is most likely used in conjuction with an aggregation query and wrapped in a By() statement

func (*Query) Min

func (q *Query) Min() *Query

Min of the unerlying values

func (*Query) MinLocal

func (q *Query) MinLocal() *Query

MinLocal is most likely used in conjuction with an aggregation query and wrapped in a By() statement

func (*Query) Optional

func (q *Query) Optional(query *Query) *Query

func (*Query) Or

func (q *Query) Or(queries ...*Query) *Query

Or can combine 0..n queries together

If used on an existing query it will lead with a dot, e.g:

existingQuery().or(<some joined queries>)

Otherwise it will not lead with a dot, e.g.:

or(<some joined queries>)

func (*Query) OrderLocalByValuesLimit

func (q *Query) OrderLocalByValuesLimit(order string, limit int) *Query

OrderLocalByValuesLimit is a helper construct to select the most occuring items, like so if called with "decr", 3: .order(local).by(values, decr).limit(local, 3)

func (*Query) OrderLocalByValuesSelectKeysLimit

func (q *Query) OrderLocalByValuesSelectKeysLimit(order string, limit int) *Query

OrderLocalByValuesSelectKeysLimit is a helper construct to select the most occuring items and extract the keys, like so if called with "decr", 3: .order(local).by(values, decr).select(keys).limit(local, 3)

func (*Query) Out

func (q *Query) Out() *Query

func (*Query) OutE

func (q *Query) OutE() *Query

func (*Query) OutEWithLabel

func (q *Query) OutEWithLabel(label string) *Query

func (*Query) OutV

func (q *Query) OutV() *Query

func (*Query) OutWithLabel

func (q *Query) OutWithLabel(label string) *Query

func (*Query) Path

func (q *Query) Path() *Query

Return the travelled path

func (*Query) Project

func (q *Query) Project(label string) *Query

Project can be used to project a result into a map. Most likely used in combination with Select().By(), example: select("foo").by(project("bar")).

func (*Query) Properties

func (q *Query) Properties(names []string) *Query

func (*Query) Range

func (q *Query) Range(offset int, limit int) *Query

func (*Query) Raw

func (q *Query) Raw(query string) *Query

func (*Query) Select

func (q *Query) Select(refs []string) *Query

func (*Query) String

func (q *Query) String() string

Return the string representation of this Query.

func (*Query) StringProperty

func (q *Query) StringProperty(key string, value string) *Query

func (*Query) Sum

func (q *Query) Sum() *Query

Sum up all the underlying values

func (*Query) SumLocal

func (q *Query) SumLocal() *Query

SumLocal is most likely used in conjuction with an aggregation query and wrapped in a By() statement

func (*Query) ToQuery

func (q *Query) ToQuery(query *Query) *Query

func (*Query) Unfold

func (q *Query) Unfold() *Query

func (*Query) Union

func (q *Query) Union(queries ...*Query) *Query

Union can combine 0..n queries together

func (*Query) V

func (q *Query) V() *Query

func (*Query) Values

func (q *Query) Values(propNames []string) *Query

Get the values of these property names.

func (*Query) Where

func (q *Query) Where(queries ...*Query) *Query

Where can combine 0..n queries together

type Response

type Response struct {
	Data []Datum
}

The result of a successful Gremlin query.

func (*Response) AssertFirst

func (r *Response) AssertFirst() *Datum

func (*Response) AssertStringSlice

func (r *Response) AssertStringSlice() []string

func (*Response) First

func (r *Response) First() (*Datum, error)

func (*Response) OneInt

func (r *Response) OneInt() (int, error)

func (*Response) Vertices

func (r *Response) Vertices() ([]Vertex, error)

Check if the output of the query are all vertices.

type Vertex

type Vertex struct {
	Id         int
	Label      string
	Properties map[string]Property
}

func (*Vertex) AssertPropertyValue

func (v *Vertex) AssertPropertyValue(name string) *PropertyValue

func (*Vertex) PropertyValue

func (v *Vertex) PropertyValue(name string) *PropertyValue

Directories

Path Synopsis
_ _ *__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate.
_ _ *__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate.
_ _ *__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate.
_ _ *__ _____ __ ___ ___ __ _| |_ ___ *\ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ * \ V V / __/ (_| |\ V /| | (_| | || __/ * \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| * * Copyright © 2016 - 2019 Weaviate.

Jump to

Keyboard shortcuts

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