graph

package module
v0.0.0-...-152623e Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2017 License: MIT Imports: 5 Imported by: 0

README

graph

TODO:
  • add query language -- perhaps gremlin (already implemented by cayley)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsLogIn

func ContainsLogIn(it Iterator, val Value)

func ContainsLogOut

func ContainsLogOut(it Iterator, val Value, good bool) bool

func Height

func Height(it Iterator, until Type) int

Height is a convienence function to measure the height of an iterator tree.

func Next

func Next(it Iterator) bool

Next is a convenience function that conditionally calls the Next method of an Iterator if it is a Nexter. If the Iterator is not a Nexter, Next returns false.

func NextLogIn

func NextLogIn(it Iterator)

func NextLogOut

func NextLogOut(it Iterator, val Value, ok bool) bool

Types

type ApplyMorphism

type ApplyMorphism func(QuadStore, Iterator) Iterator

ApplyMorphism is a curried function that can generates a new iterator based on some prior iterator.

type Description

type Description struct {
	UID       uint64         `json:",omitempty"`
	Name      string         `json:",omitempty"`
	Type      Type           `json:",omitempty"`
	Tags      []string       `json:",omitempty"`
	Size      int64          `json:",omitempty"`
	Direction quad.Direction `json:",omitempty"`
	Iterator  *Description   `json:",omitempty"`
	Iterators []Description  `json:",omitempty"`
}

type FixedIterator

type FixedIterator interface {
	Iterator
	Add(Value)
}

FixedIterator wraps iterators that are modifiable by addition of fixed value sets.

type Iterator

type Iterator interface {
	Tagger() *Tagger

	// Fills a tag-to-result-value map.
	TagResults(map[string]Value)

	// Returns the current result.
	Result() Value

	// These methods are the heart and soul of the iterator, as they constitute
	// the iteration interface.
	//
	// To get the full results of iteration, do the following:
	//
	//  for graph.Next(it) {
	//  	val := it.Result()
	//  	... do things with val.
	//  	for it.NextPath() {
	//  		... find other paths to iterate
	//  	}
	//  }
	//
	// All of them should set iterator.Last to be the last returned value, to
	// make results work.
	//
	// NextPath() advances iterators that may have more than one valid result,
	// from the bottom up.
	NextPath() bool

	// Contains returns whether the value is within the set held by the iterator.
	Contains(Value) bool

	// Err returns any error that was encountered by the Iterator.
	Err() error

	// Start iteration from the beginning
	Reset()

	// Create a new iterator just like this one
	Clone() Iterator

	// These methods relate to choosing the right iterator, or optimizing an
	// iterator tree
	//
	// Stats() returns the relative costs of calling the iteration methods for
	// this iterator, as well as the size. Roughly, it will take NextCost * Size
	// "cost units" to get everything out of the iterator. This is a wibbly-wobbly
	// thing, and not exact, but a useful heuristic.
	Stats() IteratorStats

	// Helpful accessor for the number of things in the iterator. The first return
	// value is the size, and the second return value is whether that number is exact,
	// or a conservative estimate.
	Size() (int64, bool)

	// Returns a string relating to what the function of the iterator is. By
	// knowing the names of the iterators, we can devise optimization strategies.
	Type() Type

	// Optimizes an iterator. Can replace the iterator, or merely move things
	// around internally. if it chooses to replace it with a better iterator,
	// returns (the new iterator, true), if not, it returns (self, false).
	Optimize() (Iterator, bool)

	// Return a slice of the subiterators for this iterator.
	SubIterators() []Iterator

	// Return a string representation of the iterator.
	Describe() Description

	// Close the iterator and do internal cleanup.
	Close() error

	// UID returns the unique identifier of the iterator.
	UID() uint64
}

type IteratorStats

type IteratorStats struct {
	ContainsCost int64
	NextCost     int64
	Size         int64
	Next         int64
	Contains     int64
	ContainsNext int64
}

type Linkage

type Linkage struct {
	Dir   quad.Direction
	Value Value
}

Linkage is a union type representing a set of values established for a given quad direction.

type Nexter

type Nexter 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() bool

	Iterator
}

type StatsContainer

type StatsContainer struct {
	UID  uint64
	Type Type
	IteratorStats
	SubIts []StatsContainer
}

func DumpStats

func DumpStats(it Iterator) StatsContainer

type Tagger

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

func (*Tagger) Add

func (t *Tagger) Add(tag string)

Add a tag to the iterator.

func (*Tagger) AddFixed

func (t *Tagger) AddFixed(tag string, value Value)

func (*Tagger) CopyFrom

func (t *Tagger) CopyFrom(src Iterator)

func (*Tagger) CopyFromTagger

func (t *Tagger) CopyFromTagger(st *Tagger)

func (*Tagger) Fixed

func (t *Tagger) Fixed() map[string]Value

Fixed returns the fixed tags held in the tagger. The returned value must not be mutated.

func (*Tagger) Tags

func (t *Tagger) Tags() []string

Tags returns the tags held in the tagger. The returned value must not be mutated.

type Type

type Type int

Type enumerates the set of Iterator types.

const (
	Invalid Type = iota
	All
	And
	Or
	HasA
	LinksTo
	Comparison
	Null
	Fixed
	Not
	Optional
	Materialize
	Unique
)

These are the iterator types, defined as constants

func RegisterIterator

func RegisterIterator(name string) Type

RegisterIterator adds a new iterator type to the set of acceptable types, returning the registered Type. Calls to Register are idempotent and must be made prior to use of the iterator. The conventional approach for use is to include a call to Register in a package init() function, saving the Type to a private package var.

func (*Type) MarshalText

func (t *Type) MarshalText() (text []byte, err error)

func (Type) String

func (t Type) String() string

String returns a string representation of the Type.

func (*Type) UnmarshalText

func (t *Type) UnmarshalText(text []byte) error

Directories

Path Synopsis
query

Jump to

Keyboard shortcuts

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