id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c12400
if err != nil { return nil, err } return &randomGraph{ nodes: n, nodeType: nt, predicate: p, }, nil }
c12401
nil { return nil, err } return triple.New(s, r.predicate, triple.NewNodeObject(o)) }
c12402
rand.Perm(maxEdges)[:n] { i, j := idx/r.nodes, idx%r.nodes t, err := r.newTriple(i, j) if err != nil { return nil, err } trpls = append(trpls, t) } return trpls, nil }
c12403
not allow duplicated bindings in %s", bs) } return &Table{ AvailableBindings: bs, mbs: m, }, nil }
c12404
return c.L.String() } if c.T != nil { return c.T.Format(time.RFC3339Nano) } return "<NULL>" }
c12405
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(sep) } } return nil }
c12406
t.Data = append(t.Data, r) } t.mu.Unlock() }
c12407
t.mu.RUnlock() return len(t.Data) }
c12408
{ return nil, false } return t.Data[i], true }
c12409
t.mu.RUnlock() return t.Data }
c12410
if !t.mbs[b] { t.mbs[b] = true t.AvailableBindings = append(t.AvailableBindings, b) } } }
c12411
t.unsafeAddBindings(bs) t.mu.Unlock() }
c12412
bindinds are %v", b, t.AvailableBindings) } } t.AvailableBindings = []string{} t.mbs = make(map[string]bool) t.unsafeAddBindings(bs) return nil }
c12413
defer t.mu.RUnlock() return t.mbs[b] }
c12414
t.mu.RUnlock() return t.AvailableBindings }
c12415
return false } for k := range b1 { if !b2[k] { return false } } return true }
c12416
} if len(t.AvailableBindings) == 0 { t.AvailableBindings, t.mbs = t2.AvailableBindings, t2.mbs } t.Data = append(t.Data, t2.Data...) return nil }
c12417
if b2[k] { return false } } return true }
c12418
k != "" { res[k] = v } } } return res }
c12419
{ t.AvailableBindings = append(t.AvailableBindings, k) } // Update the data. td := t.Data cnt, size := 0, len(td)*len(t2.Data) t.Data = make([]Row, size, size) // Preallocate resulting table. for _, r1 := range td { for _, r2 := range t2.Data { t.Data[cnt] = MergeRows([]Row{r1, r2}) cnt++ } } retur...
c12420
t.mu.Unlock() t.Data = nil }
c12421
i) // Preallocate resulting table. copy(td, t.Data[:i]) t.Data = td } }
c12422
{ c.rows[i], c.rows[j] = c.rows[j], c.rows[i] }
c12423
c.rows[j], c.cfg return rowLess(ri, rj, cfg) }
c12424
} sort.Sort(bySortConfig{t.Data, cfg}) }
c12425
t.unsafeSort(cfg) t.mu.Unlock() }
c12426
} } else { a, ok := alias[b] if !ok { return nil, fmt.Errorf("aggregated bindings require and alias; binding %s missing alias", b) } // Accumulators currently only can return numeric literals. switch acc.(type) { case int64: l, err := literal.DefaultBuilder().Build(literal.Int64, acc) i...
c12427
app.Acc == nil { newRow[app.OutAlias] = v } else { // Accumulators currently only can return numeric literals. switch vaccs[app.InAlias][app.OutAlias].(type) { case int64: l, err := literal.DefaultBuilder().Build(literal.Int64, vaccs[app.InAlias][app.OutAlias]) if err != nil { return...
c12428
{ m = make(map[string]AliasAccPair) resMap[aap.InAlias] = m } m[aap.OutAlias] = aap } return resMap }
c12429
sorts the table and then reduces // contiguous groups row groups. if len(t.Data) == 0 { return nil } t.unsafeSort(cfg) last, lastIdx, current, newData := "", 0, "", []Row{} id := func(r Row) string { res := bytes.NewBufferString("") for _, c := range cfg { res.WriteString(r[c.Binding].String()) res.W...
c12430
[]Row for _, r := range t.Data { if !f(r) { newData = append(newData, r) } } t.Data = newData }
c12431
:= res.Write(row.Bytes()); err != nil { return nil, err } if _, err := res.WriteString("\n"); err != nil { return nil, err } row.Reset() } return res, nil }
c12432
fmt.Sprintf("Failed to serialize to text! Error: %s", err) } return b.String() }
c12433
return } c <- &event{w, time.Now(), msgs} }
c12434
b.WriteString(l.UpperAnchor.Format(time.RFC3339Nano)) } else { b.WriteString("nil") } b.WriteString(fmt.Sprintf(", LatestAnchor=%v", l.LatestAnchor)) b.WriteString(">") return b.String() }
c12435
buffer.WriteString(l.String()) return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
c12436
idxSO: make(map[string]map[string]*triple.Triple, initialAllocation), } s.rwmu.Lock() defer s.rwmu.Unlock() if _, ok := s.graphs[id]; ok { return nil, fmt.Errorf("memory.NewGraph(%q): graph already exists", id) } s.graphs[id] = g return g, nil }
c12437
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) }
c12438
m.idxSP[key] = make(map[string]*triple.Triple) } m.idxSP[key][tuuid] = t key = pUUID + oUUID if _, ok := m.idxPO[key]; !ok { m.idxPO[key] = make(map[string]*triple.Triple) } m.idxPO[key][tuuid] = t key = sUUID + oUUID if _, ok := m.idxSO[key]; !ok { m.idxSO[key] = make(map[string]*triple.Tripl...
c12439
delete(m.idxSP, key) } key = pUUID + oUUID delete(m.idxPO[key], suuid) if len(m.idxPO[key]) == 0 { delete(m.idxPO, key) } key = sUUID + oUUID delete(m.idxSO[key], suuid) if len(m.idxSO[key]) == 0 { delete(m.idxSO, key) } m.rwmu.Unlock() } return nil }
c12440
} } return &checker{ max: o.MaxElements > 0, c: o.MaxElements, o: o, op: op, ota: ta, } }
c12441
false } if c.o.LowerAnchor != nil && t.Before(*c.o.LowerAnchor) { return false } if c.o.UpperAnchor != nil && t.After(*c.o.UpperAnchor) { return false } } c.c-- return true }
c12442
nil || ta.Sub(*lta) > 0 { trps[ppUUID] = t lastTA[ppUUID] = ta } } } for _, trp := range trps { if trp != nil { objs <- trp.Object() } } return nil } ckr := newChecker(lo, p) for _, t := range m.idxSP[spIdx] { if ckr.CheckAndUpdate(t.Predicate()) { objs <- t.Object() } } ...
c12443
error) { return a.V, nil }
c12444
return "and" case OR: return "or" default: return "@UNKNOWN@" } }
c12445
rB: rB, }, nil default: return nil, errors.New("evaluation expressions require the operation to be one for the follwing '=', '<', '>'") } }
c12446
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'") } }
c12447
false, }, nil default: return nil, errors.New("unary boolean expressions require the operation to be one for the follwing 'not'") } }
c12448
} 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) } return e, nil }
c12449
case Text: return "text" case Blob: return "blob" default: return "UNKNOWN" } }
c12450
fmt.Sprintf("\"%032f\"^^type:%v", l.Interface(), l.Type()) default: s = l.String() } return s }
c12451
%v; cannot be converted to a bool", l.t) } return l.v.(bool), nil }
c12452
literal is of type %v; cannot be converted to a int64", l.t) } return l.v.(int64), nil }
c12453
literal is of type %v; cannot be converted to a float64", l.t) } return l.v.(float64), nil }
c12454
literal is of type %v; cannot be converted to a string", l.t) } return l.v.(string), nil }
c12455
{ return nil, fmt.Errorf("literal.Build: type %v does not match type of value %v", t, v) } case []byte: if t != Blob { return nil, fmt.Errorf("literal.Build: type %v does not match type of value %v", t, v) } default: return nil, fmt.Errorf("literal.Build: type %T is not supported when building literals...
c12456
nil { return nil, fmt.Errorf("literal.Parse: could not convert value %q to float64", v) } return b.Build(Float64, float64(pv)) case "text": return b.Build(Text, v) case "blob": values := v[1 : len(v)-1] if values == "" { return b.Build(Blob, []byte{}) } bs := []byte{} for _, s := range strings....
c12457
literal due to size of %v (%d>%d)", v, l, b.max) } case []byte: if l := len(v.([]byte)); l > b.max { return nil, fmt.Errorf("literal.Build: cannot create literal due to size of %v (%d>%d)", v, l, b.max) } } return defaultBuilder.Build(t, v) }
c12458
{ return nil, fmt.Errorf("literal.Parse: cannot create literal due to size of %v (%d>%d)", t, len(text), b.max) } case Blob: if blob, err := l.Blob(); err != nil || len(blob) > b.max { return nil, fmt.Errorf("literal.Parse: cannot create literal due to size of %v (%d>%d)", t, len(blob), b.max) } } retur...
c12459
b := make([]byte, 8) binary.LittleEndian.PutUint64(b, bs) buffer.Write(b) case string: buffer.Write([]byte(v)) case []byte: buffer.Write(v) } return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
c12460
return fmt.Sprintf("%q@[%s]", p.id, p.anchor.Format(time.RFC3339Nano)) }
c12461
} id, ta := raw[0:idx+1], raw[idx+3:len(raw)-1] id, err := strconv.Unquote(id) if err != nil { return nil, fmt.Errorf("predicate.Parse can't unquote id in %s: %v", raw, err) } // TODO: if id has \" inside, it should be unquoted. if ta == "" { return &Predicate{ id: ID(id), }, nil } if ta[0] == '"' { ...
c12462
anchor for immutable predicate %v", p) } return p.anchor, nil }
c12463
predicate with empty ID", id) } return &Predicate{ id: ID(id), }, nil }
c12464
%v) cannot create a temporal predicate with empty ID", id, t) } return &Predicate{ id: ID(id), anchor: &t, }, nil }
c12465
buffer.WriteString("immutable") } else { b := make([]byte, 16) binary.PutVarint(b, p.anchor.UnixNano()) buffer.Write(b) } return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
c12466
buffer.WriteString(string(p.id)) return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
c12467
c.UsageLine, strings.TrimSpace(c.Long)) }
c12468
if err != nil { return nil, err } return &treeGenerator{ branch: branch, nodeType: nt, predicate: p, }, nil }
c12469
triple.New(parent, t.predicate, triple.NewNodeObject(descendant)) }
c12470
{ return trpls, err } trpl, err := t.newTriple(parent, offspring) if err != nil { return trpls, err } trpls = append(trpls, trpl) (*left)-- if *left < 1 { break } if currentDepth < maxDepth && !last { ntrpls, err := t.recurse(offspring, left, currentDepth+1, maxDepth, trpls) if err != ...
c12471
/ math.Log(float64(t.branch))) ntrpls, err := t.recurse(root, &n, 0, depth, trpls) if err != nil { return nil, err } return ntrpls, nil }
c12472
o.l != nil { return o.l.String() } if o.p != nil { return o.p.String() } return "@@@INVALID_OBJECT@@@" }
c12473
return o.p.UUID() default: return o.n.UUID() } }
c12474
fmt.Errorf("triple.Literal does not box a node in %s", o) } return o.n, nil }
c12475
nil { return nil, fmt.Errorf("triple.Literal does not box a predicate in %s", o) } return o.p, nil }
c12476
{ return nil, fmt.Errorf("triple.Literal does not box a literal in %s", o) } return o.l, nil }
c12477
nil } o, err := predicate.Parse(s) if err == nil { return NewPredicateObject(o), nil } return nil, err }
c12478
triples from nil components in <%v %v %v>", s, p, o) } return &Triple{ s: s, p: p, o: o, }, nil }
c12479
uuid.Equal(t.UUID(), t2.UUID()) }
c12480
fmt.Sprintf("%s\t%s\t%s", t.s, t.p, t.o) }
c12481
if err != nil { return nil, fmt.Errorf("triple.Parse failed to parse predicate %s with error %v", sp, err) } o, err := ParseObject(so, b) if err != nil { return nil, fmt.Errorf("triple.Parse failed to parse object %s with error %v", so, err) } return New(s, p, o) }
c12482
to, _ = New(b, o, NewLiteralObject(t.o.l)) } if t.o.n != nil { o, err := rp("_object", t.p) if err != nil { return nil, nil, err } to, _ = New(b, o, NewNodeObject(t.o.n)) } if t.o.p != nil { o, err := rp("_object", t.p) if err != nil { return nil, nil, err } to, _ = New(b, o, NewPredicateObje...
c12483
buffer.Write([]byte(t.p.UUID())) buffer.Write([]byte(t.o.UUID())) return uuid.NewSHA1(uuid.NIL, buffer.Bytes()) }
c12484
f = func(s *Statement, _ Symbol) (ClauseHook, error) { s.BindType(t) return f, nil } return f }
c12485
predicate to create a predicate, got %v instead", tkn) } tmp, err := predicate.Parse(tkn.Text) if err != nil { return nil, err } p = tmp return hook, nil } if o == nil { tmp, err := triple.ParseObject(tkn.Text, b) if err != nil { return nil, err } o = tmp trpl, err := tripl...
c12486
st.AddGraph(strings.TrimSpace(tkn.Text)) return hook, nil default: return nil, fmt.Errorf("hook.GraphAccumulator requires a binding to refer to a graph, got %v instead", tkn) } } return hook }
c12487
*Statement, _ Symbol) (ClauseHook, error) { s.AddWorkingGraphClause() return f, nil } return f }
c12488
*Statement, _ Symbol) (ClauseHook, error) { s.ResetWorkingGraphClause() return f, nil } return f }
c12489
set to %q", tkn.Text, c.SBinding) } c.SBinding = tkn.Text lastNopToken = nil return f, nil } if lastNopToken.Type == lexer.ItemAs { if c.SAlias != "" { return nil, fmt.Errorf("AS alias binding for subject has already being assigned on %v", st) } c.SAlias = tkn.Text lastNopTok...
c12490
&& len(cmps[0]) != 3) { return nil, "", "", false, fmt.Errorf("failed to extract partially defined predicate %q, got %v instead", raw, cmps) } id, ta := cmps[0][1], cmps[0][2] pID = id if ta != "" { pAnchorBinding = ta temporal = true } return nil, pID, pAnchorBinding, temporal, nil }
c12491
"?") != -1 { pUpperBoundAlias = tu } else { stu := strings.TrimSpace(tu) if stu != "" { ptu, err := time.Parse(time.RFC3339Nano, stu) if err != nil { return "", "", "", nil, nil, false, fmt.Errorf("predicate.Parse failed to parse time anchor %s in %s with error %v", tu, raw, err) } pUpperBound =...
c12492
return nil, fmt.Errorf("AS alias binding for predicate has already being assigned on %v", st) } c.PAlias = tkn.Text case lexer.ItemID: if c.PIDAlias != "" { return nil, fmt.Errorf("ID alias binding for predicate has already being assigned on %v", st) } c.PIDAlias = tkn.Text case lexer.I...
c12493
p.Binding = tkn.Text } else { if lastNopToken != nil && lastNopToken.Type == lexer.ItemAs { p.Alias = tkn.Text lastNopToken = nil st.AddWorkingProjection() } else { return nil, fmt.Errorf("invalid token %s for variable projection %s", tkn.Type, p) } } case lexer.ItemAs: lastN...
c12494
_, ok := bs[b]; !ok { return nil, fmt.Errorf("specified binding %s not found in where clause, only %v bindings are available", b, s.Bindings()) } } return f, nil } return f }
c12495
tkn := ce.Token() if tkn.Type == lexer.ItemBinding { st.groupBy = append(st.groupBy, tkn.Text) } return f, nil } return f }
c12496
s.projection { if idxs[idx] { continue } if len(s.groupBy) > 0 && prj.OP == lexer.ItemError { return nil, fmt.Errorf("Binding %q not listed on GROUP BY requires an aggregation function", prj.Binding) } if len(s.groupBy) == 0 && prj.OP != lexer.ItemError { s := prj.Alias if s == "" { ...
c12497
st.orderBy = append(st.orderBy, table.SortConfig{{Binding: tkn.Text}}...) case lexer.ItemAsc: st.orderBy[len(st.orderBy)-1].Desc = false case lexer.ItemDesc: st.orderBy[len(st.orderBy)-1].Desc = true } return f, nil } return f }
c12498
by binding %q unknown; available bindings are %v", cfg.Binding, s.OutputBindings()) } } // If dups exist rewrite the order by SortConfig. if dups { s.orderBy = table.SortConfig{} for b, d := range seen { s.orderBy = append(s.orderBy, table.SortConfig{{Binding: b, Desc: d}}...) } } return f, n...
c12499
if ce.token.Type != lexer.ItemHaving { st.havingExpression = append(st.havingExpression, ce) } return f, nil } return f }