_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q12400
NewRandomGraph
train
func NewRandomGraph(n int) (generator.Generator, error) { if n < 1 { return nil, fmt.Errorf("invalid number of nodes %d<1", n) } nt, err := node.NewType("/gn") if err != nil { return nil, err } p, err := predicate.NewImmutable("follow") if err != nil { return nil, err } return &randomGraph{ nodes: ...
go
{ "resource": "" }
q12401
newTriple
train
func (r *randomGraph) newTriple(i, j int) (*triple.Triple, error) { s, err := r.newNode(i) if err != nil { return nil, err } o, err := r.newNode(j) if err != nil { return nil, err } return triple.New(s, r.predicate, triple.NewNodeObject(o)) }
go
{ "resource": "" }
q12402
Generate
train
func (r *randomGraph) Generate(n int) ([]*triple.Triple, error) { maxEdges := r.nodes * r.nodes if n > maxEdges { return nil, fmt.Errorf("current configuration only allow a max of %d triples (%d requested)", maxEdges, n) } var trpls []*triple.Triple for _, idx := range rand.Perm(maxEdges)[:n] { i, j := idx/r.n...
go
{ "resource": "" }
q12403
New
train
func New(bs []string) (*Table, error) { m := make(map[string]bool) for _, b := range bs { m[b] = true } if len(m) != len(bs) { return nil, fmt.Errorf("table.New does not allow duplicated bindings in %s", bs) } return &Table{ AvailableBindings: bs, mbs: m, }, nil }
go
{ "resource": "" }
q12404
String
train
func (c *Cell) String() string { if c.S != nil { return *c.S } if c.N != nil { return c.N.String() } if c.P != nil { return c.P.String() } if c.L != nil { return c.L.String() } if c.T != nil { return c.T.Format(time.RFC3339Nano) } return "<NULL>" }
go
{ "resource": "" }
q12405
ToTextLine
train
func (r Row) ToTextLine(res *bytes.Buffer, bs []string, sep string) error { cnt := len(bs) if sep == "" { sep = "\t" } for _, b := range bs { cnt-- v := "<NULL>" if c, ok := r[b]; ok { v = c.String() } if _, err := res.WriteString(v); err != nil { return err } if cnt > 0 { res.WriteString(s...
go
{ "resource": "" }
q12406
AddRow
train
func (t *Table) AddRow(r Row) { t.mu.Lock() if len(r) > 0 { delete(r, "") t.Data = append(t.Data, r) } t.mu.Unlock() }
go
{ "resource": "" }
q12407
NumRows
train
func (t *Table) NumRows() int { t.mu.RLock() defer t.mu.RUnlock() return len(t.Data) }
go
{ "resource": "" }
q12408
Row
train
func (t *Table) Row(i int) (Row, bool) { t.mu.RLock() defer t.mu.RUnlock() if i < 0 || i >= len(t.Data) { return nil, false } return t.Data[i], true }
go
{ "resource": "" }
q12409
Rows
train
func (t *Table) Rows() []Row { t.mu.RLock() defer t.mu.RUnlock() return t.Data }
go
{ "resource": "" }
q12410
unsafeAddBindings
train
func (t *Table) unsafeAddBindings(bs []string) { for _, b := range bs { if !t.mbs[b] { t.mbs[b] = true t.AvailableBindings = append(t.AvailableBindings, b) } } }
go
{ "resource": "" }
q12411
AddBindings
train
func (t *Table) AddBindings(bs []string) { t.mu.Lock() t.unsafeAddBindings(bs) t.mu.Unlock() }
go
{ "resource": "" }
q12412
ProjectBindings
train
func (t *Table) ProjectBindings(bs []string) error { t.mu.Lock() defer t.mu.Unlock() if len(t.Data) == 0 || len(t.mbs) == 0 { return nil } for _, b := range bs { if !t.mbs[b] { return fmt.Errorf("cannot project against unknown binding %s; known bindinds are %v", b, t.AvailableBindings) } } t.AvailableBi...
go
{ "resource": "" }
q12413
HasBinding
train
func (t *Table) HasBinding(b string) bool { t.mu.RLock() defer t.mu.RUnlock() return t.mbs[b] }
go
{ "resource": "" }
q12414
Bindings
train
func (t *Table) Bindings() []string { t.mu.RLock() defer t.mu.RUnlock() return t.AvailableBindings }
go
{ "resource": "" }
q12415
equalBindings
train
func equalBindings(b1, b2 map[string]bool) bool { if len(b1) != len(b2) { return false } for k := range b1 { if !b2[k] { return false } } return true }
go
{ "resource": "" }
q12416
AppendTable
train
func (t *Table) AppendTable(t2 *Table) error { t.mu.Lock() defer t.mu.Unlock() if t2 == nil { return nil } if len(t.AvailableBindings) > 0 && !equalBindings(t.mbs, t2.mbs) { return fmt.Errorf("AppendTable can only append to an empty table or equally binded table; intead got %v and %v", t.AvailableBindings, t2....
go
{ "resource": "" }
q12417
disjointBinding
train
func disjointBinding(b1, b2 map[string]bool) bool { for k := range b1 { if b2[k] { return false } } return true }
go
{ "resource": "" }
q12418
MergeRows
train
func MergeRows(ms []Row) Row { res := make(map[string]*Cell) for _, om := range ms { for k, v := range om { if k != "" { res[k] = v } } } return res }
go
{ "resource": "" }
q12419
DotProduct
train
func (t *Table) DotProduct(t2 *Table) error { t.mu.Lock() defer t.mu.Unlock() if !disjointBinding(t.mbs, t2.mbs) { return fmt.Errorf("DotProduct operations requires disjoint bindings; instead got %v and %v", t.mbs, t2.mbs) } // Update the table metadata. m := make(map[string]bool) for k := range t.mbs { m[k]...
go
{ "resource": "" }
q12420
Truncate
train
func (t *Table) Truncate() { t.mu.Lock() defer t.mu.Unlock() t.Data = nil }
go
{ "resource": "" }
q12421
Limit
train
func (t *Table) Limit(i int64) { t.mu.Lock() defer t.mu.Unlock() if int64(len(t.Data)) > i { td := make([]Row, i, i) // Preallocate resulting table. copy(td, t.Data[:i]) t.Data = td } }
go
{ "resource": "" }
q12422
Swap
train
func (c bySortConfig) Swap(i, j int) { c.rows[i], c.rows[j] = c.rows[j], c.rows[i] }
go
{ "resource": "" }
q12423
Less
train
func (c bySortConfig) Less(i, j int) bool { ri, rj, cfg := c.rows[i], c.rows[j], c.cfg return rowLess(ri, rj, cfg) }
go
{ "resource": "" }
q12424
unsafeSort
train
func (t *Table) unsafeSort(cfg SortConfig) { if cfg == nil { return } sort.Sort(bySortConfig{t.Data, cfg}) }
go
{ "resource": "" }
q12425
Sort
train
func (t *Table) Sort(cfg SortConfig) { t.mu.Lock() t.unsafeSort(cfg) t.mu.Unlock() }
go
{ "resource": "" }
q12426
groupRangeReduce
train
func (t *Table) groupRangeReduce(i, j int, alias map[string]string, acc map[string]Accumulator) (Row, error) { t.mu.Lock() defer t.mu.Unlock() if i > j { return nil, fmt.Errorf("cannot aggregate empty ranges [%d, %d)", i, j) } // Initialize the range and accumulator results. rng := t.Data[i:j] vaccs := make(ma...
go
{ "resource": "" }
q12427
unsafeFullGroupRangeReduce
train
func (t *Table) unsafeFullGroupRangeReduce(i, j int, acc map[string]map[string]AliasAccPair) (Row, error) { if i > j { return nil, fmt.Errorf("cannot aggregate empty ranges [%d, %d)", i, j) } // Initialize the range and accumulator results. rng := t.Data[i:j] // Reset the accumulators. for _, aap := range acc {...
go
{ "resource": "" }
q12428
toMap
train
func toMap(aaps []AliasAccPair) map[string]map[string]AliasAccPair { resMap := make(map[string]map[string]AliasAccPair) for _, aap := range aaps { m, ok := resMap[aap.InAlias] if !ok { m = make(map[string]AliasAccPair) resMap[aap.InAlias] = m } m[aap.OutAlias] = aap } return resMap }
go
{ "resource": "" }
q12429
Reduce
train
func (t *Table) Reduce(cfg SortConfig, aaps []AliasAccPair) error { t.mu.Lock() defer t.mu.Unlock() maaps := toMap(aaps) // Input validation tests. if len(t.AvailableBindings) != len(maaps) { return fmt.Errorf("table.Reduce cannot project bindings; current %v, requested %v", t.AvailableBindings, aaps) } for _,...
go
{ "resource": "" }
q12430
Filter
train
func (t *Table) Filter(f func(Row) bool) { t.mu.Lock() defer t.mu.Unlock() var newData []Row for _, r := range t.Data { if !f(r) { newData = append(newData, r) } } t.Data = newData }
go
{ "resource": "" }
q12431
ToText
train
func (t *Table) ToText(sep string) (*bytes.Buffer, error) { t.mu.RLock() defer t.mu.RUnlock() res, row := &bytes.Buffer{}, &bytes.Buffer{} res.WriteString(strings.Join(t.AvailableBindings, sep)) res.WriteString("\n") for _, r := range t.Data { err := r.ToTextLine(row, t.AvailableBindings, sep) if err != nil {...
go
{ "resource": "" }
q12432
String
train
func (t *Table) String() string { t.mu.RLock() defer t.mu.RUnlock() b, err := t.ToText("\t") if err != nil { return fmt.Sprintf("Failed to serialize to text! Error: %s", err) } return b.String() }
go
{ "resource": "" }
q12433
Trace
train
func Trace(w io.Writer, msgs func() []string) { if w == nil { return } c <- &event{w, time.Now(), msgs} }
go
{ "resource": "" }
q12434
String
train
func (l *LookupOptions) String() string { b := bytes.NewBufferString("<limit=") b.WriteString(strconv.Itoa(l.MaxElements)) b.WriteString(", lower_anchor=") if l.LowerAnchor != nil { b.WriteString(l.LowerAnchor.Format(time.RFC3339Nano)) } else { b.WriteString("nil") } b.WriteString(", upper_anchor=") if l.Up...
go
{ "resource": "" }
q12435
UUID
train
func (l *LookupOptions) UUID() uuid.UUID { var buffer bytes.Buffer buffer.WriteString(l.String()) return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
go
{ "resource": "" }
q12436
NewGraph
train
func (s *memoryStore) NewGraph(ctx context.Context, id string) (storage.Graph, error) { g := &memory{ id: id, idx: make(map[string]*triple.Triple, initialAllocation), idxS: make(map[string]map[string]*triple.Triple, initialAllocation), idxP: make(map[string]map[string]*triple.Triple, initialAllocation),...
go
{ "resource": "" }
q12437
Graph
train
func (s *memoryStore) Graph(ctx context.Context, id string) (storage.Graph, error) { s.rwmu.RLock() defer s.rwmu.RUnlock() if g, ok := s.graphs[id]; ok { return g, nil } return nil, fmt.Errorf("memory.Graph(%q): graph does not exist", id) }
go
{ "resource": "" }
q12438
AddTriples
train
func (m *memory) AddTriples(ctx context.Context, ts []*triple.Triple) error { m.rwmu.Lock() defer m.rwmu.Unlock() for _, t := range ts { tuuid := UUIDToByteString(t.UUID()) sUUID := UUIDToByteString(t.Subject().UUID()) pUUID := UUIDToByteString(t.Predicate().PartialUUID()) oUUID := UUIDToByteString(t.Object(...
go
{ "resource": "" }
q12439
RemoveTriples
train
func (m *memory) RemoveTriples(ctx context.Context, ts []*triple.Triple) error { for _, t := range ts { suuid := UUIDToByteString(t.UUID()) sUUID := UUIDToByteString(t.Subject().UUID()) pUUID := UUIDToByteString(t.Predicate().PartialUUID()) oUUID := UUIDToByteString(t.Object().UUID()) // Update master index ...
go
{ "resource": "" }
q12440
newChecker
train
func newChecker(o *storage.LookupOptions, op *predicate.Predicate) *checker { var ta *time.Time if op != nil { if t, err := op.TimeAnchor(); err == nil { ta = t } } return &checker{ max: o.MaxElements > 0, c: o.MaxElements, o: o, op: op, ota: ta, } }
go
{ "resource": "" }
q12441
CheckAndUpdate
train
func (c *checker) CheckAndUpdate(p *predicate.Predicate) bool { if c.max && c.c <= 0 { return false } if p.Type() == predicate.Immutable { c.c-- return true } if t, err := p.TimeAnchor(); err == nil { if c.ota != nil && !c.ota.Equal(*t) { return false } if c.o.LowerAnchor != nil && t.Before(*c.o.Lo...
go
{ "resource": "" }
q12442
Objects
train
func (m *memory) Objects(ctx context.Context, s *node.Node, p *predicate.Predicate, lo *storage.LookupOptions, objs chan<- *triple.Object) error { if objs == nil { return fmt.Errorf("cannot provide an empty channel") } sUUID := UUIDToByteString(s.UUID()) pUUID := UUIDToByteString(p.PartialUUID()) spIdx := sUUID...
go
{ "resource": "" }
q12443
Evaluate
train
func (a *AlwaysReturn) Evaluate(r table.Row) (bool, error) { return a.V, nil }
go
{ "resource": "" }
q12444
String
train
func (o OP) String() string { switch o { case LT: return "<" case GT: return ">" case EQ: return "=" case NOT: return "not" case AND: return "and" case OR: return "or" default: return "@UNKNOWN@" } }
go
{ "resource": "" }
q12445
NewEvaluationExpression
train
func NewEvaluationExpression(op OP, lB, rB string) (Evaluator, error) { l, r := strings.TrimSpace(lB), strings.TrimSpace(rB) if l == "" || r == "" { return nil, fmt.Errorf("bindings cannot be empty; got %q, %q", l, r) } switch op { case EQ, LT, GT: return &evaluationNode{ op: op, lB: lB, rB: rB, }, ...
go
{ "resource": "" }
q12446
NewBinaryBooleanExpression
train
func NewBinaryBooleanExpression(op OP, lE, rE Evaluator) (Evaluator, error) { switch op { case AND, OR: return &booleanNode{ op: op, lS: true, lE: lE, rS: true, rE: rE, }, nil default: return nil, errors.New("binary boolean expressions require the operation to be one for the follwing 'and', 'or'...
go
{ "resource": "" }
q12447
NewUnaryBooleanExpression
train
func NewUnaryBooleanExpression(op OP, lE Evaluator) (Evaluator, error) { switch op { case NOT: return &booleanNode{ op: op, lS: true, lE: lE, rS: false, }, nil default: return nil, errors.New("unary boolean expressions require the operation to be one for the follwing 'not'") } }
go
{ "resource": "" }
q12448
NewEvaluator
train
func NewEvaluator(ce []ConsumedElement) (Evaluator, error) { e, tailCEs, err := internalNewEvaluator(ce) if err != nil { return nil, err } if len(tailCEs) > 1 || (len(tailCEs) == 1 && tailCEs[0].Token().Type != lexer.ItemRPar) { return nil, fmt.Errorf("failed to consume all token; left over %v", tailCEs) } re...
go
{ "resource": "" }
q12449
String
train
func (t Type) String() string { switch t { case Bool: return "bool" case Int64: return "int64" case Float64: return "float64" case Text: return "text" case Blob: return "blob" default: return "UNKNOWN" } }
go
{ "resource": "" }
q12450
ToComparableString
train
func (l *Literal) ToComparableString() string { s := "" switch l.t { case Int64: s = fmt.Sprintf("\"%032d\"^^type:%v", l.Interface(), l.Type()) case Float64: s = fmt.Sprintf("\"%032f\"^^type:%v", l.Interface(), l.Type()) default: s = l.String() } return s }
go
{ "resource": "" }
q12451
Bool
train
func (l *Literal) Bool() (bool, error) { if l.t != Bool { return false, fmt.Errorf("literal.Bool: literal is of type %v; cannot be converted to a bool", l.t) } return l.v.(bool), nil }
go
{ "resource": "" }
q12452
Int64
train
func (l *Literal) Int64() (int64, error) { if l.t != Int64 { return 0, fmt.Errorf("literal.Int64: literal is of type %v; cannot be converted to a int64", l.t) } return l.v.(int64), nil }
go
{ "resource": "" }
q12453
Float64
train
func (l *Literal) Float64() (float64, error) { if l.t != Float64 { return 0, fmt.Errorf("literal.Float64: literal is of type %v; cannot be converted to a float64", l.t) } return l.v.(float64), nil }
go
{ "resource": "" }
q12454
Text
train
func (l *Literal) Text() (string, error) { if l.t != Text { return "", fmt.Errorf("literal.Text: literal is of type %v; cannot be converted to a string", l.t) } return l.v.(string), nil }
go
{ "resource": "" }
q12455
Build
train
func (b *unboundBuilder) Build(t Type, v interface{}) (*Literal, error) { switch v.(type) { case bool: if t != Bool { return nil, fmt.Errorf("literal.Build: type %v does not match type of value %v", t, v) } case int64: if t != Int64 { return nil, fmt.Errorf("literal.Build: type %v does not match type of ...
go
{ "resource": "" }
q12456
Parse
train
func (b *unboundBuilder) Parse(s string) (*Literal, error) { raw := strings.TrimSpace(s) if len(raw) == 0 { return nil, fmt.Errorf("literal.Parse: cannot parse and empty string into a literal; provided string %q", s) } if raw[0] != '"' { return nil, fmt.Errorf("literal.Parse: text encoded literals must start wi...
go
{ "resource": "" }
q12457
Build
train
func (b *boundedBuilder) Build(t Type, v interface{}) (*Literal, error) { switch v.(type) { case string: if l := len(v.(string)); l > b.max { return nil, fmt.Errorf("literal.Build: cannot create literal due to size of %v (%d>%d)", v, l, b.max) } case []byte: if l := len(v.([]byte)); l > b.max { return ni...
go
{ "resource": "" }
q12458
Parse
train
func (b *boundedBuilder) Parse(s string) (*Literal, error) { l, err := defaultBuilder.Parse(s) if err != nil { return nil, err } t := l.Type() switch t { case Text: if text, err := l.Text(); err != nil || len(text) > b.max { return nil, fmt.Errorf("literal.Parse: cannot create literal due to size of %v (%d...
go
{ "resource": "" }
q12459
UUID
train
func (l *Literal) UUID() uuid.UUID { var buffer bytes.Buffer switch v := l.v.(type) { case bool: if v { buffer.WriteString("true") } else { buffer.WriteString("false") } case int64: b := make([]byte, 8) binary.PutVarint(b, v) buffer.Write(b) case float64: bs := math.Float64bits(v) b := make(...
go
{ "resource": "" }
q12460
String
train
func (p *Predicate) String() string { if p.anchor == nil { return fmt.Sprintf("%q@[]", p.id) } return fmt.Sprintf("%q@[%s]", p.id, p.anchor.Format(time.RFC3339Nano)) }
go
{ "resource": "" }
q12461
Parse
train
func Parse(s string) (*Predicate, error) { raw := strings.TrimSpace(s) if raw == "" { return nil, fmt.Errorf("predicate.Parse cannot create predicate from empty string %q", s) } if raw[0] != '"' { return nil, fmt.Errorf("predicate.Parse failed to parse since string does not start with \" in %s", s) } idx := s...
go
{ "resource": "" }
q12462
TimeAnchor
train
func (p *Predicate) TimeAnchor() (*time.Time, error) { if p.anchor == nil { return nil, fmt.Errorf("predicate.TimeAnchor cannot return anchor for immutable predicate %v", p) } return p.anchor, nil }
go
{ "resource": "" }
q12463
NewImmutable
train
func NewImmutable(id string) (*Predicate, error) { if id == "" { return nil, fmt.Errorf("predicate.NewImmutable(%q) cannot create a immutable predicate with empty ID", id) } return &Predicate{ id: ID(id), }, nil }
go
{ "resource": "" }
q12464
NewTemporal
train
func NewTemporal(id string, t time.Time) (*Predicate, error) { if id == "" { return nil, fmt.Errorf("predicate.NewTemporal(%q, %v) cannot create a temporal predicate with empty ID", id, t) } return &Predicate{ id: ID(id), anchor: &t, }, nil }
go
{ "resource": "" }
q12465
UUID
train
func (p *Predicate) UUID() uuid.UUID { var buffer bytes.Buffer buffer.WriteString(string(p.id)) if p.anchor == nil { buffer.WriteString("immutable") } else { b := make([]byte, 16) binary.PutVarint(b, p.anchor.UnixNano()) buffer.Write(b) } return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
go
{ "resource": "" }
q12466
PartialUUID
train
func (p *Predicate) PartialUUID() uuid.UUID { var buffer bytes.Buffer buffer.WriteString(string(p.id)) return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
go
{ "resource": "" }
q12467
UsageString
train
func (c *Command) UsageString() string { return fmt.Sprintf("usage:\n\n\t$ badwolf %s\n\n%s\n", c.UsageLine, strings.TrimSpace(c.Long)) }
go
{ "resource": "" }
q12468
New
train
func New(branch int) (generator.Generator, error) { if branch < 1 { return nil, fmt.Errorf("invalid branch factor %d", branch) } nt, err := node.NewType("/tn") if err != nil { return nil, err } p, err := predicate.NewImmutable("parent_of") if err != nil { return nil, err } return &treeGenerator{ branch...
go
{ "resource": "" }
q12469
newTriple
train
func (t *treeGenerator) newTriple(parent, descendant *node.Node) (*triple.Triple, error) { return triple.New(parent, t.predicate, triple.NewNodeObject(descendant)) }
go
{ "resource": "" }
q12470
recurse
train
func (t *treeGenerator) recurse(parent *node.Node, left *int, currentDepth, maxDepth int, trpls []*triple.Triple) ([]*triple.Triple, error) { if *left < 1 { return trpls, nil } for i, last := 0, *left <= t.branch; i < t.branch; i++ { offspring, err := t.newNode(i, parent.ID().String()) if err != nil { retur...
go
{ "resource": "" }
q12471
Generate
train
func (t *treeGenerator) Generate(n int) ([]*triple.Triple, error) { var trpls []*triple.Triple if n <= 0 { return trpls, nil } root, err := t.newNode(0, "") if err != nil { return nil, err } depth := int(math.Log(float64(n)) / math.Log(float64(t.branch))) ntrpls, err := t.recurse(root, &n, 0, depth, trpls) ...
go
{ "resource": "" }
q12472
String
train
func (o *Object) String() string { if o.n != nil { return o.n.String() } if o.l != nil { return o.l.String() } if o.p != nil { return o.p.String() } return "@@@INVALID_OBJECT@@@" }
go
{ "resource": "" }
q12473
UUID
train
func (o *Object) UUID() uuid.UUID { switch { case o.l != nil: return o.l.UUID() case o.p != nil: return o.p.UUID() default: return o.n.UUID() } }
go
{ "resource": "" }
q12474
Node
train
func (o *Object) Node() (*node.Node, error) { if o.n == nil { return nil, fmt.Errorf("triple.Literal does not box a node in %s", o) } return o.n, nil }
go
{ "resource": "" }
q12475
Predicate
train
func (o *Object) Predicate() (*predicate.Predicate, error) { if o.p == nil { return nil, fmt.Errorf("triple.Literal does not box a predicate in %s", o) } return o.p, nil }
go
{ "resource": "" }
q12476
Literal
train
func (o *Object) Literal() (*literal.Literal, error) { if o.l == nil { return nil, fmt.Errorf("triple.Literal does not box a literal in %s", o) } return o.l, nil }
go
{ "resource": "" }
q12477
ParseObject
train
func ParseObject(s string, b literal.Builder) (*Object, error) { n, err := node.Parse(s) if err == nil { return NewNodeObject(n), nil } l, err := b.Parse(s) if err == nil { return NewLiteralObject(l), nil } o, err := predicate.Parse(s) if err == nil { return NewPredicateObject(o), nil } return nil, err ...
go
{ "resource": "" }
q12478
New
train
func New(s *node.Node, p *predicate.Predicate, o *Object) (*Triple, error) { if s == nil || p == nil || o == nil { return nil, fmt.Errorf("triple.New cannot create triples from nil components in <%v %v %v>", s, p, o) } return &Triple{ s: s, p: p, o: o, }, nil }
go
{ "resource": "" }
q12479
Equal
train
func (t *Triple) Equal(t2 *Triple) bool { return uuid.Equal(t.UUID(), t2.UUID()) }
go
{ "resource": "" }
q12480
String
train
func (t *Triple) String() string { return fmt.Sprintf("%s\t%s\t%s", t.s, t.p, t.o) }
go
{ "resource": "" }
q12481
Parse
train
func Parse(line string, b literal.Builder) (*Triple, error) { raw := strings.TrimSpace(line) idxp := pSplit.FindIndex([]byte(raw)) idxo := oSplit.FindIndex([]byte(raw)) if len(idxp) == 0 || len(idxo) == 0 { return nil, fmt.Errorf("triple.Parse could not split s p o out of %s", raw) } ss, sp, so := raw[0:idxp[0...
go
{ "resource": "" }
q12482
Reify
train
func (t *Triple) Reify() ([]*Triple, *node.Node, error) { // Function that creates the proper reification predicates. rp := func(id string, p *predicate.Predicate) (*predicate.Predicate, error) { if p.Type() == predicate.Temporal { ta, _ := p.TimeAnchor() return predicate.NewTemporal(id, *ta) } return pre...
go
{ "resource": "" }
q12483
UUID
train
func (t *Triple) UUID() uuid.UUID { var buffer bytes.Buffer buffer.Write([]byte(t.s.UUID())) buffer.Write([]byte(t.p.UUID())) buffer.Write([]byte(t.o.UUID())) return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
go
{ "resource": "" }
q12484
TypeBindingClauseHook
train
func TypeBindingClauseHook(t StatementType) ClauseHook { var f ClauseHook f = func(s *Statement, _ Symbol) (ClauseHook, error) { s.BindType(t) return f, nil } return f }
go
{ "resource": "" }
q12485
dataAccumulator
train
func dataAccumulator(b literal.Builder) ElementHook { var ( hook ElementHook s *node.Node p *predicate.Predicate o *triple.Object ) hook = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return hook, nil } tkn := ce.Token() if tkn.Type != lexer.ItemNode ...
go
{ "resource": "" }
q12486
graphAccumulator
train
func graphAccumulator() ElementHook { var hook ElementHook hook = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return hook, nil } tkn := ce.Token() switch tkn.Type { case lexer.ItemComma: return hook, nil case lexer.ItemBinding: st.AddGraph(strings.TrimSpace(t...
go
{ "resource": "" }
q12487
whereNextWorkingClause
train
func whereNextWorkingClause() ClauseHook { var f ClauseHook f = func(s *Statement, _ Symbol) (ClauseHook, error) { s.AddWorkingGraphClause() return f, nil } return f }
go
{ "resource": "" }
q12488
whereInitWorkingClause
train
func whereInitWorkingClause() ClauseHook { var f ClauseHook f = func(s *Statement, _ Symbol) (ClauseHook, error) { s.ResetWorkingGraphClause() return f, nil } return f }
go
{ "resource": "" }
q12489
whereSubjectClause
train
func whereSubjectClause() ElementHook { var ( f ElementHook lastNopToken *lexer.Token ) f = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return f, nil } tkn := ce.Token() c := st.WorkingClause() switch tkn.Type { case lexer.ItemNode: if c.S != nil...
go
{ "resource": "" }
q12490
processPredicate
train
func processPredicate(ce ConsumedElement) (*predicate.Predicate, string, string, bool, error) { var ( nP *predicate.Predicate pID string pAnchorBinding string temporal bool ) raw := ce.Token().Text p, err := predicate.Parse(raw) if err == nil { // A fully specified predicate ...
go
{ "resource": "" }
q12491
processPredicateBound
train
func processPredicateBound(ce ConsumedElement) (string, string, string, *time.Time, *time.Time, bool, error) { var ( pID string pLowerBoundAlias string pUpperBoundAlias string pLowerBound *time.Time pUpperBound *time.Time ) raw := ce.Token().Text cmps := boundRegexp.FindAllStringSub...
go
{ "resource": "" }
q12492
wherePredicateClause
train
func wherePredicateClause() ElementHook { var ( f ElementHook lastNopToken *lexer.Token ) f = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return f, nil } tkn := ce.Token() c := st.WorkingClause() switch tkn.Type { case lexer.ItemPredicate: lastNo...
go
{ "resource": "" }
q12493
varAccumulator
train
func varAccumulator() ElementHook { var ( lastNopToken *lexer.Token f func(st *Statement, ce ConsumedElement) (ElementHook, error) ) f = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return f, nil } tkn := ce.Token() p := st.WorkingProjection() switch t...
go
{ "resource": "" }
q12494
bindingsGraphChecker
train
func bindingsGraphChecker() ClauseHook { var f ClauseHook f = func(s *Statement, _ Symbol) (ClauseHook, error) { // Force working projection flush. s.AddWorkingProjection() bs := s.BindingsMap() for _, b := range s.InputBindings() { if _, ok := bs[b]; !ok { return nil, fmt.Errorf("specified binding %s ...
go
{ "resource": "" }
q12495
groupByBindings
train
func groupByBindings() ElementHook { var f func(st *Statement, ce ConsumedElement) (ElementHook, error) f = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return f, nil } tkn := ce.Token() if tkn.Type == lexer.ItemBinding { st.groupBy = append(st.groupBy, tkn.Text) }...
go
{ "resource": "" }
q12496
groupByBindingsChecker
train
func groupByBindingsChecker() ClauseHook { var f ClauseHook f = func(s *Statement, _ Symbol) (ClauseHook, error) { // Force working projection flush. var idxs map[int]bool idxs = make(map[int]bool) for _, gb := range s.groupBy { found := false for idx, prj := range s.projection { if gb == prj.Alias ...
go
{ "resource": "" }
q12497
orderByBindings
train
func orderByBindings() ElementHook { var f func(st *Statement, ce ConsumedElement) (ElementHook, error) f = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return f, nil } tkn := ce.Token() switch tkn.Type { case lexer.ItemBinding: st.orderBy = append(st.orderBy, tabl...
go
{ "resource": "" }
q12498
orderByBindingsChecker
train
func orderByBindingsChecker() ClauseHook { var f ClauseHook f = func(s *Statement, _ Symbol) (ClauseHook, error) { // Force working projection flush. outs := make(map[string]bool) for _, out := range s.OutputBindings() { outs[out] = true } seen, dups := make(map[string]bool), false for _, cfg := range ...
go
{ "resource": "" }
q12499
havingExpression
train
func havingExpression() ElementHook { var f func(st *Statement, ce ConsumedElement) (ElementHook, error) f = func(st *Statement, ce ConsumedElement) (ElementHook, error) { if ce.IsSymbol() { return f, nil } if ce.token.Type != lexer.ItemHaving { st.havingExpression = append(st.havingExpression, ce) } ...
go
{ "resource": "" }