repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
cayleygraph/cayley
quad/value.go
RegisterStringConversion
func RegisterStringConversion(dataType IRI, fnc StringConversion) { if fnc == nil { delete(knownConversions, dataType) } else { knownConversions[dataType] = fnc if short := dataType.Short(); short != dataType { knownConversions[short] = fnc } if full := dataType.Full(); full != dataType { knownConversions[full] = fnc } } }
go
func RegisterStringConversion(dataType IRI, fnc StringConversion) { if fnc == nil { delete(knownConversions, dataType) } else { knownConversions[dataType] = fnc if short := dataType.Short(); short != dataType { knownConversions[short] = fnc } if full := dataType.Full(); full != dataType { knownConversions[full] = fnc } } }
[ "func", "RegisterStringConversion", "(", "dataType", "IRI", ",", "fnc", "StringConversion", ")", "{", "if", "fnc", "==", "nil", "{", "delete", "(", "knownConversions", ",", "dataType", ")", "\n", "}", "else", "{", "knownConversions", "[", "dataType", "]", "=", "fnc", "\n", "if", "short", ":=", "dataType", ".", "Short", "(", ")", ";", "short", "!=", "dataType", "{", "knownConversions", "[", "short", "]", "=", "fnc", "\n", "}", "\n", "if", "full", ":=", "dataType", ".", "Full", "(", ")", ";", "full", "!=", "dataType", "{", "knownConversions", "[", "full", "]", "=", "fnc", "\n", "}", "\n", "}", "\n", "}" ]
// RegisterStringConversion will register an automatic conversion of // TypedString values with provided type to a native equivalent such as Int, Time, etc. // // If fnc is nil, automatic conversion from selected type will be removed.
[ "RegisterStringConversion", "will", "register", "an", "automatic", "conversion", "of", "TypedString", "values", "with", "provided", "type", "to", "a", "native", "equivalent", "such", "as", "Int", "Time", "etc", ".", "If", "fnc", "is", "nil", "automatic", "conversion", "from", "selected", "type", "will", "be", "removed", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/value.go#L299-L311
train
cayleygraph/cayley
quad/value.go
Next
func (s *Sequence) Next() BNode { n := atomic.AddUint64(&s.last, 1) return BNode(fmt.Sprintf("n%d", n)) }
go
func (s *Sequence) Next() BNode { n := atomic.AddUint64(&s.last, 1) return BNode(fmt.Sprintf("n%d", n)) }
[ "func", "(", "s", "*", "Sequence", ")", "Next", "(", ")", "BNode", "{", "n", ":=", "atomic", ".", "AddUint64", "(", "&", "s", ".", "last", ",", "1", ")", "\n", "return", "BNode", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "n", ")", ")", "\n", "}" ]
// Next returns a new blank node. It's safe for concurrent use.
[ "Next", "returns", "a", "new", "blank", "node", ".", "It", "s", "safe", "for", "concurrent", "use", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/value.go#L438-L441
train
cayleygraph/cayley
graph/iterator/hasa.go
NewHasA
func NewHasA(qs graph.QuadStore, subIt graph.Iterator, d quad.Direction) *HasA { return &HasA{ uid: NextUID(), qs: qs, primaryIt: subIt, dir: d, } }
go
func NewHasA(qs graph.QuadStore, subIt graph.Iterator, d quad.Direction) *HasA { return &HasA{ uid: NextUID(), qs: qs, primaryIt: subIt, dir: d, } }
[ "func", "NewHasA", "(", "qs", "graph", ".", "QuadStore", ",", "subIt", "graph", ".", "Iterator", ",", "d", "quad", ".", "Direction", ")", "*", "HasA", "{", "return", "&", "HasA", "{", "uid", ":", "NextUID", "(", ")", ",", "qs", ":", "qs", ",", "primaryIt", ":", "subIt", ",", "dir", ":", "d", ",", "}", "\n", "}" ]
// Construct a new HasA iterator, given the quad subiterator, and the quad // direction for which it stands.
[ "Construct", "a", "new", "HasA", "iterator", "given", "the", "quad", "subiterator", "and", "the", "quad", "direction", "for", "which", "it", "stands", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/hasa.go#L64-L71
train
cayleygraph/cayley
graph/iterator/hasa.go
TagResults
func (it *HasA) TagResults(dst map[string]graph.Value) { it.tags.TagResult(dst, it.Result()) it.primaryIt.TagResults(dst) }
go
func (it *HasA) TagResults(dst map[string]graph.Value) { it.tags.TagResult(dst, it.Result()) it.primaryIt.TagResults(dst) }
[ "func", "(", "it", "*", "HasA", ")", "TagResults", "(", "dst", "map", "[", "string", "]", "graph", ".", "Value", ")", "{", "it", ".", "tags", ".", "TagResult", "(", "dst", ",", "it", ".", "Result", "(", ")", ")", "\n\n", "it", ".", "primaryIt", ".", "TagResults", "(", "dst", ")", "\n", "}" ]
// Pass the TagResults down the chain.
[ "Pass", "the", "TagResults", "down", "the", "chain", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/hasa.go#L124-L128
train
cayleygraph/cayley
graph/iterator/hasa.go
NextPath
func (it *HasA) NextPath(ctx context.Context) bool { // Order here is important. If the subiterator has a NextPath, then we // need do nothing -- there is a next result, and we shouldn't move forward. // However, we then need to get the next result from our last Contains(). // // The upshot is, the end of NextPath() bubbles up from the bottom of the // iterator tree up, and we need to respect that. if clog.V(4) { clog.Infof("HASA %v NextPath", it.UID()) } if it.primaryIt.NextPath(ctx) { return true } it.err = it.primaryIt.Err() if it.err != nil { return false } result := it.NextContains(ctx) // Sets it.err if there's an error if it.err != nil { return false } if clog.V(4) { clog.Infof("HASA %v NextPath Returns %v", it.UID(), result) } return result }
go
func (it *HasA) NextPath(ctx context.Context) bool { // Order here is important. If the subiterator has a NextPath, then we // need do nothing -- there is a next result, and we shouldn't move forward. // However, we then need to get the next result from our last Contains(). // // The upshot is, the end of NextPath() bubbles up from the bottom of the // iterator tree up, and we need to respect that. if clog.V(4) { clog.Infof("HASA %v NextPath", it.UID()) } if it.primaryIt.NextPath(ctx) { return true } it.err = it.primaryIt.Err() if it.err != nil { return false } result := it.NextContains(ctx) // Sets it.err if there's an error if it.err != nil { return false } if clog.V(4) { clog.Infof("HASA %v NextPath Returns %v", it.UID(), result) } return result }
[ "func", "(", "it", "*", "HasA", ")", "NextPath", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "// Order here is important. If the subiterator has a NextPath, then we", "// need do nothing -- there is a next result, and we shouldn't move forward.", "// However, we then need to get the next result from our last Contains().", "//", "// The upshot is, the end of NextPath() bubbles up from the bottom of the", "// iterator tree up, and we need to respect that.", "if", "clog", ".", "V", "(", "4", ")", "{", "clog", ".", "Infof", "(", "\"", "\"", ",", "it", ".", "UID", "(", ")", ")", "\n", "}", "\n", "if", "it", ".", "primaryIt", ".", "NextPath", "(", "ctx", ")", "{", "return", "true", "\n", "}", "\n", "it", ".", "err", "=", "it", ".", "primaryIt", ".", "Err", "(", ")", "\n", "if", "it", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n\n", "result", ":=", "it", ".", "NextContains", "(", "ctx", ")", "// Sets it.err if there's an error", "\n", "if", "it", ".", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "if", "clog", ".", "V", "(", "4", ")", "{", "clog", ".", "Infof", "(", "\"", "\"", ",", "it", ".", "UID", "(", ")", ",", "result", ")", "\n", "}", "\n", "return", "result", "\n", "}" ]
// Get the next result that matches this branch.
[ "Get", "the", "next", "result", "that", "matches", "this", "branch", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/hasa.go#L178-L204
train
cayleygraph/cayley
graph/iterator/hasa.go
Next
func (it *HasA) Next(ctx context.Context) bool { graph.NextLogIn(it) it.runstats.Next += 1 if it.resultIt != nil { it.resultIt.Close() } if !it.primaryIt.Next(ctx) { it.err = it.primaryIt.Err() return graph.NextLogOut(it, false) } tID := it.primaryIt.Result() val := it.qs.QuadDirection(tID, it.dir) it.result = val return graph.NextLogOut(it, true) }
go
func (it *HasA) Next(ctx context.Context) bool { graph.NextLogIn(it) it.runstats.Next += 1 if it.resultIt != nil { it.resultIt.Close() } if !it.primaryIt.Next(ctx) { it.err = it.primaryIt.Err() return graph.NextLogOut(it, false) } tID := it.primaryIt.Result() val := it.qs.QuadDirection(tID, it.dir) it.result = val return graph.NextLogOut(it, true) }
[ "func", "(", "it", "*", "HasA", ")", "Next", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "graph", ".", "NextLogIn", "(", "it", ")", "\n", "it", ".", "runstats", ".", "Next", "+=", "1", "\n", "if", "it", ".", "resultIt", "!=", "nil", "{", "it", ".", "resultIt", ".", "Close", "(", ")", "\n", "}", "\n\n", "if", "!", "it", ".", "primaryIt", ".", "Next", "(", "ctx", ")", "{", "it", ".", "err", "=", "it", ".", "primaryIt", ".", "Err", "(", ")", "\n", "return", "graph", ".", "NextLogOut", "(", "it", ",", "false", ")", "\n", "}", "\n", "tID", ":=", "it", ".", "primaryIt", ".", "Result", "(", ")", "\n", "val", ":=", "it", ".", "qs", ".", "QuadDirection", "(", "tID", ",", "it", ".", "dir", ")", "\n", "it", ".", "result", "=", "val", "\n", "return", "graph", ".", "NextLogOut", "(", "it", ",", "true", ")", "\n", "}" ]
// Next advances the iterator. This is simpler than Contains. We have a // subiterator we can get a value from, and we can take that resultant quad, // pull our direction out of it, and return that.
[ "Next", "advances", "the", "iterator", ".", "This", "is", "simpler", "than", "Contains", ".", "We", "have", "a", "subiterator", "we", "can", "get", "a", "value", "from", "and", "we", "can", "take", "that", "resultant", "quad", "pull", "our", "direction", "out", "of", "it", "and", "return", "that", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/hasa.go#L209-L224
train
cayleygraph/cayley
quad/rw.go
Copy
func Copy(dst Writer, src Reader) (n int, err error) { if bw, ok := dst.(BatchWriter); ok { return CopyBatch(bw, src, 0) } var q Quad for { q, err = src.ReadQuad() if err == io.EOF { err = nil return } else if err != nil { return } if err = dst.WriteQuad(q); err != nil { return } n++ } }
go
func Copy(dst Writer, src Reader) (n int, err error) { if bw, ok := dst.(BatchWriter); ok { return CopyBatch(bw, src, 0) } var q Quad for { q, err = src.ReadQuad() if err == io.EOF { err = nil return } else if err != nil { return } if err = dst.WriteQuad(q); err != nil { return } n++ } }
[ "func", "Copy", "(", "dst", "Writer", ",", "src", "Reader", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "bw", ",", "ok", ":=", "dst", ".", "(", "BatchWriter", ")", ";", "ok", "{", "return", "CopyBatch", "(", "bw", ",", "src", ",", "0", ")", "\n", "}", "\n", "var", "q", "Quad", "\n", "for", "{", "q", ",", "err", "=", "src", ".", "ReadQuad", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "err", "=", "nil", "\n", "return", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "if", "err", "=", "dst", ".", "WriteQuad", "(", "q", ")", ";", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "n", "++", "\n", "}", "\n", "}" ]
// Copy will copy all quads from src to dst. It returns copied quads count and an error, if it failed. // // Copy will try to cast dst to BatchWriter and will switch to CopyBatch implementation in case of success.
[ "Copy", "will", "copy", "all", "quads", "from", "src", "to", "dst", ".", "It", "returns", "copied", "quads", "count", "and", "an", "error", "if", "it", "failed", ".", "Copy", "will", "try", "to", "cast", "dst", "to", "BatchWriter", "and", "will", "switch", "to", "CopyBatch", "implementation", "in", "case", "of", "success", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/rw.go#L86-L104
train
cayleygraph/cayley
quad/rw.go
CopyBatch
func CopyBatch(dst BatchWriter, src Reader, batchSize int) (cnt int, err error) { if batchSize <= 0 { batchSize = DefaultBatch } buf := make([]Quad, batchSize) bsrc, ok := src.(BatchReader) if !ok { bsrc = batchReader{src} } var n int for err == nil { n, err = bsrc.ReadQuads(buf) if err != nil && err != io.EOF { return } eof := err == io.EOF n, err = dst.WriteQuads(buf[:n]) cnt += n if eof { break } } return }
go
func CopyBatch(dst BatchWriter, src Reader, batchSize int) (cnt int, err error) { if batchSize <= 0 { batchSize = DefaultBatch } buf := make([]Quad, batchSize) bsrc, ok := src.(BatchReader) if !ok { bsrc = batchReader{src} } var n int for err == nil { n, err = bsrc.ReadQuads(buf) if err != nil && err != io.EOF { return } eof := err == io.EOF n, err = dst.WriteQuads(buf[:n]) cnt += n if eof { break } } return }
[ "func", "CopyBatch", "(", "dst", "BatchWriter", ",", "src", "Reader", ",", "batchSize", "int", ")", "(", "cnt", "int", ",", "err", "error", ")", "{", "if", "batchSize", "<=", "0", "{", "batchSize", "=", "DefaultBatch", "\n", "}", "\n", "buf", ":=", "make", "(", "[", "]", "Quad", ",", "batchSize", ")", "\n", "bsrc", ",", "ok", ":=", "src", ".", "(", "BatchReader", ")", "\n", "if", "!", "ok", "{", "bsrc", "=", "batchReader", "{", "src", "}", "\n", "}", "\n", "var", "n", "int", "\n", "for", "err", "==", "nil", "{", "n", ",", "err", "=", "bsrc", ".", "ReadQuads", "(", "buf", ")", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "io", ".", "EOF", "{", "return", "\n", "}", "\n", "eof", ":=", "err", "==", "io", ".", "EOF", "\n", "n", ",", "err", "=", "dst", ".", "WriteQuads", "(", "buf", "[", ":", "n", "]", ")", "\n", "cnt", "+=", "n", "\n", "if", "eof", "{", "break", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// CopyBatch will copy all quads from src to dst in a batches of batchSize. // It returns copied quads count and an error, if it failed. // // If batchSize <= 0 default batch size will be used.
[ "CopyBatch", "will", "copy", "all", "quads", "from", "src", "to", "dst", "in", "a", "batches", "of", "batchSize", ".", "It", "returns", "copied", "quads", "count", "and", "an", "error", "if", "it", "failed", ".", "If", "batchSize", "<", "=", "0", "default", "batch", "size", "will", "be", "used", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/rw.go#L126-L149
train
cayleygraph/cayley
quad/rw.go
ReadAll
func ReadAll(r Reader) (arr []Quad, err error) { switch rt := r.(type) { case *Quads: arr = make([]Quad, len(rt.s)) copy(arr, rt.s) rt.s = nil return } var q Quad for { q, err = r.ReadQuad() if err == io.EOF { return arr, nil } else if err != nil { return nil, err } arr = append(arr, q) } }
go
func ReadAll(r Reader) (arr []Quad, err error) { switch rt := r.(type) { case *Quads: arr = make([]Quad, len(rt.s)) copy(arr, rt.s) rt.s = nil return } var q Quad for { q, err = r.ReadQuad() if err == io.EOF { return arr, nil } else if err != nil { return nil, err } arr = append(arr, q) } }
[ "func", "ReadAll", "(", "r", "Reader", ")", "(", "arr", "[", "]", "Quad", ",", "err", "error", ")", "{", "switch", "rt", ":=", "r", ".", "(", "type", ")", "{", "case", "*", "Quads", ":", "arr", "=", "make", "(", "[", "]", "Quad", ",", "len", "(", "rt", ".", "s", ")", ")", "\n", "copy", "(", "arr", ",", "rt", ".", "s", ")", "\n", "rt", ".", "s", "=", "nil", "\n", "return", "\n", "}", "\n", "var", "q", "Quad", "\n", "for", "{", "q", ",", "err", "=", "r", ".", "ReadQuad", "(", ")", "\n", "if", "err", "==", "io", ".", "EOF", "{", "return", "arr", ",", "nil", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "arr", "=", "append", "(", "arr", ",", "q", ")", "\n", "}", "\n", "}" ]
// ReadAll reads all quads from r until EOF. // It returns a slice with all quads that were read and an error, if any.
[ "ReadAll", "reads", "all", "quads", "from", "r", "until", "EOF", ".", "It", "returns", "a", "slice", "with", "all", "quads", "that", "were", "read", "and", "an", "error", "if", "any", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/rw.go#L153-L171
train
cayleygraph/cayley
quad/quad.go
Make
func Make(subject, predicate, object, label interface{}) (q Quad) { var ok bool if q.Subject, ok = AsValue(subject); !ok { q.Subject = String(fmt.Sprint(subject)) } if q.Predicate, ok = AsValue(predicate); !ok { q.Predicate = String(fmt.Sprint(predicate)) } if q.Object, ok = AsValue(object); !ok { q.Object = String(fmt.Sprint(object)) } if q.Label, ok = AsValue(label); !ok { q.Label = String(fmt.Sprint(label)) } return }
go
func Make(subject, predicate, object, label interface{}) (q Quad) { var ok bool if q.Subject, ok = AsValue(subject); !ok { q.Subject = String(fmt.Sprint(subject)) } if q.Predicate, ok = AsValue(predicate); !ok { q.Predicate = String(fmt.Sprint(predicate)) } if q.Object, ok = AsValue(object); !ok { q.Object = String(fmt.Sprint(object)) } if q.Label, ok = AsValue(label); !ok { q.Label = String(fmt.Sprint(label)) } return }
[ "func", "Make", "(", "subject", ",", "predicate", ",", "object", ",", "label", "interface", "{", "}", ")", "(", "q", "Quad", ")", "{", "var", "ok", "bool", "\n", "if", "q", ".", "Subject", ",", "ok", "=", "AsValue", "(", "subject", ")", ";", "!", "ok", "{", "q", ".", "Subject", "=", "String", "(", "fmt", ".", "Sprint", "(", "subject", ")", ")", "\n", "}", "\n", "if", "q", ".", "Predicate", ",", "ok", "=", "AsValue", "(", "predicate", ")", ";", "!", "ok", "{", "q", ".", "Predicate", "=", "String", "(", "fmt", ".", "Sprint", "(", "predicate", ")", ")", "\n", "}", "\n", "if", "q", ".", "Object", ",", "ok", "=", "AsValue", "(", "object", ")", ";", "!", "ok", "{", "q", ".", "Object", "=", "String", "(", "fmt", ".", "Sprint", "(", "object", ")", ")", "\n", "}", "\n", "if", "q", ".", "Label", ",", "ok", "=", "AsValue", "(", "label", ")", ";", "!", "ok", "{", "q", ".", "Label", "=", "String", "(", "fmt", ".", "Sprint", "(", "label", ")", ")", "\n", "}", "\n", "return", "\n", "}" ]
// Make creates a quad with provided values.
[ "Make", "creates", "a", "quad", "with", "provided", "values", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/quad.go#L51-L66
train
cayleygraph/cayley
quad/quad.go
MakeIRI
func MakeIRI(subject, predicate, object, label string) (q Quad) { if subject != "" { q.Subject = IRI(subject) } if predicate != "" { q.Predicate = IRI(predicate) } if object != "" { q.Object = IRI(object) } if label != "" { q.Label = IRI(label) } return }
go
func MakeIRI(subject, predicate, object, label string) (q Quad) { if subject != "" { q.Subject = IRI(subject) } if predicate != "" { q.Predicate = IRI(predicate) } if object != "" { q.Object = IRI(object) } if label != "" { q.Label = IRI(label) } return }
[ "func", "MakeIRI", "(", "subject", ",", "predicate", ",", "object", ",", "label", "string", ")", "(", "q", "Quad", ")", "{", "if", "subject", "!=", "\"", "\"", "{", "q", ".", "Subject", "=", "IRI", "(", "subject", ")", "\n", "}", "\n", "if", "predicate", "!=", "\"", "\"", "{", "q", ".", "Predicate", "=", "IRI", "(", "predicate", ")", "\n", "}", "\n", "if", "object", "!=", "\"", "\"", "{", "q", ".", "Object", "=", "IRI", "(", "object", ")", "\n", "}", "\n", "if", "label", "!=", "\"", "\"", "{", "q", ".", "Label", "=", "IRI", "(", "label", ")", "\n", "}", "\n", "return", "\n", "}" ]
// MakeIRI creates a quad with provided IRI values.
[ "MakeIRI", "creates", "a", "quad", "with", "provided", "IRI", "values", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/quad.go#L88-L102
train
cayleygraph/cayley
quad/quad.go
Get
func (q Quad) Get(d Direction) Value { switch d { case Subject: return q.Subject case Predicate: return q.Predicate case Label: return q.Label case Object: return q.Object default: panic(d.String()) } }
go
func (q Quad) Get(d Direction) Value { switch d { case Subject: return q.Subject case Predicate: return q.Predicate case Label: return q.Label case Object: return q.Object default: panic(d.String()) } }
[ "func", "(", "q", "Quad", ")", "Get", "(", "d", "Direction", ")", "Value", "{", "switch", "d", "{", "case", "Subject", ":", "return", "q", ".", "Subject", "\n", "case", "Predicate", ":", "return", "q", ".", "Predicate", "\n", "case", "Label", ":", "return", "q", ".", "Label", "\n", "case", "Object", ":", "return", "q", ".", "Object", "\n", "default", ":", "panic", "(", "d", ".", "String", "(", ")", ")", "\n", "}", "\n", "}" ]
// Per-field accessor for quads.
[ "Per", "-", "field", "accessor", "for", "quads", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/quad.go#L211-L224
train
cayleygraph/cayley
quad/quad.go
GetString
func (q Quad) GetString(d Direction) string { switch d { case Subject: return StringOf(q.Subject) case Predicate: return StringOf(q.Predicate) case Object: return StringOf(q.Object) case Label: return StringOf(q.Label) default: panic(d.String()) } }
go
func (q Quad) GetString(d Direction) string { switch d { case Subject: return StringOf(q.Subject) case Predicate: return StringOf(q.Predicate) case Object: return StringOf(q.Object) case Label: return StringOf(q.Label) default: panic(d.String()) } }
[ "func", "(", "q", "Quad", ")", "GetString", "(", "d", "Direction", ")", "string", "{", "switch", "d", "{", "case", "Subject", ":", "return", "StringOf", "(", "q", ".", "Subject", ")", "\n", "case", "Predicate", ":", "return", "StringOf", "(", "q", ".", "Predicate", ")", "\n", "case", "Object", ":", "return", "StringOf", "(", "q", ".", "Object", ")", "\n", "case", "Label", ":", "return", "StringOf", "(", "q", ".", "Label", ")", "\n", "default", ":", "panic", "(", "d", ".", "String", "(", ")", ")", "\n", "}", "\n", "}" ]
// Per-field accessor for quads that returns strings instead of values.
[ "Per", "-", "field", "accessor", "for", "quads", "that", "returns", "strings", "instead", "of", "values", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/quad.go#L242-L255
train
cayleygraph/cayley
quad/quad.go
String
func (q Quad) String() string { return fmt.Sprintf("%v -- %v -> %v", q.Subject, q.Predicate, q.Object) }
go
func (q Quad) String() string { return fmt.Sprintf("%v -- %v -> %v", q.Subject, q.Predicate, q.Object) }
[ "func", "(", "q", "Quad", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "q", ".", "Subject", ",", "q", ".", "Predicate", ",", "q", ".", "Object", ")", "\n", "}" ]
// Pretty-prints a quad.
[ "Pretty", "-", "prints", "a", "quad", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/quad.go#L258-L260
train
cayleygraph/cayley
quad/quad.go
NQuad
func (q Quad) NQuad() string { if q.Label == nil || q.Label.String() == "" { return fmt.Sprintf("%s %s %s .", q.Subject, q.Predicate, q.Object) } return fmt.Sprintf("%s %s %s %s .", q.Subject, q.Predicate, q.Object, q.Label) }
go
func (q Quad) NQuad() string { if q.Label == nil || q.Label.String() == "" { return fmt.Sprintf("%s %s %s .", q.Subject, q.Predicate, q.Object) } return fmt.Sprintf("%s %s %s %s .", q.Subject, q.Predicate, q.Object, q.Label) }
[ "func", "(", "q", "Quad", ")", "NQuad", "(", ")", "string", "{", "if", "q", ".", "Label", "==", "nil", "||", "q", ".", "Label", ".", "String", "(", ")", "==", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "q", ".", "Subject", ",", "q", ".", "Predicate", ",", "q", ".", "Object", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "q", ".", "Subject", ",", "q", ".", "Predicate", ",", "q", ".", "Object", ",", "q", ".", "Label", ")", "\n", "}" ]
// Prints a quad in N-Quad format.
[ "Prints", "a", "quad", "in", "N", "-", "Quad", "format", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/quad.go#L267-L272
train
cayleygraph/cayley
graph/iterator/or.go
TagResults
func (it *Or) TagResults(dst map[string]graph.Value) { it.tags.TagResult(dst, it.Result()) it.internalIterators[it.currentIterator].TagResults(dst) }
go
func (it *Or) TagResults(dst map[string]graph.Value) { it.tags.TagResult(dst, it.Result()) it.internalIterators[it.currentIterator].TagResults(dst) }
[ "func", "(", "it", "*", "Or", ")", "TagResults", "(", "dst", "map", "[", "string", "]", "graph", ".", "Value", ")", "{", "it", ".", "tags", ".", "TagResult", "(", "dst", ",", "it", ".", "Result", "(", ")", ")", "\n\n", "it", ".", "internalIterators", "[", "it", ".", "currentIterator", "]", ".", "TagResults", "(", "dst", ")", "\n", "}" ]
// Overrides BaseIterator TagResults, as it needs to add it's own results and // recurse down it's subiterators.
[ "Overrides", "BaseIterator", "TagResults", "as", "it", "needs", "to", "add", "it", "s", "own", "results", "and", "recurse", "down", "it", "s", "subiterators", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/or.go#L100-L104
train
cayleygraph/cayley
graph/iterator/or.go
AddSubIterator
func (it *Or) AddSubIterator(sub graph.Iterator) { it.internalIterators = append(it.internalIterators, sub) }
go
func (it *Or) AddSubIterator(sub graph.Iterator) { it.internalIterators = append(it.internalIterators, sub) }
[ "func", "(", "it", "*", "Or", ")", "AddSubIterator", "(", "sub", "graph", ".", "Iterator", ")", "{", "it", ".", "internalIterators", "=", "append", "(", "it", ".", "internalIterators", ",", "sub", ")", "\n", "}" ]
// Add a subiterator to this Or graph.iterator. Order matters.
[ "Add", "a", "subiterator", "to", "this", "Or", "graph", ".", "iterator", ".", "Order", "matters", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/or.go#L111-L113
train
cayleygraph/cayley
graph/iterator/or.go
subItsContain
func (it *Or) subItsContain(ctx context.Context, val graph.Value) (bool, error) { var subIsGood = false for i, sub := range it.internalIterators { subIsGood = sub.Contains(ctx, val) if subIsGood { it.currentIterator = i break } err := sub.Err() if err != nil { return false, err } } return subIsGood, nil }
go
func (it *Or) subItsContain(ctx context.Context, val graph.Value) (bool, error) { var subIsGood = false for i, sub := range it.internalIterators { subIsGood = sub.Contains(ctx, val) if subIsGood { it.currentIterator = i break } err := sub.Err() if err != nil { return false, err } } return subIsGood, nil }
[ "func", "(", "it", "*", "Or", ")", "subItsContain", "(", "ctx", "context", ".", "Context", ",", "val", "graph", ".", "Value", ")", "(", "bool", ",", "error", ")", "{", "var", "subIsGood", "=", "false", "\n", "for", "i", ",", "sub", ":=", "range", "it", ".", "internalIterators", "{", "subIsGood", "=", "sub", ".", "Contains", "(", "ctx", ",", "val", ")", "\n", "if", "subIsGood", "{", "it", ".", "currentIterator", "=", "i", "\n", "break", "\n", "}", "\n\n", "err", ":=", "sub", ".", "Err", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "}", "\n", "return", "subIsGood", ",", "nil", "\n", "}" ]
// Checks a value against the iterators, in order.
[ "Checks", "a", "value", "against", "the", "iterators", "in", "order", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/or.go#L162-L177
train
cayleygraph/cayley
graph/iterator/or.go
Contains
func (it *Or) Contains(ctx context.Context, val graph.Value) bool { graph.ContainsLogIn(it, val) anyGood, err := it.subItsContain(ctx, val) if err != nil { it.err = err return false } else if !anyGood { return graph.ContainsLogOut(it, val, false) } it.result = val return graph.ContainsLogOut(it, val, true) }
go
func (it *Or) Contains(ctx context.Context, val graph.Value) bool { graph.ContainsLogIn(it, val) anyGood, err := it.subItsContain(ctx, val) if err != nil { it.err = err return false } else if !anyGood { return graph.ContainsLogOut(it, val, false) } it.result = val return graph.ContainsLogOut(it, val, true) }
[ "func", "(", "it", "*", "Or", ")", "Contains", "(", "ctx", "context", ".", "Context", ",", "val", "graph", ".", "Value", ")", "bool", "{", "graph", ".", "ContainsLogIn", "(", "it", ",", "val", ")", "\n", "anyGood", ",", "err", ":=", "it", ".", "subItsContain", "(", "ctx", ",", "val", ")", "\n", "if", "err", "!=", "nil", "{", "it", ".", "err", "=", "err", "\n", "return", "false", "\n", "}", "else", "if", "!", "anyGood", "{", "return", "graph", ".", "ContainsLogOut", "(", "it", ",", "val", ",", "false", ")", "\n", "}", "\n", "it", ".", "result", "=", "val", "\n", "return", "graph", ".", "ContainsLogOut", "(", "it", ",", "val", ",", "true", ")", "\n", "}" ]
// Check a value against the entire graph.iterator, in order.
[ "Check", "a", "value", "against", "the", "entire", "graph", ".", "iterator", "in", "order", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/or.go#L180-L191
train
cayleygraph/cayley
graph/iterator/or.go
Size
func (it *Or) Size() (int64, bool) { var val int64 var b bool if it.isShortCircuiting { val = 0 b = true for _, sub := range it.internalIterators { newval, newb := sub.Size() if val < newval { val = newval } b = newb && b } } else { val = 0 b = true for _, sub := range it.internalIterators { newval, newb := sub.Size() val += newval b = newb && b } } return val, b }
go
func (it *Or) Size() (int64, bool) { var val int64 var b bool if it.isShortCircuiting { val = 0 b = true for _, sub := range it.internalIterators { newval, newb := sub.Size() if val < newval { val = newval } b = newb && b } } else { val = 0 b = true for _, sub := range it.internalIterators { newval, newb := sub.Size() val += newval b = newb && b } } return val, b }
[ "func", "(", "it", "*", "Or", ")", "Size", "(", ")", "(", "int64", ",", "bool", ")", "{", "var", "val", "int64", "\n", "var", "b", "bool", "\n", "if", "it", ".", "isShortCircuiting", "{", "val", "=", "0", "\n", "b", "=", "true", "\n", "for", "_", ",", "sub", ":=", "range", "it", ".", "internalIterators", "{", "newval", ",", "newb", ":=", "sub", ".", "Size", "(", ")", "\n", "if", "val", "<", "newval", "{", "val", "=", "newval", "\n", "}", "\n", "b", "=", "newb", "&&", "b", "\n", "}", "\n", "}", "else", "{", "val", "=", "0", "\n", "b", "=", "true", "\n", "for", "_", ",", "sub", ":=", "range", "it", ".", "internalIterators", "{", "newval", ",", "newb", ":=", "sub", ".", "Size", "(", ")", "\n", "val", "+=", "newval", "\n", "b", "=", "newb", "&&", "b", "\n", "}", "\n", "}", "\n", "return", "val", ",", "b", "\n", "}" ]
// Returns the approximate size of the Or graph.iterator. Because we're dealing // with a union, we know that the largest we can be is the sum of all the iterators, // or in the case of short-circuiting, the longest.
[ "Returns", "the", "approximate", "size", "of", "the", "Or", "graph", ".", "iterator", ".", "Because", "we", "re", "dealing", "with", "a", "union", "we", "know", "that", "the", "largest", "we", "can", "be", "is", "the", "sum", "of", "all", "the", "iterators", "or", "in", "the", "case", "of", "short", "-", "circuiting", "the", "longest", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/or.go#L196-L219
train
cayleygraph/cayley
graph/iterator/or.go
Close
func (it *Or) Close() error { it.cleanUp() var err error for _, sub := range it.internalIterators { _err := sub.Close() if _err != nil && err == nil { err = _err } } return err }
go
func (it *Or) Close() error { it.cleanUp() var err error for _, sub := range it.internalIterators { _err := sub.Close() if _err != nil && err == nil { err = _err } } return err }
[ "func", "(", "it", "*", "Or", ")", "Close", "(", ")", "error", "{", "it", ".", "cleanUp", "(", ")", "\n\n", "var", "err", "error", "\n", "for", "_", ",", "sub", ":=", "range", "it", ".", "internalIterators", "{", "_err", ":=", "sub", ".", "Close", "(", ")", "\n", "if", "_err", "!=", "nil", "&&", "err", "==", "nil", "{", "err", "=", "_err", "\n", "}", "\n", "}", "\n\n", "return", "err", "\n", "}" ]
// Close this graph.iterator, and, by extension, close the subiterators. // Close should be idempotent, and it follows that if it's subiterators // follow this contract, the Or follows the contract. It closes all // subiterators it can, but returns the first error it encounters.
[ "Close", "this", "graph", ".", "iterator", "and", "by", "extension", "close", "the", "subiterators", ".", "Close", "should", "be", "idempotent", "and", "it", "follows", "that", "if", "it", "s", "subiterators", "follow", "this", "contract", "the", "Or", "follows", "the", "contract", ".", "It", "closes", "all", "subiterators", "it", "can", "but", "returns", "the", "first", "error", "it", "encounters", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/or.go#L244-L256
train
cayleygraph/cayley
graph/iterator/linksto.go
NewLinksTo
func NewLinksTo(qs graph.QuadStore, it graph.Iterator, d quad.Direction) *LinksTo { return &LinksTo{ uid: NextUID(), qs: qs, primaryIt: it, dir: d, nextIt: &Null{}, } }
go
func NewLinksTo(qs graph.QuadStore, it graph.Iterator, d quad.Direction) *LinksTo { return &LinksTo{ uid: NextUID(), qs: qs, primaryIt: it, dir: d, nextIt: &Null{}, } }
[ "func", "NewLinksTo", "(", "qs", "graph", ".", "QuadStore", ",", "it", "graph", ".", "Iterator", ",", "d", "quad", ".", "Direction", ")", "*", "LinksTo", "{", "return", "&", "LinksTo", "{", "uid", ":", "NextUID", "(", ")", ",", "qs", ":", "qs", ",", "primaryIt", ":", "it", ",", "dir", ":", "d", ",", "nextIt", ":", "&", "Null", "{", "}", ",", "}", "\n", "}" ]
// Construct a new LinksTo iterator around a direction and a subiterator of // nodes.
[ "Construct", "a", "new", "LinksTo", "iterator", "around", "a", "direction", "and", "a", "subiterator", "of", "nodes", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/linksto.go#L59-L67
train
cayleygraph/cayley
graph/iterator/linksto.go
Contains
func (it *LinksTo) Contains(ctx context.Context, val graph.Value) bool { graph.ContainsLogIn(it, val) it.runstats.Contains += 1 node := it.qs.QuadDirection(val, it.dir) if it.primaryIt.Contains(ctx, node) { it.result = val return graph.ContainsLogOut(it, val, true) } it.err = it.primaryIt.Err() return graph.ContainsLogOut(it, val, false) }
go
func (it *LinksTo) Contains(ctx context.Context, val graph.Value) bool { graph.ContainsLogIn(it, val) it.runstats.Contains += 1 node := it.qs.QuadDirection(val, it.dir) if it.primaryIt.Contains(ctx, node) { it.result = val return graph.ContainsLogOut(it, val, true) } it.err = it.primaryIt.Err() return graph.ContainsLogOut(it, val, false) }
[ "func", "(", "it", "*", "LinksTo", ")", "Contains", "(", "ctx", "context", ".", "Context", ",", "val", "graph", ".", "Value", ")", "bool", "{", "graph", ".", "ContainsLogIn", "(", "it", ",", "val", ")", "\n", "it", ".", "runstats", ".", "Contains", "+=", "1", "\n", "node", ":=", "it", ".", "qs", ".", "QuadDirection", "(", "val", ",", "it", ".", "dir", ")", "\n", "if", "it", ".", "primaryIt", ".", "Contains", "(", "ctx", ",", "node", ")", "{", "it", ".", "result", "=", "val", "\n", "return", "graph", ".", "ContainsLogOut", "(", "it", ",", "val", ",", "true", ")", "\n", "}", "\n", "it", ".", "err", "=", "it", ".", "primaryIt", ".", "Err", "(", ")", "\n", "return", "graph", ".", "ContainsLogOut", "(", "it", ",", "val", ",", "false", ")", "\n", "}" ]
// If it checks in the right direction for the subiterator, it is a valid link // for the LinksTo.
[ "If", "it", "checks", "in", "the", "right", "direction", "for", "the", "subiterator", "it", "is", "a", "valid", "link", "for", "the", "LinksTo", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/linksto.go#L108-L118
train
cayleygraph/cayley
graph/iterator/linksto.go
Optimize
func (it *LinksTo) Optimize() (graph.Iterator, bool) { newPrimary, changed := it.primaryIt.Optimize() if changed { it.primaryIt = newPrimary if it.primaryIt.Type() == graph.Null { it.nextIt.Close() return it.primaryIt, true } } // Ask the graph.QuadStore if we can be replaced. Often times, this is a great // optimization opportunity (there's a fixed iterator underneath us, for // example). newReplacement, hasOne := it.qs.OptimizeIterator(it) if hasOne { it.Close() return newReplacement, true } return it, false }
go
func (it *LinksTo) Optimize() (graph.Iterator, bool) { newPrimary, changed := it.primaryIt.Optimize() if changed { it.primaryIt = newPrimary if it.primaryIt.Type() == graph.Null { it.nextIt.Close() return it.primaryIt, true } } // Ask the graph.QuadStore if we can be replaced. Often times, this is a great // optimization opportunity (there's a fixed iterator underneath us, for // example). newReplacement, hasOne := it.qs.OptimizeIterator(it) if hasOne { it.Close() return newReplacement, true } return it, false }
[ "func", "(", "it", "*", "LinksTo", ")", "Optimize", "(", ")", "(", "graph", ".", "Iterator", ",", "bool", ")", "{", "newPrimary", ",", "changed", ":=", "it", ".", "primaryIt", ".", "Optimize", "(", ")", "\n", "if", "changed", "{", "it", ".", "primaryIt", "=", "newPrimary", "\n", "if", "it", ".", "primaryIt", ".", "Type", "(", ")", "==", "graph", ".", "Null", "{", "it", ".", "nextIt", ".", "Close", "(", ")", "\n", "return", "it", ".", "primaryIt", ",", "true", "\n", "}", "\n", "}", "\n", "// Ask the graph.QuadStore if we can be replaced. Often times, this is a great", "// optimization opportunity (there's a fixed iterator underneath us, for", "// example).", "newReplacement", ",", "hasOne", ":=", "it", ".", "qs", ".", "OptimizeIterator", "(", "it", ")", "\n", "if", "hasOne", "{", "it", ".", "Close", "(", ")", "\n", "return", "newReplacement", ",", "true", "\n", "}", "\n", "return", "it", ",", "false", "\n", "}" ]
// Optimize the LinksTo, by replacing it if it can be.
[ "Optimize", "the", "LinksTo", "by", "replacing", "it", "if", "it", "can", "be", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/linksto.go#L126-L144
train
cayleygraph/cayley
graph/iterator/linksto.go
Close
func (it *LinksTo) Close() error { err := it.nextIt.Close() _err := it.primaryIt.Close() if _err != nil && err == nil { err = _err } return err }
go
func (it *LinksTo) Close() error { err := it.nextIt.Close() _err := it.primaryIt.Close() if _err != nil && err == nil { err = _err } return err }
[ "func", "(", "it", "*", "LinksTo", ")", "Close", "(", ")", "error", "{", "err", ":=", "it", ".", "nextIt", ".", "Close", "(", ")", "\n\n", "_err", ":=", "it", ".", "primaryIt", ".", "Close", "(", ")", "\n", "if", "_err", "!=", "nil", "&&", "err", "==", "nil", "{", "err", "=", "_err", "\n", "}", "\n\n", "return", "err", "\n", "}" ]
// Close closes the iterator. It closes all subiterators it can, but // returns the first error it encounters.
[ "Close", "closes", "the", "iterator", ".", "It", "closes", "all", "subiterators", "it", "can", "but", "returns", "the", "first", "error", "it", "encounters", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/linksto.go#L188-L197
train
cayleygraph/cayley
graph/iterator/linksto.go
NextPath
func (it *LinksTo) NextPath(ctx context.Context) bool { ok := it.primaryIt.NextPath(ctx) if !ok { it.err = it.primaryIt.Err() } return ok }
go
func (it *LinksTo) NextPath(ctx context.Context) bool { ok := it.primaryIt.NextPath(ctx) if !ok { it.err = it.primaryIt.Err() } return ok }
[ "func", "(", "it", "*", "LinksTo", ")", "NextPath", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "ok", ":=", "it", ".", "primaryIt", ".", "NextPath", "(", "ctx", ")", "\n", "if", "!", "ok", "{", "it", ".", "err", "=", "it", ".", "primaryIt", ".", "Err", "(", ")", "\n", "}", "\n", "return", "ok", "\n", "}" ]
// We won't ever have a new result, but our subiterators might.
[ "We", "won", "t", "ever", "have", "a", "new", "result", "but", "our", "subiterators", "might", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/linksto.go#L200-L206
train
cayleygraph/cayley
graph/iterator/linksto.go
Stats
func (it *LinksTo) Stats() graph.IteratorStats { subitStats := it.primaryIt.Stats() // TODO(barakmich): These should really come from the quadstore itself checkConstant := int64(1) nextConstant := int64(2) st := graph.IteratorStats{ NextCost: nextConstant + subitStats.NextCost, ContainsCost: checkConstant + subitStats.ContainsCost, Next: it.runstats.Next, Contains: it.runstats.Contains, ContainsNext: it.runstats.ContainsNext, } st.Size, st.ExactSize = it.Size() return st }
go
func (it *LinksTo) Stats() graph.IteratorStats { subitStats := it.primaryIt.Stats() // TODO(barakmich): These should really come from the quadstore itself checkConstant := int64(1) nextConstant := int64(2) st := graph.IteratorStats{ NextCost: nextConstant + subitStats.NextCost, ContainsCost: checkConstant + subitStats.ContainsCost, Next: it.runstats.Next, Contains: it.runstats.Contains, ContainsNext: it.runstats.ContainsNext, } st.Size, st.ExactSize = it.Size() return st }
[ "func", "(", "it", "*", "LinksTo", ")", "Stats", "(", ")", "graph", ".", "IteratorStats", "{", "subitStats", ":=", "it", ".", "primaryIt", ".", "Stats", "(", ")", "\n", "// TODO(barakmich): These should really come from the quadstore itself", "checkConstant", ":=", "int64", "(", "1", ")", "\n", "nextConstant", ":=", "int64", "(", "2", ")", "\n", "st", ":=", "graph", ".", "IteratorStats", "{", "NextCost", ":", "nextConstant", "+", "subitStats", ".", "NextCost", ",", "ContainsCost", ":", "checkConstant", "+", "subitStats", ".", "ContainsCost", ",", "Next", ":", "it", ".", "runstats", ".", "Next", ",", "Contains", ":", "it", ".", "runstats", ".", "Contains", ",", "ContainsNext", ":", "it", ".", "runstats", ".", "ContainsNext", ",", "}", "\n", "st", ".", "Size", ",", "st", ".", "ExactSize", "=", "it", ".", "Size", "(", ")", "\n", "return", "st", "\n", "}" ]
// Return a guess as to how big or costly it is to next the iterator.
[ "Return", "a", "guess", "as", "to", "how", "big", "or", "costly", "it", "is", "to", "next", "the", "iterator", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/linksto.go#L212-L226
train
cayleygraph/cayley
graph/path/path.go
StartPath
func StartPath(qs graph.QuadStore, nodes ...quad.Value) *Path { return newPath(qs, isMorphism(nodes...)) }
go
func StartPath(qs graph.QuadStore, nodes ...quad.Value) *Path { return newPath(qs, isMorphism(nodes...)) }
[ "func", "StartPath", "(", "qs", "graph", ".", "QuadStore", ",", "nodes", "...", "quad", ".", "Value", ")", "*", "Path", "{", "return", "newPath", "(", "qs", ",", "isMorphism", "(", "nodes", "...", ")", ")", "\n", "}" ]
// StartPath creates a new Path from a set of nodes and an underlying QuadStore.
[ "StartPath", "creates", "a", "new", "Path", "from", "a", "set", "of", "nodes", "and", "an", "underlying", "QuadStore", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L94-L96
train
cayleygraph/cayley
graph/path/path.go
StartPathNodes
func StartPathNodes(qs graph.QuadStore, nodes ...graph.Value) *Path { return newPath(qs, isNodeMorphism(nodes...)) }
go
func StartPathNodes(qs graph.QuadStore, nodes ...graph.Value) *Path { return newPath(qs, isNodeMorphism(nodes...)) }
[ "func", "StartPathNodes", "(", "qs", "graph", ".", "QuadStore", ",", "nodes", "...", "graph", ".", "Value", ")", "*", "Path", "{", "return", "newPath", "(", "qs", ",", "isNodeMorphism", "(", "nodes", "...", ")", ")", "\n", "}" ]
// StartPathNodes creates a new Path from a set of nodes and an underlying QuadStore.
[ "StartPathNodes", "creates", "a", "new", "Path", "from", "a", "set", "of", "nodes", "and", "an", "underlying", "QuadStore", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L99-L101
train
cayleygraph/cayley
graph/path/path.go
PathFromIterator
func PathFromIterator(qs graph.QuadStore, it graph.Iterator) *Path { return newPath(qs, iteratorMorphism(it)) }
go
func PathFromIterator(qs graph.QuadStore, it graph.Iterator) *Path { return newPath(qs, iteratorMorphism(it)) }
[ "func", "PathFromIterator", "(", "qs", "graph", ".", "QuadStore", ",", "it", "graph", ".", "Iterator", ")", "*", "Path", "{", "return", "newPath", "(", "qs", ",", "iteratorMorphism", "(", "it", ")", ")", "\n", "}" ]
// PathFromIterator creates a new Path from a set of nodes contained in iterator.
[ "PathFromIterator", "creates", "a", "new", "Path", "from", "a", "set", "of", "nodes", "contained", "in", "iterator", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L104-L106
train
cayleygraph/cayley
graph/path/path.go
Clone
func (p *Path) Clone() *Path { stack := p.stack return &Path{ stack: stack[:len(stack):len(stack)], qs: p.qs, baseContext: p.baseContext, } }
go
func (p *Path) Clone() *Path { stack := p.stack return &Path{ stack: stack[:len(stack):len(stack)], qs: p.qs, baseContext: p.baseContext, } }
[ "func", "(", "p", "*", "Path", ")", "Clone", "(", ")", "*", "Path", "{", "stack", ":=", "p", ".", "stack", "\n", "return", "&", "Path", "{", "stack", ":", "stack", "[", ":", "len", "(", "stack", ")", ":", "len", "(", "stack", ")", "]", ",", "qs", ":", "p", ".", "qs", ",", "baseContext", ":", "p", ".", "baseContext", ",", "}", "\n", "}" ]
// Clone returns a clone of the current path.
[ "Clone", "returns", "a", "clone", "of", "the", "current", "path", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L114-L121
train
cayleygraph/cayley
graph/path/path.go
Reverse
func (p *Path) Reverse() *Path { newPath := NewPath(p.qs) ctx := &newPath.baseContext for i := len(p.stack) - 1; i >= 0; i-- { var revMorphism morphism revMorphism, ctx = p.stack[i].Reversal(ctx) newPath.stack = append(newPath.stack, revMorphism) } return newPath }
go
func (p *Path) Reverse() *Path { newPath := NewPath(p.qs) ctx := &newPath.baseContext for i := len(p.stack) - 1; i >= 0; i-- { var revMorphism morphism revMorphism, ctx = p.stack[i].Reversal(ctx) newPath.stack = append(newPath.stack, revMorphism) } return newPath }
[ "func", "(", "p", "*", "Path", ")", "Reverse", "(", ")", "*", "Path", "{", "newPath", ":=", "NewPath", "(", "p", ".", "qs", ")", "\n", "ctx", ":=", "&", "newPath", ".", "baseContext", "\n", "for", "i", ":=", "len", "(", "p", ".", "stack", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", "{", "var", "revMorphism", "morphism", "\n", "revMorphism", ",", "ctx", "=", "p", ".", "stack", "[", "i", "]", ".", "Reversal", "(", "ctx", ")", "\n", "newPath", ".", "stack", "=", "append", "(", "newPath", ".", "stack", ",", "revMorphism", ")", "\n", "}", "\n", "return", "newPath", "\n", "}" ]
// Reverse returns a new Path that is the reverse of the current one.
[ "Reverse", "returns", "a", "new", "Path", "that", "is", "the", "reverse", "of", "the", "current", "one", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L136-L145
train
cayleygraph/cayley
graph/path/path.go
Is
func (p *Path) Is(nodes ...quad.Value) *Path { np := p.clone() np.stack = append(np.stack, isMorphism(nodes...)) return np }
go
func (p *Path) Is(nodes ...quad.Value) *Path { np := p.clone() np.stack = append(np.stack, isMorphism(nodes...)) return np }
[ "func", "(", "p", "*", "Path", ")", "Is", "(", "nodes", "...", "quad", ".", "Value", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "isMorphism", "(", "nodes", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// Is declares that the current nodes in this path are only the nodes // passed as arguments.
[ "Is", "declares", "that", "the", "current", "nodes", "in", "this", "path", "are", "only", "the", "nodes", "passed", "as", "arguments", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L149-L153
train
cayleygraph/cayley
graph/path/path.go
Regex
func (p *Path) Regex(pattern *regexp.Regexp) *Path { return p.Filters(shape.Regexp{Re: pattern, Refs: false}) }
go
func (p *Path) Regex(pattern *regexp.Regexp) *Path { return p.Filters(shape.Regexp{Re: pattern, Refs: false}) }
[ "func", "(", "p", "*", "Path", ")", "Regex", "(", "pattern", "*", "regexp", ".", "Regexp", ")", "*", "Path", "{", "return", "p", ".", "Filters", "(", "shape", ".", "Regexp", "{", "Re", ":", "pattern", ",", "Refs", ":", "false", "}", ")", "\n", "}" ]
// Regex represents the nodes that are matching provided regexp pattern. // It will only include Raw and String values.
[ "Regex", "represents", "the", "nodes", "that", "are", "matching", "provided", "regexp", "pattern", ".", "It", "will", "only", "include", "Raw", "and", "String", "values", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L157-L159
train
cayleygraph/cayley
graph/path/path.go
Filter
func (p *Path) Filter(op iterator.Operator, node quad.Value) *Path { return p.Filters(shape.Comparison{Op: op, Val: node}) }
go
func (p *Path) Filter(op iterator.Operator, node quad.Value) *Path { return p.Filters(shape.Comparison{Op: op, Val: node}) }
[ "func", "(", "p", "*", "Path", ")", "Filter", "(", "op", "iterator", ".", "Operator", ",", "node", "quad", ".", "Value", ")", "*", "Path", "{", "return", "p", ".", "Filters", "(", "shape", ".", "Comparison", "{", "Op", ":", "op", ",", "Val", ":", "node", "}", ")", "\n", "}" ]
// Filter represents the nodes that are passing comparison with provided value.
[ "Filter", "represents", "the", "nodes", "that", "are", "passing", "comparison", "with", "provided", "value", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L179-L181
train
cayleygraph/cayley
graph/path/path.go
Filters
func (p *Path) Filters(filters ...shape.ValueFilter) *Path { np := p.clone() np.stack = append(np.stack, filterMorphism(filters)) return np }
go
func (p *Path) Filters(filters ...shape.ValueFilter) *Path { np := p.clone() np.stack = append(np.stack, filterMorphism(filters)) return np }
[ "func", "(", "p", "*", "Path", ")", "Filters", "(", "filters", "...", "shape", ".", "ValueFilter", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "filterMorphism", "(", "filters", ")", ")", "\n", "return", "np", "\n", "}" ]
// Filters represents the nodes that are passing provided filters.
[ "Filters", "represents", "the", "nodes", "that", "are", "passing", "provided", "filters", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L184-L188
train
cayleygraph/cayley
graph/path/path.go
Tag
func (p *Path) Tag(tags ...string) *Path { np := p.clone() np.stack = append(np.stack, tagMorphism(tags...)) return np }
go
func (p *Path) Tag(tags ...string) *Path { np := p.clone() np.stack = append(np.stack, tagMorphism(tags...)) return np }
[ "func", "(", "p", "*", "Path", ")", "Tag", "(", "tags", "...", "string", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "tagMorphism", "(", "tags", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// Tag adds tag strings to the nodes at this point in the path for each result // path in the set.
[ "Tag", "adds", "tag", "strings", "to", "the", "nodes", "at", "this", "point", "in", "the", "path", "for", "each", "result", "path", "in", "the", "set", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L192-L196
train
cayleygraph/cayley
graph/path/path.go
InWithTags
func (p *Path) InWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, inMorphism(tags, via...)) return np }
go
func (p *Path) InWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, inMorphism(tags, via...)) return np }
[ "func", "(", "p", "*", "Path", ")", "InWithTags", "(", "tags", "[", "]", "string", ",", "via", "...", "interface", "{", "}", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "inMorphism", "(", "tags", ",", "via", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// InWithTags is exactly like In, except it tags the value of the predicate // traversed with the tags provided.
[ "InWithTags", "is", "exactly", "like", "In", "except", "it", "tags", "the", "value", "of", "the", "predicate", "traversed", "with", "the", "tags", "provided", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L230-L234
train
cayleygraph/cayley
graph/path/path.go
OutWithTags
func (p *Path) OutWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, outMorphism(tags, via...)) return np }
go
func (p *Path) OutWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, outMorphism(tags, via...)) return np }
[ "func", "(", "p", "*", "Path", ")", "OutWithTags", "(", "tags", "[", "]", "string", ",", "via", "...", "interface", "{", "}", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "outMorphism", "(", "tags", ",", "via", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// OutWithTags is exactly like In, except it tags the value of the predicate // traversed with the tags provided.
[ "OutWithTags", "is", "exactly", "like", "In", "except", "it", "tags", "the", "value", "of", "the", "predicate", "traversed", "with", "the", "tags", "provided", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L238-L242
train
cayleygraph/cayley
graph/path/path.go
BothWithTags
func (p *Path) BothWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, bothMorphism(tags, via...)) return np }
go
func (p *Path) BothWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, bothMorphism(tags, via...)) return np }
[ "func", "(", "p", "*", "Path", ")", "BothWithTags", "(", "tags", "[", "]", "string", ",", "via", "...", "interface", "{", "}", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "bothMorphism", "(", "tags", ",", "via", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// BothWithTags is exactly like Both, except it tags the value of the predicate // traversed with the tags provided.
[ "BothWithTags", "is", "exactly", "like", "Both", "except", "it", "tags", "the", "value", "of", "the", "predicate", "traversed", "with", "the", "tags", "provided", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L260-L264
train
cayleygraph/cayley
graph/path/path.go
Labels
func (p *Path) Labels() *Path { np := p.clone() np.stack = append(np.stack, labelsMorphism()) return np }
go
func (p *Path) Labels() *Path { np := p.clone() np.stack = append(np.stack, labelsMorphism()) return np }
[ "func", "(", "p", "*", "Path", ")", "Labels", "(", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "labelsMorphism", "(", ")", ")", "\n", "return", "np", "\n", "}" ]
// Labels updates this path to represent the nodes of the labels // of inbound and outbound quads.
[ "Labels", "updates", "this", "path", "to", "represent", "the", "nodes", "of", "the", "labels", "of", "inbound", "and", "outbound", "quads", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L268-L272
train
cayleygraph/cayley
graph/path/path.go
SavePredicates
func (p *Path) SavePredicates(rev bool, tag string) *Path { np := p.clone() np.stack = append(np.stack, savePredicatesMorphism(rev, tag)) return np }
go
func (p *Path) SavePredicates(rev bool, tag string) *Path { np := p.clone() np.stack = append(np.stack, savePredicatesMorphism(rev, tag)) return np }
[ "func", "(", "p", "*", "Path", ")", "SavePredicates", "(", "rev", "bool", ",", "tag", "string", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "savePredicatesMorphism", "(", "rev", ",", "tag", ")", ")", "\n", "return", "np", "\n", "}" ]
// SavePredicates saves either forward or reverse predicates of current node // without changing path location.
[ "SavePredicates", "saves", "either", "forward", "or", "reverse", "predicates", "of", "current", "node", "without", "changing", "path", "location", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L305-L309
train
cayleygraph/cayley
graph/path/path.go
And
func (p *Path) And(path *Path) *Path { np := p.clone() np.stack = append(np.stack, andMorphism(path)) return np }
go
func (p *Path) And(path *Path) *Path { np := p.clone() np.stack = append(np.stack, andMorphism(path)) return np }
[ "func", "(", "p", "*", "Path", ")", "And", "(", "path", "*", "Path", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "andMorphism", "(", "path", ")", ")", "\n", "return", "np", "\n", "}" ]
// And updates the current Path to represent the nodes that match both the // current Path so far, and the given Path.
[ "And", "updates", "the", "current", "Path", "to", "represent", "the", "nodes", "that", "match", "both", "the", "current", "Path", "so", "far", "and", "the", "given", "Path", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L313-L317
train
cayleygraph/cayley
graph/path/path.go
Or
func (p *Path) Or(path *Path) *Path { np := p.clone() np.stack = append(np.stack, orMorphism(path)) return np }
go
func (p *Path) Or(path *Path) *Path { np := p.clone() np.stack = append(np.stack, orMorphism(path)) return np }
[ "func", "(", "p", "*", "Path", ")", "Or", "(", "path", "*", "Path", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "orMorphism", "(", "path", ")", ")", "\n", "return", "np", "\n", "}" ]
// Or updates the current Path to represent the nodes that match either the // current Path so far, or the given Path.
[ "Or", "updates", "the", "current", "Path", "to", "represent", "the", "nodes", "that", "match", "either", "the", "current", "Path", "so", "far", "or", "the", "given", "Path", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L321-L325
train
cayleygraph/cayley
graph/path/path.go
Unique
func (p *Path) Unique() *Path { np := p.clone() np.stack = append(np.stack, uniqueMorphism()) return np }
go
func (p *Path) Unique() *Path { np := p.clone() np.stack = append(np.stack, uniqueMorphism()) return np }
[ "func", "(", "p", "*", "Path", ")", "Unique", "(", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "uniqueMorphism", "(", ")", ")", "\n", "return", "np", "\n", "}" ]
// Unique updates the current Path to contain only unique nodes.
[ "Unique", "updates", "the", "current", "Path", "to", "contain", "only", "unique", "nodes", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L340-L344
train
cayleygraph/cayley
graph/path/path.go
Follow
func (p *Path) Follow(path *Path) *Path { np := p.clone() np.stack = append(np.stack, followMorphism(path)) return np }
go
func (p *Path) Follow(path *Path) *Path { np := p.clone() np.stack = append(np.stack, followMorphism(path)) return np }
[ "func", "(", "p", "*", "Path", ")", "Follow", "(", "path", "*", "Path", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "followMorphism", "(", "path", ")", ")", "\n", "return", "np", "\n", "}" ]
// Follow allows you to stitch two paths together. The resulting path will start // from where the first path left off and continue iterating down the path given.
[ "Follow", "allows", "you", "to", "stitch", "two", "paths", "together", ".", "The", "resulting", "path", "will", "start", "from", "where", "the", "first", "path", "left", "off", "and", "continue", "iterating", "down", "the", "path", "given", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L348-L352
train
cayleygraph/cayley
graph/path/path.go
FollowReverse
func (p *Path) FollowReverse(path *Path) *Path { np := p.clone() np.stack = append(np.stack, followMorphism(path.Reverse())) return np }
go
func (p *Path) FollowReverse(path *Path) *Path { np := p.clone() np.stack = append(np.stack, followMorphism(path.Reverse())) return np }
[ "func", "(", "p", "*", "Path", ")", "FollowReverse", "(", "path", "*", "Path", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "followMorphism", "(", "path", ".", "Reverse", "(", ")", ")", ")", "\n", "return", "np", "\n", "}" ]
// FollowReverse is the same as follow, except it will iterate backwards up the // path given as argument.
[ "FollowReverse", "is", "the", "same", "as", "follow", "except", "it", "will", "iterate", "backwards", "up", "the", "path", "given", "as", "argument", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L356-L360
train
cayleygraph/cayley
graph/path/path.go
SaveOptional
func (p *Path) SaveOptional(via interface{}, tag string) *Path { np := p.clone() np.stack = append(np.stack, saveOptionalMorphism(via, tag)) return np }
go
func (p *Path) SaveOptional(via interface{}, tag string) *Path { np := p.clone() np.stack = append(np.stack, saveOptionalMorphism(via, tag)) return np }
[ "func", "(", "p", "*", "Path", ")", "SaveOptional", "(", "via", "interface", "{", "}", ",", "tag", "string", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "saveOptionalMorphism", "(", "via", ",", "tag", ")", ")", "\n", "return", "np", "\n", "}" ]
// SaveOptional is the same as Save, but does not require linkage to exist.
[ "SaveOptional", "is", "the", "same", "as", "Save", "but", "does", "not", "require", "linkage", "to", "exist", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L418-L422
train
cayleygraph/cayley
graph/path/path.go
SaveOptionalReverse
func (p *Path) SaveOptionalReverse(via interface{}, tag string) *Path { np := p.clone() np.stack = append(np.stack, saveOptionalReverseMorphism(via, tag)) return np }
go
func (p *Path) SaveOptionalReverse(via interface{}, tag string) *Path { np := p.clone() np.stack = append(np.stack, saveOptionalReverseMorphism(via, tag)) return np }
[ "func", "(", "p", "*", "Path", ")", "SaveOptionalReverse", "(", "via", "interface", "{", "}", ",", "tag", "string", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "saveOptionalReverseMorphism", "(", "via", ",", "tag", ")", ")", "\n", "return", "np", "\n", "}" ]
// SaveOptionalReverse is the same as SaveReverse, but does not require linkage to exist.
[ "SaveOptionalReverse", "is", "the", "same", "as", "SaveReverse", "but", "does", "not", "require", "linkage", "to", "exist", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L425-L429
train
cayleygraph/cayley
graph/path/path.go
Has
func (p *Path) Has(via interface{}, nodes ...quad.Value) *Path { np := p.clone() np.stack = append(np.stack, hasMorphism(via, false, nodes...)) return np }
go
func (p *Path) Has(via interface{}, nodes ...quad.Value) *Path { np := p.clone() np.stack = append(np.stack, hasMorphism(via, false, nodes...)) return np }
[ "func", "(", "p", "*", "Path", ")", "Has", "(", "via", "interface", "{", "}", ",", "nodes", "...", "quad", ".", "Value", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "hasMorphism", "(", "via", ",", "false", ",", "nodes", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// Has limits the paths to be ones where the current nodes have some linkage // to some known node.
[ "Has", "limits", "the", "paths", "to", "be", "ones", "where", "the", "current", "nodes", "have", "some", "linkage", "to", "some", "known", "node", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L433-L437
train
cayleygraph/cayley
graph/path/path.go
HasReverse
func (p *Path) HasReverse(via interface{}, nodes ...quad.Value) *Path { np := p.clone() np.stack = append(np.stack, hasMorphism(via, true, nodes...)) return np }
go
func (p *Path) HasReverse(via interface{}, nodes ...quad.Value) *Path { np := p.clone() np.stack = append(np.stack, hasMorphism(via, true, nodes...)) return np }
[ "func", "(", "p", "*", "Path", ")", "HasReverse", "(", "via", "interface", "{", "}", ",", "nodes", "...", "quad", ".", "Value", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "hasMorphism", "(", "via", ",", "true", ",", "nodes", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// HasReverse limits the paths to be ones where some known node have some linkage // to the current nodes.
[ "HasReverse", "limits", "the", "paths", "to", "be", "ones", "where", "some", "known", "node", "have", "some", "linkage", "to", "the", "current", "nodes", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L441-L445
train
cayleygraph/cayley
graph/path/path.go
HasFilter
func (p *Path) HasFilter(via interface{}, rev bool, filt ...shape.ValueFilter) *Path { np := p.clone() np.stack = append(np.stack, hasFilterMorphism(via, rev, filt)) return np }
go
func (p *Path) HasFilter(via interface{}, rev bool, filt ...shape.ValueFilter) *Path { np := p.clone() np.stack = append(np.stack, hasFilterMorphism(via, rev, filt)) return np }
[ "func", "(", "p", "*", "Path", ")", "HasFilter", "(", "via", "interface", "{", "}", ",", "rev", "bool", ",", "filt", "...", "shape", ".", "ValueFilter", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "hasFilterMorphism", "(", "via", ",", "rev", ",", "filt", ")", ")", "\n", "return", "np", "\n", "}" ]
// HasFilter limits the paths to be ones where the current nodes have some linkage // to some nodes that pass provided filters.
[ "HasFilter", "limits", "the", "paths", "to", "be", "ones", "where", "the", "current", "nodes", "have", "some", "linkage", "to", "some", "nodes", "that", "pass", "provided", "filters", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L449-L453
train
cayleygraph/cayley
graph/path/path.go
LabelContextWithTags
func (p *Path) LabelContextWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, labelContextMorphism(tags, via...)) return np }
go
func (p *Path) LabelContextWithTags(tags []string, via ...interface{}) *Path { np := p.clone() np.stack = append(np.stack, labelContextMorphism(tags, via...)) return np }
[ "func", "(", "p", "*", "Path", ")", "LabelContextWithTags", "(", "tags", "[", "]", "string", ",", "via", "...", "interface", "{", "}", ")", "*", "Path", "{", "np", ":=", "p", ".", "clone", "(", ")", "\n", "np", ".", "stack", "=", "append", "(", "np", ".", "stack", ",", "labelContextMorphism", "(", "tags", ",", "via", "...", ")", ")", "\n", "return", "np", "\n", "}" ]
// LabelContextWithTags is exactly like LabelContext, except it tags the value // of the label used in the traversal with the tags provided.
[ "LabelContextWithTags", "is", "exactly", "like", "LabelContext", "except", "it", "tags", "the", "value", "of", "the", "label", "used", "in", "the", "traversal", "with", "the", "tags", "provided", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L465-L469
train
cayleygraph/cayley
graph/path/path.go
BuildIteratorOn
func (p *Path) BuildIteratorOn(qs graph.QuadStore) graph.Iterator { return shape.BuildIterator(qs, p.Shape()) }
go
func (p *Path) BuildIteratorOn(qs graph.QuadStore) graph.Iterator { return shape.BuildIterator(qs, p.Shape()) }
[ "func", "(", "p", "*", "Path", ")", "BuildIteratorOn", "(", "qs", "graph", ".", "QuadStore", ")", "graph", ".", "Iterator", "{", "return", "shape", ".", "BuildIterator", "(", "qs", ",", "p", ".", "Shape", "(", ")", ")", "\n", "}" ]
// BuildIteratorOn will return an iterator for this path on the given QuadStore.
[ "BuildIteratorOn", "will", "return", "an", "iterator", "for", "this", "path", "on", "the", "given", "QuadStore", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L512-L514
train
cayleygraph/cayley
graph/path/path.go
Morphism
func (p *Path) Morphism() graph.ApplyMorphism { return func(qs graph.QuadStore, it graph.Iterator) graph.Iterator { return p.ShapeFrom(iteratorShape{it}).BuildIterator(qs) } }
go
func (p *Path) Morphism() graph.ApplyMorphism { return func(qs graph.QuadStore, it graph.Iterator) graph.Iterator { return p.ShapeFrom(iteratorShape{it}).BuildIterator(qs) } }
[ "func", "(", "p", "*", "Path", ")", "Morphism", "(", ")", "graph", ".", "ApplyMorphism", "{", "return", "func", "(", "qs", "graph", ".", "QuadStore", ",", "it", "graph", ".", "Iterator", ")", "graph", ".", "Iterator", "{", "return", "p", ".", "ShapeFrom", "(", "iteratorShape", "{", "it", "}", ")", ".", "BuildIterator", "(", "qs", ")", "\n", "}", "\n", "}" ]
// Morphism returns the morphism of this path. The returned value is a // function that, when given a QuadStore and an existing Iterator, will // return a new Iterator that yields the subset of values from the existing // iterator matched by the current Path.
[ "Morphism", "returns", "the", "morphism", "of", "this", "path", ".", "The", "returned", "value", "is", "a", "function", "that", "when", "given", "a", "QuadStore", "and", "an", "existing", "Iterator", "will", "return", "a", "new", "Iterator", "that", "yields", "the", "subset", "of", "values", "from", "the", "existing", "iterator", "matched", "by", "the", "current", "Path", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L520-L524
train
cayleygraph/cayley
graph/path/path.go
Skip
func (p *Path) Skip(v int64) *Path { p.stack = append(p.stack, skipMorphism(v)) return p }
go
func (p *Path) Skip(v int64) *Path { p.stack = append(p.stack, skipMorphism(v)) return p }
[ "func", "(", "p", "*", "Path", ")", "Skip", "(", "v", "int64", ")", "*", "Path", "{", "p", ".", "stack", "=", "append", "(", "p", ".", "stack", ",", "skipMorphism", "(", "v", ")", ")", "\n", "return", "p", "\n", "}" ]
// Skip will omit a number of values from result set.
[ "Skip", "will", "omit", "a", "number", "of", "values", "from", "result", "set", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L527-L530
train
cayleygraph/cayley
graph/path/path.go
Limit
func (p *Path) Limit(v int64) *Path { p.stack = append(p.stack, limitMorphism(v)) return p }
go
func (p *Path) Limit(v int64) *Path { p.stack = append(p.stack, limitMorphism(v)) return p }
[ "func", "(", "p", "*", "Path", ")", "Limit", "(", "v", "int64", ")", "*", "Path", "{", "p", ".", "stack", "=", "append", "(", "p", ".", "stack", ",", "limitMorphism", "(", "v", ")", ")", "\n", "return", "p", "\n", "}" ]
// Limit will limit a number of values in result set.
[ "Limit", "will", "limit", "a", "number", "of", "values", "in", "result", "set", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L533-L536
train
cayleygraph/cayley
graph/path/path.go
Count
func (p *Path) Count() *Path { p.stack = append(p.stack, countMorphism()) return p }
go
func (p *Path) Count() *Path { p.stack = append(p.stack, countMorphism()) return p }
[ "func", "(", "p", "*", "Path", ")", "Count", "(", ")", "*", "Path", "{", "p", ".", "stack", "=", "append", "(", "p", ".", "stack", ",", "countMorphism", "(", ")", ")", "\n", "return", "p", "\n", "}" ]
// Count will count a number of results as it's own result set.
[ "Count", "will", "count", "a", "number", "of", "results", "as", "it", "s", "own", "result", "set", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L539-L542
train
cayleygraph/cayley
graph/path/path.go
Iterate
func (p *Path) Iterate(ctx context.Context) *graph.IterateChain { return shape.Iterate(ctx, p.qs, p.Shape()) }
go
func (p *Path) Iterate(ctx context.Context) *graph.IterateChain { return shape.Iterate(ctx, p.qs, p.Shape()) }
[ "func", "(", "p", "*", "Path", ")", "Iterate", "(", "ctx", "context", ".", "Context", ")", "*", "graph", ".", "IterateChain", "{", "return", "shape", ".", "Iterate", "(", "ctx", ",", "p", ".", "qs", ",", "p", ".", "Shape", "(", ")", ")", "\n", "}" ]
// Iterate is an shortcut for graph.Iterate.
[ "Iterate", "is", "an", "shortcut", "for", "graph", ".", "Iterate", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/path/path.go#L545-L547
train
cayleygraph/cayley
graph/iterator/value_comparison.go
doComparison
func (it *Comparison) doComparison(val graph.Value) bool { qval := it.qs.NameOf(val) switch cVal := it.val.(type) { case quad.Int: if cVal2, ok := qval.(quad.Int); ok { return RunIntOp(cVal2, it.op, cVal) } return false case quad.Float: if cVal2, ok := qval.(quad.Float); ok { return RunFloatOp(cVal2, it.op, cVal) } return false case quad.String: if cVal2, ok := qval.(quad.String); ok { return RunStrOp(string(cVal2), it.op, string(cVal)) } return false case quad.BNode: if cVal2, ok := qval.(quad.BNode); ok { return RunStrOp(string(cVal2), it.op, string(cVal)) } return false case quad.IRI: if cVal2, ok := qval.(quad.IRI); ok { return RunStrOp(string(cVal2), it.op, string(cVal)) } return false case quad.Time: if cVal2, ok := qval.(quad.Time); ok { return RunTimeOp(time.Time(cVal2), it.op, time.Time(cVal)) } return false default: return RunStrOp(quad.StringOf(qval), it.op, quad.StringOf(it.val)) } }
go
func (it *Comparison) doComparison(val graph.Value) bool { qval := it.qs.NameOf(val) switch cVal := it.val.(type) { case quad.Int: if cVal2, ok := qval.(quad.Int); ok { return RunIntOp(cVal2, it.op, cVal) } return false case quad.Float: if cVal2, ok := qval.(quad.Float); ok { return RunFloatOp(cVal2, it.op, cVal) } return false case quad.String: if cVal2, ok := qval.(quad.String); ok { return RunStrOp(string(cVal2), it.op, string(cVal)) } return false case quad.BNode: if cVal2, ok := qval.(quad.BNode); ok { return RunStrOp(string(cVal2), it.op, string(cVal)) } return false case quad.IRI: if cVal2, ok := qval.(quad.IRI); ok { return RunStrOp(string(cVal2), it.op, string(cVal)) } return false case quad.Time: if cVal2, ok := qval.(quad.Time); ok { return RunTimeOp(time.Time(cVal2), it.op, time.Time(cVal)) } return false default: return RunStrOp(quad.StringOf(qval), it.op, quad.StringOf(it.val)) } }
[ "func", "(", "it", "*", "Comparison", ")", "doComparison", "(", "val", "graph", ".", "Value", ")", "bool", "{", "qval", ":=", "it", ".", "qs", ".", "NameOf", "(", "val", ")", "\n", "switch", "cVal", ":=", "it", ".", "val", ".", "(", "type", ")", "{", "case", "quad", ".", "Int", ":", "if", "cVal2", ",", "ok", ":=", "qval", ".", "(", "quad", ".", "Int", ")", ";", "ok", "{", "return", "RunIntOp", "(", "cVal2", ",", "it", ".", "op", ",", "cVal", ")", "\n", "}", "\n", "return", "false", "\n", "case", "quad", ".", "Float", ":", "if", "cVal2", ",", "ok", ":=", "qval", ".", "(", "quad", ".", "Float", ")", ";", "ok", "{", "return", "RunFloatOp", "(", "cVal2", ",", "it", ".", "op", ",", "cVal", ")", "\n", "}", "\n", "return", "false", "\n", "case", "quad", ".", "String", ":", "if", "cVal2", ",", "ok", ":=", "qval", ".", "(", "quad", ".", "String", ")", ";", "ok", "{", "return", "RunStrOp", "(", "string", "(", "cVal2", ")", ",", "it", ".", "op", ",", "string", "(", "cVal", ")", ")", "\n", "}", "\n", "return", "false", "\n", "case", "quad", ".", "BNode", ":", "if", "cVal2", ",", "ok", ":=", "qval", ".", "(", "quad", ".", "BNode", ")", ";", "ok", "{", "return", "RunStrOp", "(", "string", "(", "cVal2", ")", ",", "it", ".", "op", ",", "string", "(", "cVal", ")", ")", "\n", "}", "\n", "return", "false", "\n", "case", "quad", ".", "IRI", ":", "if", "cVal2", ",", "ok", ":=", "qval", ".", "(", "quad", ".", "IRI", ")", ";", "ok", "{", "return", "RunStrOp", "(", "string", "(", "cVal2", ")", ",", "it", ".", "op", ",", "string", "(", "cVal", ")", ")", "\n", "}", "\n", "return", "false", "\n", "case", "quad", ".", "Time", ":", "if", "cVal2", ",", "ok", ":=", "qval", ".", "(", "quad", ".", "Time", ")", ";", "ok", "{", "return", "RunTimeOp", "(", "time", ".", "Time", "(", "cVal2", ")", ",", "it", ".", "op", ",", "time", ".", "Time", "(", "cVal", ")", ")", "\n", "}", "\n", "return", "false", "\n", "default", ":", "return", "RunStrOp", "(", "quad", ".", "StringOf", "(", "qval", ")", ",", "it", ".", "op", ",", "quad", ".", "StringOf", "(", "it", ".", "val", ")", ")", "\n", "}", "\n", "}" ]
// Here's the non-boilerplate part of the ValueComparison iterator. Given a value // and our operator, determine whether or not we meet the requirement.
[ "Here", "s", "the", "non", "-", "boilerplate", "part", "of", "the", "ValueComparison", "iterator", ".", "Given", "a", "value", "and", "our", "operator", "determine", "whether", "or", "not", "we", "meet", "the", "requirement", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/value_comparison.go#L95-L131
train
cayleygraph/cayley
quad/nquads/nquads.go
NewReader
func NewReader(r io.Reader, raw bool) *Reader { return &Reader{r: bufio.NewReader(r), raw: raw} }
go
func NewReader(r io.Reader, raw bool) *Reader { return &Reader{r: bufio.NewReader(r), raw: raw} }
[ "func", "NewReader", "(", "r", "io", ".", "Reader", ",", "raw", "bool", ")", "*", "Reader", "{", "return", "&", "Reader", "{", "r", ":", "bufio", ".", "NewReader", "(", "r", ")", ",", "raw", ":", "raw", "}", "\n", "}" ]
// NewReader returns an N-Quad decoder that takes its input from the // provided io.Reader.
[ "NewReader", "returns", "an", "N", "-", "Quad", "decoder", "that", "takes", "its", "input", "from", "the", "provided", "io", ".", "Reader", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/nquads/nquads.go#L92-L94
train
cayleygraph/cayley
quad/nquads/nquads.go
ReadQuad
func (dec *Reader) ReadQuad() (quad.Quad, error) { dec.line = dec.line[:0] var line []byte for { for { l, pre, err := dec.r.ReadLine() if err != nil { return quad.Quad{}, err } dec.line = append(dec.line, l...) if !pre { break } } if line = bytes.TrimSpace(dec.line); len(line) != 0 && line[0] != '#' { break } dec.line = dec.line[:0] } var ( q quad.Quad err error ) if dec.raw { q, err = ParseRaw(string(line)) } else { q, err = Parse(string(line)) } if err != nil { return quad.Quad{}, fmt.Errorf("failed to parse %q: %v", dec.line, err) } if !q.IsValid() { return dec.ReadQuad() } return q, nil }
go
func (dec *Reader) ReadQuad() (quad.Quad, error) { dec.line = dec.line[:0] var line []byte for { for { l, pre, err := dec.r.ReadLine() if err != nil { return quad.Quad{}, err } dec.line = append(dec.line, l...) if !pre { break } } if line = bytes.TrimSpace(dec.line); len(line) != 0 && line[0] != '#' { break } dec.line = dec.line[:0] } var ( q quad.Quad err error ) if dec.raw { q, err = ParseRaw(string(line)) } else { q, err = Parse(string(line)) } if err != nil { return quad.Quad{}, fmt.Errorf("failed to parse %q: %v", dec.line, err) } if !q.IsValid() { return dec.ReadQuad() } return q, nil }
[ "func", "(", "dec", "*", "Reader", ")", "ReadQuad", "(", ")", "(", "quad", ".", "Quad", ",", "error", ")", "{", "dec", ".", "line", "=", "dec", ".", "line", "[", ":", "0", "]", "\n", "var", "line", "[", "]", "byte", "\n", "for", "{", "for", "{", "l", ",", "pre", ",", "err", ":=", "dec", ".", "r", ".", "ReadLine", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "quad", ".", "Quad", "{", "}", ",", "err", "\n", "}", "\n", "dec", ".", "line", "=", "append", "(", "dec", ".", "line", ",", "l", "...", ")", "\n", "if", "!", "pre", "{", "break", "\n", "}", "\n", "}", "\n", "if", "line", "=", "bytes", ".", "TrimSpace", "(", "dec", ".", "line", ")", ";", "len", "(", "line", ")", "!=", "0", "&&", "line", "[", "0", "]", "!=", "'#'", "{", "break", "\n", "}", "\n", "dec", ".", "line", "=", "dec", ".", "line", "[", ":", "0", "]", "\n", "}", "\n", "var", "(", "q", "quad", ".", "Quad", "\n", "err", "error", "\n", ")", "\n", "if", "dec", ".", "raw", "{", "q", ",", "err", "=", "ParseRaw", "(", "string", "(", "line", ")", ")", "\n", "}", "else", "{", "q", ",", "err", "=", "Parse", "(", "string", "(", "line", ")", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "quad", ".", "Quad", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "dec", ".", "line", ",", "err", ")", "\n", "}", "\n", "if", "!", "q", ".", "IsValid", "(", ")", "{", "return", "dec", ".", "ReadQuad", "(", ")", "\n", "}", "\n", "return", "q", ",", "nil", "\n", "}" ]
// ReadQuad returns the next valid N-Quad as a quad.Quad, or an error.
[ "ReadQuad", "returns", "the", "next", "valid", "N", "-", "Quad", "as", "a", "quad", ".", "Quad", "or", "an", "error", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/quad/nquads/nquads.go#L97-L132
train
cayleygraph/cayley
query/gizmo/finals.go
GetLimit
func (p *pathObject) GetLimit(limit int) error { it := p.buildIteratorTree() it.Tagger().Add(TopResultTag) p.s.limit = limit p.s.count = 0 return p.s.runIterator(it) }
go
func (p *pathObject) GetLimit(limit int) error { it := p.buildIteratorTree() it.Tagger().Add(TopResultTag) p.s.limit = limit p.s.count = 0 return p.s.runIterator(it) }
[ "func", "(", "p", "*", "pathObject", ")", "GetLimit", "(", "limit", "int", ")", "error", "{", "it", ":=", "p", ".", "buildIteratorTree", "(", ")", "\n", "it", ".", "Tagger", "(", ")", ".", "Add", "(", "TopResultTag", ")", "\n", "p", ".", "s", ".", "limit", "=", "limit", "\n", "p", ".", "s", ".", "count", "=", "0", "\n", "return", "p", ".", "s", ".", "runIterator", "(", "it", ")", "\n", "}" ]
// GetLimit is the same as All, but limited to the first N unique nodes at the end of the path, and each of their possible traversals.
[ "GetLimit", "is", "the", "same", "as", "All", "but", "limited", "to", "the", "first", "N", "unique", "nodes", "at", "the", "end", "of", "the", "path", "and", "each", "of", "their", "possible", "traversals", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/query/gizmo/finals.go#L26-L32
train
cayleygraph/cayley
query/gizmo/finals.go
Map
func (p *pathObject) Map(call goja.FunctionCall) goja.Value { return p.ForEach(call) }
go
func (p *pathObject) Map(call goja.FunctionCall) goja.Value { return p.ForEach(call) }
[ "func", "(", "p", "*", "pathObject", ")", "Map", "(", "call", "goja", ".", "FunctionCall", ")", "goja", ".", "Value", "{", "return", "p", ".", "ForEach", "(", "call", ")", "\n", "}" ]
// Map is a alias for ForEach.
[ "Map", "is", "a", "alias", "for", "ForEach", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/query/gizmo/finals.go#L122-L124
train
cayleygraph/cayley
clog/clog.go
V
func V(level int) bool { if logger == nil { return false } return logger.V(level) }
go
func V(level int) bool { if logger == nil { return false } return logger.V(level) }
[ "func", "V", "(", "level", "int", ")", "bool", "{", "if", "logger", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "logger", ".", "V", "(", "level", ")", "\n", "}" ]
// V returns whether the current clog verbosity is above the specified level.
[ "V", "returns", "whether", "the", "current", "clog", "verbosity", "is", "above", "the", "specified", "level", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/clog/clog.go#L40-L45
train
cayleygraph/cayley
clog/clog.go
Infof
func Infof(format string, args ...interface{}) { if logger != nil { logger.Infof(format, args...) } }
go
func Infof(format string, args ...interface{}) { if logger != nil { logger.Infof(format, args...) } }
[ "func", "Infof", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "logger", "!=", "nil", "{", "logger", ".", "Infof", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// Infof logs information level messages.
[ "Infof", "logs", "information", "level", "messages", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/clog/clog.go#L55-L59
train
cayleygraph/cayley
clog/clog.go
Warningf
func Warningf(format string, args ...interface{}) { if logger != nil { logger.Warningf(format, args...) } }
go
func Warningf(format string, args ...interface{}) { if logger != nil { logger.Warningf(format, args...) } }
[ "func", "Warningf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "logger", "!=", "nil", "{", "logger", ".", "Warningf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// Warningf logs warning level messages.
[ "Warningf", "logs", "warning", "level", "messages", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/clog/clog.go#L62-L66
train
cayleygraph/cayley
clog/clog.go
Errorf
func Errorf(format string, args ...interface{}) { if logger != nil { logger.Errorf(format, args...) } }
go
func Errorf(format string, args ...interface{}) { if logger != nil { logger.Errorf(format, args...) } }
[ "func", "Errorf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "logger", "!=", "nil", "{", "logger", ".", "Errorf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// Errorf logs error level messages.
[ "Errorf", "logs", "error", "level", "messages", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/clog/clog.go#L69-L73
train
cayleygraph/cayley
clog/clog.go
Fatalf
func Fatalf(format string, args ...interface{}) { if logger != nil { logger.Fatalf(format, args...) } }
go
func Fatalf(format string, args ...interface{}) { if logger != nil { logger.Fatalf(format, args...) } }
[ "func", "Fatalf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "logger", "!=", "nil", "{", "logger", ".", "Fatalf", "(", "format", ",", "args", "...", ")", "\n", "}", "\n", "}" ]
// Fatalf logs fatal messages and terminates the program.
[ "Fatalf", "logs", "fatal", "messages", "and", "terminates", "the", "program", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/clog/clog.go#L76-L80
train
cayleygraph/cayley
graph/nosql/elastic/elastic.go
dialElastic
func dialElastic(addr string, options graph.Options) (*elastic.Client, error) { client, err := elastic.NewClient(elastic.SetURL(addr)) if err != nil { return nil, err } return client, nil }
go
func dialElastic(addr string, options graph.Options) (*elastic.Client, error) { client, err := elastic.NewClient(elastic.SetURL(addr)) if err != nil { return nil, err } return client, nil }
[ "func", "dialElastic", "(", "addr", "string", ",", "options", "graph", ".", "Options", ")", "(", "*", "elastic", ".", "Client", ",", "error", ")", "{", "client", ",", "err", ":=", "elastic", ".", "NewClient", "(", "elastic", ".", "SetURL", "(", "addr", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "client", ",", "nil", "\n", "}" ]
// dialElastic connects to elasticsearch
[ "dialElastic", "connects", "to", "elasticsearch" ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/nosql/elastic/elastic.go#L34-L40
train
cayleygraph/cayley
graph/nosql/ouch/values.go
toOuchValue
func toOuchValue(v nosql.Value) interface{} { switch v := v.(type) { case nil: return nil case nosql.Strings: return []string(v) case nosql.String: return string(v) case nosql.Int: return int64(v) case nosql.Float: return float64(v) case nosql.Bool: return bool(v) case nosql.Time: return time.Time(v).UTC().Format(time.RFC3339Nano) case nosql.Bytes: return base64.StdEncoding.EncodeToString(v) default: panic(fmt.Errorf("unsupported type: %T", v)) } }
go
func toOuchValue(v nosql.Value) interface{} { switch v := v.(type) { case nil: return nil case nosql.Strings: return []string(v) case nosql.String: return string(v) case nosql.Int: return int64(v) case nosql.Float: return float64(v) case nosql.Bool: return bool(v) case nosql.Time: return time.Time(v).UTC().Format(time.RFC3339Nano) case nosql.Bytes: return base64.StdEncoding.EncodeToString(v) default: panic(fmt.Errorf("unsupported type: %T", v)) } }
[ "func", "toOuchValue", "(", "v", "nosql", ".", "Value", ")", "interface", "{", "}", "{", "switch", "v", ":=", "v", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "nil", "\n", "case", "nosql", ".", "Strings", ":", "return", "[", "]", "string", "(", "v", ")", "\n", "case", "nosql", ".", "String", ":", "return", "string", "(", "v", ")", "\n", "case", "nosql", ".", "Int", ":", "return", "int64", "(", "v", ")", "\n", "case", "nosql", ".", "Float", ":", "return", "float64", "(", "v", ")", "\n", "case", "nosql", ".", "Bool", ":", "return", "bool", "(", "v", ")", "\n", "case", "nosql", ".", "Time", ":", "return", "time", ".", "Time", "(", "v", ")", ".", "UTC", "(", ")", ".", "Format", "(", "time", ".", "RFC3339Nano", ")", "\n", "case", "nosql", ".", "Bytes", ":", "return", "base64", ".", "StdEncoding", ".", "EncodeToString", "(", "v", ")", "\n", "default", ":", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ")", ")", "\n", "}", "\n", "}" ]
// toOuchValue serializes nosql.Value -> native json values.
[ "toOuchValue", "serializes", "nosql", ".", "Value", "-", ">", "native", "json", "values", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/nosql/ouch/values.go#L17-L38
train
cayleygraph/cayley
writer/single.go
RemoveNode
func (s *Single) RemoveNode(v quad.Value) error { gv := s.qs.ValueOf(v) if gv == nil { return graph.ErrNodeNotExists } del := graph.NewRemover(s) defer del.Close() total := 0 // TODO(dennwc): QuadStore may remove node without iterations. Consider optional interface for this. for _, d := range []quad.Direction{quad.Subject, quad.Predicate, quad.Object, quad.Label} { r := graph.NewResultReader(s.qs, s.qs.QuadIterator(d, gv)) n, err := quad.Copy(del, r) r.Close() if err != nil { return err } total += n } if err := del.Flush(); err != nil { return err } if total == 0 { return graph.ErrNodeNotExists } return nil }
go
func (s *Single) RemoveNode(v quad.Value) error { gv := s.qs.ValueOf(v) if gv == nil { return graph.ErrNodeNotExists } del := graph.NewRemover(s) defer del.Close() total := 0 // TODO(dennwc): QuadStore may remove node without iterations. Consider optional interface for this. for _, d := range []quad.Direction{quad.Subject, quad.Predicate, quad.Object, quad.Label} { r := graph.NewResultReader(s.qs, s.qs.QuadIterator(d, gv)) n, err := quad.Copy(del, r) r.Close() if err != nil { return err } total += n } if err := del.Flush(); err != nil { return err } if total == 0 { return graph.ErrNodeNotExists } return nil }
[ "func", "(", "s", "*", "Single", ")", "RemoveNode", "(", "v", "quad", ".", "Value", ")", "error", "{", "gv", ":=", "s", ".", "qs", ".", "ValueOf", "(", "v", ")", "\n", "if", "gv", "==", "nil", "{", "return", "graph", ".", "ErrNodeNotExists", "\n", "}", "\n", "del", ":=", "graph", ".", "NewRemover", "(", "s", ")", "\n", "defer", "del", ".", "Close", "(", ")", "\n\n", "total", ":=", "0", "\n", "// TODO(dennwc): QuadStore may remove node without iterations. Consider optional interface for this.", "for", "_", ",", "d", ":=", "range", "[", "]", "quad", ".", "Direction", "{", "quad", ".", "Subject", ",", "quad", ".", "Predicate", ",", "quad", ".", "Object", ",", "quad", ".", "Label", "}", "{", "r", ":=", "graph", ".", "NewResultReader", "(", "s", ".", "qs", ",", "s", ".", "qs", ".", "QuadIterator", "(", "d", ",", "gv", ")", ")", "\n", "n", ",", "err", ":=", "quad", ".", "Copy", "(", "del", ",", "r", ")", "\n", "r", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "total", "+=", "n", "\n", "}", "\n", "if", "err", ":=", "del", ".", "Flush", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "total", "==", "0", "{", "return", "graph", ".", "ErrNodeNotExists", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RemoveNode removes all quads with the given value. // // It returns ErrNodeNotExists if node is missing.
[ "RemoveNode", "removes", "all", "quads", "with", "the", "given", "value", ".", "It", "returns", "ErrNodeNotExists", "if", "node", "is", "missing", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/writer/single.go#L84-L110
train
cayleygraph/cayley
graph/iterator/unique.go
Next
func (it *Unique) Next(ctx context.Context) bool { graph.NextLogIn(it) it.runstats.Next += 1 for it.subIt.Next(ctx) { curr := it.subIt.Result() key := graph.ToKey(curr) if ok := it.seen[key]; !ok { it.result = curr it.seen[key] = true return graph.NextLogOut(it, true) } } it.err = it.subIt.Err() return graph.NextLogOut(it, false) }
go
func (it *Unique) Next(ctx context.Context) bool { graph.NextLogIn(it) it.runstats.Next += 1 for it.subIt.Next(ctx) { curr := it.subIt.Result() key := graph.ToKey(curr) if ok := it.seen[key]; !ok { it.result = curr it.seen[key] = true return graph.NextLogOut(it, true) } } it.err = it.subIt.Err() return graph.NextLogOut(it, false) }
[ "func", "(", "it", "*", "Unique", ")", "Next", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "graph", ".", "NextLogIn", "(", "it", ")", "\n", "it", ".", "runstats", ".", "Next", "+=", "1", "\n\n", "for", "it", ".", "subIt", ".", "Next", "(", "ctx", ")", "{", "curr", ":=", "it", ".", "subIt", ".", "Result", "(", ")", "\n", "key", ":=", "graph", ".", "ToKey", "(", "curr", ")", "\n", "if", "ok", ":=", "it", ".", "seen", "[", "key", "]", ";", "!", "ok", "{", "it", ".", "result", "=", "curr", "\n", "it", ".", "seen", "[", "key", "]", "=", "true", "\n", "return", "graph", ".", "NextLogOut", "(", "it", ",", "true", ")", "\n", "}", "\n", "}", "\n", "it", ".", "err", "=", "it", ".", "subIt", ".", "Err", "(", ")", "\n", "return", "graph", ".", "NextLogOut", "(", "it", ",", "false", ")", "\n", "}" ]
// Next advances the subiterator, continuing until it returns a value which it // has not previously seen.
[ "Next", "advances", "the", "subiterator", "continuing", "until", "it", "returns", "a", "value", "which", "it", "has", "not", "previously", "seen", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/unique.go#L67-L82
train
cayleygraph/cayley
graph/iterator/unique.go
Contains
func (it *Unique) Contains(ctx context.Context, val graph.Value) bool { graph.ContainsLogIn(it, val) it.runstats.Contains += 1 return graph.ContainsLogOut(it, val, it.subIt.Contains(ctx, val)) }
go
func (it *Unique) Contains(ctx context.Context, val graph.Value) bool { graph.ContainsLogIn(it, val) it.runstats.Contains += 1 return graph.ContainsLogOut(it, val, it.subIt.Contains(ctx, val)) }
[ "func", "(", "it", "*", "Unique", ")", "Contains", "(", "ctx", "context", ".", "Context", ",", "val", "graph", ".", "Value", ")", "bool", "{", "graph", ".", "ContainsLogIn", "(", "it", ",", "val", ")", "\n", "it", ".", "runstats", ".", "Contains", "+=", "1", "\n", "return", "graph", ".", "ContainsLogOut", "(", "it", ",", "val", ",", "it", ".", "subIt", ".", "Contains", "(", "ctx", ",", "val", ")", ")", "\n", "}" ]
// Contains checks whether the passed value is part of the primary iterator, // which is irrelevant for uniqueness.
[ "Contains", "checks", "whether", "the", "passed", "value", "is", "part", "of", "the", "primary", "iterator", "which", "is", "irrelevant", "for", "uniqueness", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/unique.go#L94-L98
train
cayleygraph/cayley
graph/iterator/unique.go
Close
func (it *Unique) Close() error { it.seen = nil return it.subIt.Close() }
go
func (it *Unique) Close() error { it.seen = nil return it.subIt.Close() }
[ "func", "(", "it", "*", "Unique", ")", "Close", "(", ")", "error", "{", "it", ".", "seen", "=", "nil", "\n", "return", "it", ".", "subIt", ".", "Close", "(", ")", "\n", "}" ]
// Close closes the primary iterators.
[ "Close", "closes", "the", "primary", "iterators", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/unique.go#L108-L111
train
cayleygraph/cayley
query/gizmo/environ.go
Uri
func (g *graphObject) Uri(s string) quad.IRI { return quad.IRI(g.s.ns.FullIRI(s)) }
go
func (g *graphObject) Uri(s string) quad.IRI { return quad.IRI(g.s.ns.FullIRI(s)) }
[ "func", "(", "g", "*", "graphObject", ")", "Uri", "(", "s", "string", ")", "quad", ".", "IRI", "{", "return", "quad", ".", "IRI", "(", "g", ".", "s", ".", "ns", ".", "FullIRI", "(", "s", ")", ")", "\n", "}" ]
// Uri creates an IRI values from a given string.
[ "Uri", "creates", "an", "IRI", "values", "from", "a", "given", "string", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/query/gizmo/environ.go#L44-L46
train
cayleygraph/cayley
query/gizmo/environ.go
AddNamespace
func (g *graphObject) AddNamespace(pref, ns string) { g.s.ns.Register(voc.Namespace{Prefix: pref + ":", Full: ns}) }
go
func (g *graphObject) AddNamespace(pref, ns string) { g.s.ns.Register(voc.Namespace{Prefix: pref + ":", Full: ns}) }
[ "func", "(", "g", "*", "graphObject", ")", "AddNamespace", "(", "pref", ",", "ns", "string", ")", "{", "g", ".", "s", ".", "ns", ".", "Register", "(", "voc", ".", "Namespace", "{", "Prefix", ":", "pref", "+", "\"", "\"", ",", "Full", ":", "ns", "}", ")", "\n", "}" ]
// AddNamespace associates prefix with a given IRI namespace.
[ "AddNamespace", "associates", "prefix", "with", "a", "given", "IRI", "namespace", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/query/gizmo/environ.go#L49-L51
train
cayleygraph/cayley
query/gizmo/environ.go
LoadNamespaces
func (g *graphObject) LoadNamespaces() error { return g.s.sch.LoadNamespaces(g.s.ctx, g.s.qs, &g.s.ns) }
go
func (g *graphObject) LoadNamespaces() error { return g.s.sch.LoadNamespaces(g.s.ctx, g.s.qs, &g.s.ns) }
[ "func", "(", "g", "*", "graphObject", ")", "LoadNamespaces", "(", ")", "error", "{", "return", "g", ".", "s", ".", "sch", ".", "LoadNamespaces", "(", "g", ".", "s", ".", "ctx", ",", "g", ".", "s", ".", "qs", ",", "&", "g", ".", "s", ".", "ns", ")", "\n", "}" ]
// LoadNamespaces loads all namespaces saved to graph.
[ "LoadNamespaces", "loads", "all", "namespaces", "saved", "to", "graph", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/query/gizmo/environ.go#L59-L61
train
cayleygraph/cayley
query/gizmo/environ.go
V
func (g *graphObject) V(call goja.FunctionCall) goja.Value { return g.Vertex(call) }
go
func (g *graphObject) V(call goja.FunctionCall) goja.Value { return g.Vertex(call) }
[ "func", "(", "g", "*", "graphObject", ")", "V", "(", "call", "goja", ".", "FunctionCall", ")", "goja", ".", "Value", "{", "return", "g", ".", "Vertex", "(", "call", ")", "\n", "}" ]
// V is a shorthand for Vertex.
[ "V", "is", "a", "shorthand", "for", "Vertex", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/query/gizmo/environ.go#L64-L66
train
cayleygraph/cayley
graph/iterator/count.go
Next
func (it *Count) Next(ctx context.Context) bool { if it.done { return false } size, exact := it.it.Size() if !exact { for size = 0; it.it.Next(ctx); size++ { for ; it.it.NextPath(ctx); size++ { } } } it.result = quad.Int(size) it.done = true return true }
go
func (it *Count) Next(ctx context.Context) bool { if it.done { return false } size, exact := it.it.Size() if !exact { for size = 0; it.it.Next(ctx); size++ { for ; it.it.NextPath(ctx); size++ { } } } it.result = quad.Int(size) it.done = true return true }
[ "func", "(", "it", "*", "Count", ")", "Next", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "if", "it", ".", "done", "{", "return", "false", "\n", "}", "\n", "size", ",", "exact", ":=", "it", ".", "it", ".", "Size", "(", ")", "\n", "if", "!", "exact", "{", "for", "size", "=", "0", ";", "it", ".", "it", ".", "Next", "(", "ctx", ")", ";", "size", "++", "{", "for", ";", "it", ".", "it", ".", "NextPath", "(", "ctx", ")", ";", "size", "++", "{", "}", "\n", "}", "\n", "}", "\n", "it", ".", "result", "=", "quad", ".", "Int", "(", "size", ")", "\n", "it", ".", "done", "=", "true", "\n", "return", "true", "\n", "}" ]
// Next counts a number of results in underlying iterator.
[ "Next", "counts", "a", "number", "of", "results", "in", "underlying", "iterator", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/count.go#L62-L76
train
cayleygraph/cayley
graph/iterator/materialize.go
Size
func (it *Materialize) Size() (int64, bool) { if it.hasRun && !it.aborted { if clog.V(2) { clog.Infof("returning size %v", it.actualSize) } return it.actualSize, true } if clog.V(2) { clog.Infof("bailing size %v", it.actualSize) } return it.subIt.Size() }
go
func (it *Materialize) Size() (int64, bool) { if it.hasRun && !it.aborted { if clog.V(2) { clog.Infof("returning size %v", it.actualSize) } return it.actualSize, true } if clog.V(2) { clog.Infof("bailing size %v", it.actualSize) } return it.subIt.Size() }
[ "func", "(", "it", "*", "Materialize", ")", "Size", "(", ")", "(", "int64", ",", "bool", ")", "{", "if", "it", ".", "hasRun", "&&", "!", "it", ".", "aborted", "{", "if", "clog", ".", "V", "(", "2", ")", "{", "clog", ".", "Infof", "(", "\"", "\"", ",", "it", ".", "actualSize", ")", "\n", "}", "\n", "return", "it", ".", "actualSize", ",", "true", "\n", "}", "\n", "if", "clog", ".", "V", "(", "2", ")", "{", "clog", ".", "Infof", "(", "\"", "\"", ",", "it", ".", "actualSize", ")", "\n", "}", "\n", "return", "it", ".", "subIt", ".", "Size", "(", ")", "\n", "}" ]
// Size is the number of values stored, if we've got them all. // Otherwise, guess based on the size of the subiterator.
[ "Size", "is", "the", "number", "of", "values", "stored", "if", "we", "ve", "got", "them", "all", ".", "Otherwise", "guess", "based", "on", "the", "size", "of", "the", "subiterator", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/materialize.go#L161-L172
train
cayleygraph/cayley
graph/iterator/materialize.go
Stats
func (it *Materialize) Stats() graph.IteratorStats { overhead := int64(2) var ( size int64 exact bool ) if it.expectSize > 0 { size, exact = it.expectSize, false } else { size, exact = it.Size() } subitStats := it.subIt.Stats() return graph.IteratorStats{ ContainsCost: overhead * subitStats.NextCost, NextCost: overhead * subitStats.NextCost, Size: size, ExactSize: exact, Next: it.runstats.Next, Contains: it.runstats.Contains, } }
go
func (it *Materialize) Stats() graph.IteratorStats { overhead := int64(2) var ( size int64 exact bool ) if it.expectSize > 0 { size, exact = it.expectSize, false } else { size, exact = it.Size() } subitStats := it.subIt.Stats() return graph.IteratorStats{ ContainsCost: overhead * subitStats.NextCost, NextCost: overhead * subitStats.NextCost, Size: size, ExactSize: exact, Next: it.runstats.Next, Contains: it.runstats.Contains, } }
[ "func", "(", "it", "*", "Materialize", ")", "Stats", "(", ")", "graph", ".", "IteratorStats", "{", "overhead", ":=", "int64", "(", "2", ")", "\n", "var", "(", "size", "int64", "\n", "exact", "bool", "\n", ")", "\n", "if", "it", ".", "expectSize", ">", "0", "{", "size", ",", "exact", "=", "it", ".", "expectSize", ",", "false", "\n", "}", "else", "{", "size", ",", "exact", "=", "it", ".", "Size", "(", ")", "\n", "}", "\n", "subitStats", ":=", "it", ".", "subIt", ".", "Stats", "(", ")", "\n", "return", "graph", ".", "IteratorStats", "{", "ContainsCost", ":", "overhead", "*", "subitStats", ".", "NextCost", ",", "NextCost", ":", "overhead", "*", "subitStats", ".", "NextCost", ",", "Size", ":", "size", ",", "ExactSize", ":", "exact", ",", "Next", ":", "it", ".", "runstats", ".", "Next", ",", "Contains", ":", "it", ".", "runstats", ".", "Contains", ",", "}", "\n", "}" ]
// The entire point of Materialize is to amortize the cost by // putting it all up front.
[ "The", "entire", "point", "of", "Materialize", "is", "to", "amortize", "the", "cost", "by", "putting", "it", "all", "up", "front", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/iterator/materialize.go#L176-L196
train
cayleygraph/cayley
schema/writer.go
WriteAsQuads
func (c *Config) WriteAsQuads(w quad.Writer, o interface{}) (quad.Value, error) { wr := c.newWriter(w) return wr.writeAsQuads(reflect.ValueOf(o)) }
go
func (c *Config) WriteAsQuads(w quad.Writer, o interface{}) (quad.Value, error) { wr := c.newWriter(w) return wr.writeAsQuads(reflect.ValueOf(o)) }
[ "func", "(", "c", "*", "Config", ")", "WriteAsQuads", "(", "w", "quad", ".", "Writer", ",", "o", "interface", "{", "}", ")", "(", "quad", ".", "Value", ",", "error", ")", "{", "wr", ":=", "c", ".", "newWriter", "(", "w", ")", "\n", "return", "wr", ".", "writeAsQuads", "(", "reflect", ".", "ValueOf", "(", "o", ")", ")", "\n", "}" ]
// WriteAsQuads writes a single value in form of quads into specified quad writer. // // It returns an identifier of the object in the output sub-graph. If an object has // an annotated ID field, it's value will be converted to quad.Value and returned. // Otherwise, a new BNode will be generated using GenerateID function. // // See LoadTo for a list of quads mapping rules.
[ "WriteAsQuads", "writes", "a", "single", "value", "in", "form", "of", "quads", "into", "specified", "quad", "writer", ".", "It", "returns", "an", "identifier", "of", "the", "object", "in", "the", "output", "sub", "-", "graph", ".", "If", "an", "object", "has", "an", "annotated", "ID", "field", "it", "s", "value", "will", "be", "converted", "to", "quad", ".", "Value", "and", "returned", ".", "Otherwise", "a", "new", "BNode", "will", "be", "generated", "using", "GenerateID", "function", ".", "See", "LoadTo", "for", "a", "list", "of", "quads", "mapping", "rules", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/schema/writer.go#L17-L20
train
cayleygraph/cayley
schema/writer.go
writeOneValReflect
func (w *writer) writeOneValReflect(id quad.Value, pred quad.Value, rv reflect.Value, rev bool) error { if isZero(rv) { return nil } // write field value and get an ID sid, err := w.writeAsQuads(rv) if err != nil { return err } // write a quad pointing to this value return w.writeQuad(id, pred, sid, rev) }
go
func (w *writer) writeOneValReflect(id quad.Value, pred quad.Value, rv reflect.Value, rev bool) error { if isZero(rv) { return nil } // write field value and get an ID sid, err := w.writeAsQuads(rv) if err != nil { return err } // write a quad pointing to this value return w.writeQuad(id, pred, sid, rev) }
[ "func", "(", "w", "*", "writer", ")", "writeOneValReflect", "(", "id", "quad", ".", "Value", ",", "pred", "quad", ".", "Value", ",", "rv", "reflect", ".", "Value", ",", "rev", "bool", ")", "error", "{", "if", "isZero", "(", "rv", ")", "{", "return", "nil", "\n", "}", "\n", "// write field value and get an ID", "sid", ",", "err", ":=", "w", ".", "writeAsQuads", "(", "rv", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "// write a quad pointing to this value", "return", "w", ".", "writeQuad", "(", "id", ",", "pred", ",", "sid", ",", "rev", ")", "\n", "}" ]
// writeOneValReflect writes a set of quads corresponding to a value. It may omit writing quads if value is zero.
[ "writeOneValReflect", "writes", "a", "set", "of", "quads", "corresponding", "to", "a", "value", ".", "It", "may", "omit", "writing", "quads", "if", "value", "is", "zero", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/schema/writer.go#L40-L51
train
cayleygraph/cayley
graph/transaction.go
NewTransactionN
func NewTransactionN(n int) *Transaction { return &Transaction{Deltas: make([]Delta, 0, n), deltas: make(map[Delta]struct{}, n)} }
go
func NewTransactionN(n int) *Transaction { return &Transaction{Deltas: make([]Delta, 0, n), deltas: make(map[Delta]struct{}, n)} }
[ "func", "NewTransactionN", "(", "n", "int", ")", "*", "Transaction", "{", "return", "&", "Transaction", "{", "Deltas", ":", "make", "(", "[", "]", "Delta", ",", "0", ",", "n", ")", ",", "deltas", ":", "make", "(", "map", "[", "Delta", "]", "struct", "{", "}", ",", "n", ")", "}", "\n", "}" ]
// NewTransactionN initialize a new transaction with a predefined capacity.
[ "NewTransactionN", "initialize", "a", "new", "transaction", "with", "a", "predefined", "capacity", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/transaction.go#L33-L35
train
cayleygraph/cayley
graph/transaction.go
AddQuad
func (t *Transaction) AddQuad(q quad.Quad) { ad, rd := createDeltas(q) if _, adExists := t.deltas[ad]; !adExists { if _, rdExists := t.deltas[rd]; rdExists { t.deleteDelta(rd) } else { t.addDelta(ad) } } }
go
func (t *Transaction) AddQuad(q quad.Quad) { ad, rd := createDeltas(q) if _, adExists := t.deltas[ad]; !adExists { if _, rdExists := t.deltas[rd]; rdExists { t.deleteDelta(rd) } else { t.addDelta(ad) } } }
[ "func", "(", "t", "*", "Transaction", ")", "AddQuad", "(", "q", "quad", ".", "Quad", ")", "{", "ad", ",", "rd", ":=", "createDeltas", "(", "q", ")", "\n\n", "if", "_", ",", "adExists", ":=", "t", ".", "deltas", "[", "ad", "]", ";", "!", "adExists", "{", "if", "_", ",", "rdExists", ":=", "t", ".", "deltas", "[", "rd", "]", ";", "rdExists", "{", "t", ".", "deleteDelta", "(", "rd", ")", "\n", "}", "else", "{", "t", ".", "addDelta", "(", "ad", ")", "\n", "}", "\n", "}", "\n", "}" ]
// AddQuad adds a new quad to the transaction if it is not already present in it. // If there is a 'remove' delta for that quad, it will remove that delta from // the transaction instead of actually adding the quad.
[ "AddQuad", "adds", "a", "new", "quad", "to", "the", "transaction", "if", "it", "is", "not", "already", "present", "in", "it", ".", "If", "there", "is", "a", "remove", "delta", "for", "that", "quad", "it", "will", "remove", "that", "delta", "from", "the", "transaction", "instead", "of", "actually", "adding", "the", "quad", "." ]
5318a818e947b20ef36a274f643e577f036bca7c
https://github.com/cayleygraph/cayley/blob/5318a818e947b20ef36a274f643e577f036bca7c/graph/transaction.go#L40-L50
train
go-vgo/robotgo
clipboard/clipboard_windows.go
waitOpenClipboard
func waitOpenClipboard() error { started := time.Now() limit := started.Add(time.Second) var r uintptr var err error for time.Now().Before(limit) { r, _, err = openClipboard.Call(0) if r != 0 { return nil } time.Sleep(time.Millisecond) } return err }
go
func waitOpenClipboard() error { started := time.Now() limit := started.Add(time.Second) var r uintptr var err error for time.Now().Before(limit) { r, _, err = openClipboard.Call(0) if r != 0 { return nil } time.Sleep(time.Millisecond) } return err }
[ "func", "waitOpenClipboard", "(", ")", "error", "{", "started", ":=", "time", ".", "Now", "(", ")", "\n", "limit", ":=", "started", ".", "Add", "(", "time", ".", "Second", ")", "\n", "var", "r", "uintptr", "\n", "var", "err", "error", "\n", "for", "time", ".", "Now", "(", ")", ".", "Before", "(", "limit", ")", "{", "r", ",", "_", ",", "err", "=", "openClipboard", ".", "Call", "(", "0", ")", "\n", "if", "r", "!=", "0", "{", "return", "nil", "\n", "}", "\n", "time", ".", "Sleep", "(", "time", ".", "Millisecond", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// waitOpenClipboard opens the clipboard, waiting for up to a second to do so.
[ "waitOpenClipboard", "opens", "the", "clipboard", "waiting", "for", "up", "to", "a", "second", "to", "do", "so", "." ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/clipboard/clipboard_windows.go#L38-L51
train
go-vgo/robotgo
robotgo_unix.go
GetXId
func GetXId(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) { if xu == nil { var err error xu, err = xgbutil.NewConn() if err != nil { // log.Println("xgbutil.NewConn errors is: ", err) return 0, err } } xid, err := GetXidFromPid(xu, pid) return xid, err }
go
func GetXId(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) { if xu == nil { var err error xu, err = xgbutil.NewConn() if err != nil { // log.Println("xgbutil.NewConn errors is: ", err) return 0, err } } xid, err := GetXidFromPid(xu, pid) return xid, err }
[ "func", "GetXId", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "pid", "int32", ")", "(", "xproto", ".", "Window", ",", "error", ")", "{", "if", "xu", "==", "nil", "{", "var", "err", "error", "\n", "xu", ",", "err", "=", "xgbutil", ".", "NewConn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "// log.Println(\"xgbutil.NewConn errors is: \", err)", "return", "0", ",", "err", "\n", "}", "\n", "}", "\n\n", "xid", ",", "err", ":=", "GetXidFromPid", "(", "xu", ",", "pid", ")", "\n", "return", "xid", ",", "err", "\n", "}" ]
// GetXId get the xid return window and error
[ "GetXId", "get", "the", "xid", "return", "window", "and", "error" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo_unix.go#L119-L131
train
go-vgo/robotgo
robotgo_unix.go
GetXidFromPid
func GetXidFromPid(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) { windows, err := ewmh.ClientListGet(xu) if err != nil { return 0, err } for _, window := range windows { wmPid, err := ewmh.WmPidGet(xu, window) if err != nil { return 0, err } if uint(pid) == wmPid { return window, nil } } return 0, errors.New("failed to find a window with a matching pid.") }
go
func GetXidFromPid(xu *xgbutil.XUtil, pid int32) (xproto.Window, error) { windows, err := ewmh.ClientListGet(xu) if err != nil { return 0, err } for _, window := range windows { wmPid, err := ewmh.WmPidGet(xu, window) if err != nil { return 0, err } if uint(pid) == wmPid { return window, nil } } return 0, errors.New("failed to find a window with a matching pid.") }
[ "func", "GetXidFromPid", "(", "xu", "*", "xgbutil", ".", "XUtil", ",", "pid", "int32", ")", "(", "xproto", ".", "Window", ",", "error", ")", "{", "windows", ",", "err", ":=", "ewmh", ".", "ClientListGet", "(", "xu", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "window", ":=", "range", "windows", "{", "wmPid", ",", "err", ":=", "ewmh", ".", "WmPidGet", "(", "xu", ",", "window", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "if", "uint", "(", "pid", ")", "==", "wmPid", "{", "return", "window", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// GetXidFromPid get the xide from pid
[ "GetXidFromPid", "get", "the", "xide", "from", "pid" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo_unix.go#L134-L152
train
go-vgo/robotgo
robotgo_win.go
FindWindow
func FindWindow(str string) win.HWND { hwnd := win.FindWindow(nil, syscall.StringToUTF16Ptr(str)) return hwnd }
go
func FindWindow(str string) win.HWND { hwnd := win.FindWindow(nil, syscall.StringToUTF16Ptr(str)) return hwnd }
[ "func", "FindWindow", "(", "str", "string", ")", "win", ".", "HWND", "{", "hwnd", ":=", "win", ".", "FindWindow", "(", "nil", ",", "syscall", ".", "StringToUTF16Ptr", "(", "str", ")", ")", "\n\n", "return", "hwnd", "\n", "}" ]
// FindWindow find window hwnd by name
[ "FindWindow", "find", "window", "hwnd", "by", "name" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo_win.go#L22-L26
train
go-vgo/robotgo
robotgo_ocr.go
GetText
func GetText(imgPath string, args ...string) (string, error) { var lang = "eng" if len(args) > 0 { lang = args[0] if lang == "zh" { lang = "chi_sim" } } client := gosseract.NewClient() defer client.Close() client.SetImage(imgPath) client.SetLanguage(lang) return client.Text() }
go
func GetText(imgPath string, args ...string) (string, error) { var lang = "eng" if len(args) > 0 { lang = args[0] if lang == "zh" { lang = "chi_sim" } } client := gosseract.NewClient() defer client.Close() client.SetImage(imgPath) client.SetLanguage(lang) return client.Text() }
[ "func", "GetText", "(", "imgPath", "string", ",", "args", "...", "string", ")", "(", "string", ",", "error", ")", "{", "var", "lang", "=", "\"", "\"", "\n\n", "if", "len", "(", "args", ")", ">", "0", "{", "lang", "=", "args", "[", "0", "]", "\n", "if", "lang", "==", "\"", "\"", "{", "lang", "=", "\"", "\"", "\n", "}", "\n", "}", "\n\n", "client", ":=", "gosseract", ".", "NewClient", "(", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n\n", "client", ".", "SetImage", "(", "imgPath", ")", "\n", "client", ".", "SetLanguage", "(", "lang", ")", "\n", "return", "client", ".", "Text", "(", ")", "\n", "}" ]
// GetText get the image text by tesseract ocr
[ "GetText", "get", "the", "image", "text", "by", "tesseract", "ocr" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo_ocr.go#L20-L36
train
go-vgo/robotgo
robotgo.go
MilliSleep
func MilliSleep(tm int) { time.Sleep(time.Duration(tm) * time.Millisecond) }
go
func MilliSleep(tm int) { time.Sleep(time.Duration(tm) * time.Millisecond) }
[ "func", "MilliSleep", "(", "tm", "int", ")", "{", "time", ".", "Sleep", "(", "time", ".", "Duration", "(", "tm", ")", "*", "time", ".", "Millisecond", ")", "\n", "}" ]
// MilliSleep sleep tm milli second
[ "MilliSleep", "sleep", "tm", "milli", "second" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L116-L118
train
go-vgo/robotgo
robotgo.go
Sleep
func Sleep(tm int) { time.Sleep(time.Duration(tm) * time.Second) }
go
func Sleep(tm int) { time.Sleep(time.Duration(tm) * time.Second) }
[ "func", "Sleep", "(", "tm", "int", ")", "{", "time", ".", "Sleep", "(", "time", ".", "Duration", "(", "tm", ")", "*", "time", ".", "Second", ")", "\n", "}" ]
// Sleep time.Sleep tm second
[ "Sleep", "time", ".", "Sleep", "tm", "second" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L121-L123
train
go-vgo/robotgo
robotgo.go
UintToHex
func UintToHex(u uint32) CHex { hex := U32ToHex(C.uint32_t(u)) return CHex(hex) }
go
func UintToHex(u uint32) CHex { hex := U32ToHex(C.uint32_t(u)) return CHex(hex) }
[ "func", "UintToHex", "(", "u", "uint32", ")", "CHex", "{", "hex", ":=", "U32ToHex", "(", "C", ".", "uint32_t", "(", "u", ")", ")", "\n", "return", "CHex", "(", "hex", ")", "\n", "}" ]
// UintToHex trans uint32 to robotgo.CHex
[ "UintToHex", "trans", "uint32", "to", "robotgo", ".", "CHex" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L150-L153
train
go-vgo/robotgo
robotgo.go
PadHex
func PadHex(hex C.MMRGBHex) string { color := C.pad_hex(hex) gcolor := C.GoString(color) C.free(unsafe.Pointer(color)) return gcolor }
go
func PadHex(hex C.MMRGBHex) string { color := C.pad_hex(hex) gcolor := C.GoString(color) C.free(unsafe.Pointer(color)) return gcolor }
[ "func", "PadHex", "(", "hex", "C", ".", "MMRGBHex", ")", "string", "{", "color", ":=", "C", ".", "pad_hex", "(", "hex", ")", "\n", "gcolor", ":=", "C", ".", "GoString", "(", "color", ")", "\n", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "color", ")", ")", "\n\n", "return", "gcolor", "\n", "}" ]
// PadHex trans C.MMRGBHex to string
[ "PadHex", "trans", "C", ".", "MMRGBHex", "to", "string" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L166-L172
train
go-vgo/robotgo
robotgo.go
HexToRgb
func HexToRgb(hex uint32) *C.uint8_t { return C.color_hex_to_rgb(C.uint32_t(hex)) }
go
func HexToRgb(hex uint32) *C.uint8_t { return C.color_hex_to_rgb(C.uint32_t(hex)) }
[ "func", "HexToRgb", "(", "hex", "uint32", ")", "*", "C", ".", "uint8_t", "{", "return", "C", ".", "color_hex_to_rgb", "(", "C", ".", "uint32_t", "(", "hex", ")", ")", "\n", "}" ]
// HexToRgb trans hex to rgb
[ "HexToRgb", "trans", "hex", "to", "rgb" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L175-L177
train
go-vgo/robotgo
robotgo.go
RgbToHex
func RgbToHex(r, g, b uint8) C.uint32_t { return C.color_rgb_to_hex(C.uint8_t(r), C.uint8_t(g), C.uint8_t(b)) }
go
func RgbToHex(r, g, b uint8) C.uint32_t { return C.color_rgb_to_hex(C.uint8_t(r), C.uint8_t(g), C.uint8_t(b)) }
[ "func", "RgbToHex", "(", "r", ",", "g", ",", "b", "uint8", ")", "C", ".", "uint32_t", "{", "return", "C", ".", "color_rgb_to_hex", "(", "C", ".", "uint8_t", "(", "r", ")", ",", "C", ".", "uint8_t", "(", "g", ")", ",", "C", ".", "uint8_t", "(", "b", ")", ")", "\n", "}" ]
// RgbToHex trans rgb to hex
[ "RgbToHex", "trans", "rgb", "to", "hex" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L180-L182
train
go-vgo/robotgo
robotgo.go
GetPxColor
func GetPxColor(x, y int) C.MMRGBHex { cx := C.size_t(x) cy := C.size_t(y) color := C.get_px_color(cx, cy) return color }
go
func GetPxColor(x, y int) C.MMRGBHex { cx := C.size_t(x) cy := C.size_t(y) color := C.get_px_color(cx, cy) return color }
[ "func", "GetPxColor", "(", "x", ",", "y", "int", ")", "C", ".", "MMRGBHex", "{", "cx", ":=", "C", ".", "size_t", "(", "x", ")", "\n", "cy", ":=", "C", ".", "size_t", "(", "y", ")", "\n\n", "color", ":=", "C", ".", "get_px_color", "(", "cx", ",", "cy", ")", "\n", "return", "color", "\n", "}" ]
// GetPxColor get pixel color return C.MMRGBHex
[ "GetPxColor", "get", "pixel", "color", "return", "C", ".", "MMRGBHex" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L185-L191
train
go-vgo/robotgo
robotgo.go
GetPixelColor
func GetPixelColor(x, y int) string { cx := C.size_t(x) cy := C.size_t(y) color := C.get_pixel_color(cx, cy) gcolor := C.GoString(color) C.free(unsafe.Pointer(color)) return gcolor }
go
func GetPixelColor(x, y int) string { cx := C.size_t(x) cy := C.size_t(y) color := C.get_pixel_color(cx, cy) gcolor := C.GoString(color) C.free(unsafe.Pointer(color)) return gcolor }
[ "func", "GetPixelColor", "(", "x", ",", "y", "int", ")", "string", "{", "cx", ":=", "C", ".", "size_t", "(", "x", ")", "\n", "cy", ":=", "C", ".", "size_t", "(", "y", ")", "\n\n", "color", ":=", "C", ".", "get_pixel_color", "(", "cx", ",", "cy", ")", "\n", "gcolor", ":=", "C", ".", "GoString", "(", "color", ")", "\n", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "color", ")", ")", "\n\n", "return", "gcolor", "\n", "}" ]
// GetPixelColor get pixel color return string
[ "GetPixelColor", "get", "pixel", "color", "return", "string" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L194-L203
train
go-vgo/robotgo
robotgo.go
GetScreenSize
func GetScreenSize() (int, int) { size := C.get_screen_size() // fmt.Println("...", size, size.width) return int(size.width), int(size.height) }
go
func GetScreenSize() (int, int) { size := C.get_screen_size() // fmt.Println("...", size, size.width) return int(size.width), int(size.height) }
[ "func", "GetScreenSize", "(", ")", "(", "int", ",", "int", ")", "{", "size", ":=", "C", ".", "get_screen_size", "(", ")", "\n", "// fmt.Println(\"...\", size, size.width)", "return", "int", "(", "size", ".", "width", ")", ",", "int", "(", "size", ".", "height", ")", "\n", "}" ]
// GetScreenSize get the screen size
[ "GetScreenSize", "get", "the", "screen", "size" ]
d643b9ffe5a44c524740136edc428be68ddbecae
https://github.com/go-vgo/robotgo/blob/d643b9ffe5a44c524740136edc428be68ddbecae/robotgo.go#L222-L226
train