id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
12,500 | google/badwolf | bql/semantic/hooks.go | havingExpressionBuilder | func havingExpressionBuilder() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.havingExpressionEvaluator = &AlwaysReturn{V: true}
if len(s.havingExpression) > 0 {
eval, err := NewEvaluator(s.havingExpression)
if err != nil {
return nil, err
}
s.havingExpressi... | go | func havingExpressionBuilder() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.havingExpressionEvaluator = &AlwaysReturn{V: true}
if len(s.havingExpression) > 0 {
eval, err := NewEvaluator(s.havingExpression)
if err != nil {
return nil, err
}
s.havingExpressi... | [
"func",
"havingExpressionBuilder",
"(",
")",
"ClauseHook",
"{",
"var",
"f",
"ClauseHook",
"\n",
"f",
"=",
"func",
"(",
"s",
"*",
"Statement",
",",
"_",
"Symbol",
")",
"(",
"ClauseHook",
",",
"error",
")",
"{",
"s",
".",
"havingExpressionEvaluator",
"=",
... | // havingExpressionBuilder given the collected tokens that forms the having
// clause expression, it builds the expression to use when filtering values
// on the final result table. | [
"havingExpressionBuilder",
"given",
"the",
"collected",
"tokens",
"that",
"forms",
"the",
"having",
"clause",
"expression",
"it",
"builds",
"the",
"expression",
"to",
"use",
"when",
"filtering",
"values",
"on",
"the",
"final",
"result",
"table",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L853-L867 |
12,501 | google/badwolf | bql/semantic/hooks.go | limitCollection | func limitCollection() ElementHook {
var f func(st *Statement, ce ConsumedElement) (ElementHook, error)
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() || ce.token.Type == lexer.ItemLimit {
return f, nil
}
if ce.token.Type != lexer.ItemLiteral {
return nil, fmt.Errorf("... | go | func limitCollection() ElementHook {
var f func(st *Statement, ce ConsumedElement) (ElementHook, error)
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() || ce.token.Type == lexer.ItemLimit {
return f, nil
}
if ce.token.Type != lexer.ItemLiteral {
return nil, fmt.Errorf("... | [
"func",
"limitCollection",
"(",
")",
"ElementHook",
"{",
"var",
"f",
"func",
"(",
"st",
"*",
"Statement",
",",
"ce",
"ConsumedElement",
")",
"(",
"ElementHook",
",",
"error",
")",
"\n",
"f",
"=",
"func",
"(",
"st",
"*",
"Statement",
",",
"ce",
"Consume... | // limitCollection collects the limit of rows to return as indicated by the
// LIMIT clause. | [
"limitCollection",
"collects",
"the",
"limit",
"of",
"rows",
"to",
"return",
"as",
"indicated",
"by",
"the",
"LIMIT",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L871-L895 |
12,502 | google/badwolf | bql/semantic/hooks.go | collectGlobalBounds | func collectGlobalBounds() ElementHook {
var (
f func(st *Statement, ce ConsumedElement) (ElementHook, error)
opToken *lexer.Token
lastToken *lexer.Token
)
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.token
switch tkn.Type ... | go | func collectGlobalBounds() ElementHook {
var (
f func(st *Statement, ce ConsumedElement) (ElementHook, error)
opToken *lexer.Token
lastToken *lexer.Token
)
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.token
switch tkn.Type ... | [
"func",
"collectGlobalBounds",
"(",
")",
"ElementHook",
"{",
"var",
"(",
"f",
"func",
"(",
"st",
"*",
"Statement",
",",
"ce",
"ConsumedElement",
")",
"(",
"ElementHook",
",",
"error",
")",
"\n",
"opToken",
"*",
"lexer",
".",
"Token",
"\n",
"lastToken",
"... | // collectGlobalBounds collects the global time bounds that should be applied
// to all temporal predicates. | [
"collectGlobalBounds",
"collects",
"the",
"global",
"time",
"bounds",
"that",
"should",
"be",
"applied",
"to",
"all",
"temporal",
"predicates",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L899-L951 |
12,503 | google/badwolf | bql/semantic/hooks.go | InitWorkingConstructClause | func InitWorkingConstructClause() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.ResetWorkingConstructClause()
return f, nil
}
return f
} | go | func InitWorkingConstructClause() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.ResetWorkingConstructClause()
return f, nil
}
return f
} | [
"func",
"InitWorkingConstructClause",
"(",
")",
"ClauseHook",
"{",
"var",
"f",
"ClauseHook",
"\n",
"f",
"=",
"func",
"(",
"s",
"*",
"Statement",
",",
"_",
"Symbol",
")",
"(",
"ClauseHook",
",",
"error",
")",
"{",
"s",
".",
"ResetWorkingConstructClause",
"(... | // InitWorkingConstructClause returns a clause hook to initialize a new working
// construct clause. | [
"InitWorkingConstructClause",
"returns",
"a",
"clause",
"hook",
"to",
"initialize",
"a",
"new",
"working",
"construct",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L955-L962 |
12,504 | google/badwolf | bql/semantic/hooks.go | NextWorkingConstructClause | func NextWorkingConstructClause() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.AddWorkingConstructClause()
return f, nil
}
return f
} | go | func NextWorkingConstructClause() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.AddWorkingConstructClause()
return f, nil
}
return f
} | [
"func",
"NextWorkingConstructClause",
"(",
")",
"ClauseHook",
"{",
"var",
"f",
"ClauseHook",
"\n",
"f",
"=",
"func",
"(",
"s",
"*",
"Statement",
",",
"_",
"Symbol",
")",
"(",
"ClauseHook",
",",
"error",
")",
"{",
"s",
".",
"AddWorkingConstructClause",
"(",... | // NextWorkingConstructClause returns a clause hook to close the current working
// construct clause and start a new working construct clause. | [
"NextWorkingConstructClause",
"returns",
"a",
"clause",
"hook",
"to",
"close",
"the",
"current",
"working",
"construct",
"clause",
"and",
"start",
"a",
"new",
"working",
"construct",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L966-L973 |
12,505 | google/badwolf | bql/semantic/hooks.go | constructSubject | func constructSubject() ElementHook {
var f ElementHook
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.Token()
c := st.WorkingConstructClause()
if c.S != nil {
return nil, fmt.Errorf("invalid subject %v in construct clause, subject alrea... | go | func constructSubject() ElementHook {
var f ElementHook
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.Token()
c := st.WorkingConstructClause()
if c.S != nil {
return nil, fmt.Errorf("invalid subject %v in construct clause, subject alrea... | [
"func",
"constructSubject",
"(",
")",
"ElementHook",
"{",
"var",
"f",
"ElementHook",
"\n",
"f",
"=",
"func",
"(",
"st",
"*",
"Statement",
",",
"ce",
"ConsumedElement",
")",
"(",
"ElementHook",
",",
"error",
")",
"{",
"if",
"ce",
".",
"IsSymbol",
"(",
"... | // constructSubject returns an element hook that updates the subject
// modifiers on the working construct clause. | [
"constructSubject",
"returns",
"an",
"element",
"hook",
"that",
"updates",
"the",
"subject",
"modifiers",
"on",
"the",
"working",
"construct",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L977-L1004 |
12,506 | google/badwolf | bql/semantic/hooks.go | constructPredicate | func constructPredicate() ElementHook {
var f ElementHook
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.Token()
p := st.WorkingConstructClause().WorkingPredicateObjectPair()
if p.P != nil {
return nil, fmt.Errorf("invalid predicate %v i... | go | func constructPredicate() ElementHook {
var f ElementHook
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.Token()
p := st.WorkingConstructClause().WorkingPredicateObjectPair()
if p.P != nil {
return nil, fmt.Errorf("invalid predicate %v i... | [
"func",
"constructPredicate",
"(",
")",
"ElementHook",
"{",
"var",
"f",
"ElementHook",
"\n",
"f",
"=",
"func",
"(",
"st",
"*",
"Statement",
",",
"ce",
"ConsumedElement",
")",
"(",
"ElementHook",
",",
"error",
")",
"{",
"if",
"ce",
".",
"IsSymbol",
"(",
... | // constructPredicate returns an element hook that updates the predicate
// modifiers on the current predicate-object pair of the working graph clause. | [
"constructPredicate",
"returns",
"an",
"element",
"hook",
"that",
"updates",
"the",
"predicate",
"modifiers",
"on",
"the",
"current",
"predicate",
"-",
"object",
"pair",
"of",
"the",
"working",
"graph",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L1008-L1038 |
12,507 | google/badwolf | bql/semantic/hooks.go | constructObject | func constructObject() ElementHook {
var f ElementHook
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.Token()
p := st.WorkingConstructClause().WorkingPredicateObjectPair()
if p.O != nil {
return nil, fmt.Errorf("invalid object %v in cons... | go | func constructObject() ElementHook {
var f ElementHook
f = func(st *Statement, ce ConsumedElement) (ElementHook, error) {
if ce.IsSymbol() {
return f, nil
}
tkn := ce.Token()
p := st.WorkingConstructClause().WorkingPredicateObjectPair()
if p.O != nil {
return nil, fmt.Errorf("invalid object %v in cons... | [
"func",
"constructObject",
"(",
")",
"ElementHook",
"{",
"var",
"f",
"ElementHook",
"\n",
"f",
"=",
"func",
"(",
"st",
"*",
"Statement",
",",
"ce",
"ConsumedElement",
")",
"(",
"ElementHook",
",",
"error",
")",
"{",
"if",
"ce",
".",
"IsSymbol",
"(",
")... | // constructObject returns an element hook that updates the object
// modifiers on the current predicate-object pair of the working graph clause. | [
"constructObject",
"returns",
"an",
"element",
"hook",
"that",
"updates",
"the",
"object",
"modifiers",
"on",
"the",
"current",
"predicate",
"-",
"object",
"pair",
"of",
"the",
"working",
"graph",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L1042-L1084 |
12,508 | google/badwolf | bql/semantic/hooks.go | NextWorkingConstructPredicateObjectPair | func NextWorkingConstructPredicateObjectPair() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.WorkingConstructClause().AddWorkingPredicateObjectPair()
return f, nil
}
return f
} | go | func NextWorkingConstructPredicateObjectPair() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.WorkingConstructClause().AddWorkingPredicateObjectPair()
return f, nil
}
return f
} | [
"func",
"NextWorkingConstructPredicateObjectPair",
"(",
")",
"ClauseHook",
"{",
"var",
"f",
"ClauseHook",
"\n",
"f",
"=",
"func",
"(",
"s",
"*",
"Statement",
",",
"_",
"Symbol",
")",
"(",
"ClauseHook",
",",
"error",
")",
"{",
"s",
".",
"WorkingConstructClaus... | // NextWorkingConstructPredicateObjectPair returns a clause hook to close the current
// predicate-object pair and start a new predicate-object pair within the working
// construct clause. | [
"NextWorkingConstructPredicateObjectPair",
"returns",
"a",
"clause",
"hook",
"to",
"close",
"the",
"current",
"predicate",
"-",
"object",
"pair",
"and",
"start",
"a",
"new",
"predicate",
"-",
"object",
"pair",
"within",
"the",
"working",
"construct",
"clause",
"."... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L1089-L1096 |
12,509 | google/badwolf | bql/semantic/hooks.go | ShowClauseHook | func ShowClauseHook() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.sType = Show
return f, nil
}
return f
} | go | func ShowClauseHook() ClauseHook {
var f ClauseHook
f = func(s *Statement, _ Symbol) (ClauseHook, error) {
s.sType = Show
return f, nil
}
return f
} | [
"func",
"ShowClauseHook",
"(",
")",
"ClauseHook",
"{",
"var",
"f",
"ClauseHook",
"\n",
"f",
"=",
"func",
"(",
"s",
"*",
"Statement",
",",
"_",
"Symbol",
")",
"(",
"ClauseHook",
",",
"error",
")",
"{",
"s",
".",
"sType",
"=",
"Show",
"\n",
"return",
... | // ShowClauseHook returns a clause hook for the show statement. | [
"ShowClauseHook",
"returns",
"a",
"clause",
"hook",
"for",
"the",
"show",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/hooks.go#L1099-L1106 |
12,510 | google/badwolf | tools/benchmark/batteries/generators.go | getTreeGenerators | func getTreeGenerators(bFactors []int) ([]generator.Generator, error) {
var gens []generator.Generator
for _, b := range bFactors {
t, err := tree.New(b)
if err != nil {
return nil, err
}
gens = append(gens, t)
}
return gens, nil
} | go | func getTreeGenerators(bFactors []int) ([]generator.Generator, error) {
var gens []generator.Generator
for _, b := range bFactors {
t, err := tree.New(b)
if err != nil {
return nil, err
}
gens = append(gens, t)
}
return gens, nil
} | [
"func",
"getTreeGenerators",
"(",
"bFactors",
"[",
"]",
"int",
")",
"(",
"[",
"]",
"generator",
".",
"Generator",
",",
"error",
")",
"{",
"var",
"gens",
"[",
"]",
"generator",
".",
"Generator",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"bFactors",
"... | // getTreeGenerators returns the set of tree generators to use while creating
// benchmarks. | [
"getTreeGenerators",
"returns",
"the",
"set",
"of",
"tree",
"generators",
"to",
"use",
"while",
"creating",
"benchmarks",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/batteries/generators.go#L26-L36 |
12,511 | google/badwolf | tools/benchmark/batteries/generators.go | getGraphGenerators | func getGraphGenerators(nodes []int) ([]generator.Generator, error) {
var gens []generator.Generator
for _, b := range nodes {
t, err := graph.NewRandomGraph(b)
if err != nil {
return nil, err
}
gens = append(gens, t)
}
return gens, nil
} | go | func getGraphGenerators(nodes []int) ([]generator.Generator, error) {
var gens []generator.Generator
for _, b := range nodes {
t, err := graph.NewRandomGraph(b)
if err != nil {
return nil, err
}
gens = append(gens, t)
}
return gens, nil
} | [
"func",
"getGraphGenerators",
"(",
"nodes",
"[",
"]",
"int",
")",
"(",
"[",
"]",
"generator",
".",
"Generator",
",",
"error",
")",
"{",
"var",
"gens",
"[",
"]",
"generator",
".",
"Generator",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"nodes",
"{",
... | // getGraphGenerators returns the set of tree generators to use while creating
// benchmarks. | [
"getGraphGenerators",
"returns",
"the",
"set",
"of",
"tree",
"generators",
"to",
"use",
"while",
"creating",
"benchmarks",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/batteries/generators.go#L40-L50 |
12,512 | google/badwolf | tools/vcli/bw/assert/assert.go | assertCommand | func assertCommand(ctx context.Context, cmd *command.Command, args []string, store storage.Store, builder literal.Builder, chanSize, bulkSize int) int {
if len(args) < 2 {
log.Printf("Missing required folder path. ")
cmd.Usage()
return 2
}
// Open the folder.
folder := strings.TrimSpace(args[len(args)-1])
f,... | go | func assertCommand(ctx context.Context, cmd *command.Command, args []string, store storage.Store, builder literal.Builder, chanSize, bulkSize int) int {
if len(args) < 2 {
log.Printf("Missing required folder path. ")
cmd.Usage()
return 2
}
// Open the folder.
folder := strings.TrimSpace(args[len(args)-1])
f,... | [
"func",
"assertCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"cmd",
"*",
"command",
".",
"Command",
",",
"args",
"[",
"]",
"string",
",",
"store",
"storage",
".",
"Store",
",",
"builder",
"literal",
".",
"Builder",
",",
"chanSize",
",",
"bulkSize... | // assertCommand runs all the BQL statements available in the file. | [
"assertCommand",
"runs",
"all",
"the",
"BQL",
"statements",
"available",
"in",
"the",
"file",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/assert/assert.go#L50-L120 |
12,513 | google/badwolf | tools/vcli/bw/run/run.go | runCommand | func runCommand(ctx context.Context, cmd *command.Command, args []string, store storage.Store, chanSize, bulkSize int) int {
if len(args) < 2 {
log.Printf("[ERROR] Missing required file path. ")
cmd.Usage()
return 2
}
file := strings.TrimSpace(args[len(args)-1])
lines, err := io.GetStatementsFromFile(file)
i... | go | func runCommand(ctx context.Context, cmd *command.Command, args []string, store storage.Store, chanSize, bulkSize int) int {
if len(args) < 2 {
log.Printf("[ERROR] Missing required file path. ")
cmd.Usage()
return 2
}
file := strings.TrimSpace(args[len(args)-1])
lines, err := io.GetStatementsFromFile(file)
i... | [
"func",
"runCommand",
"(",
"ctx",
"context",
".",
"Context",
",",
"cmd",
"*",
"command",
".",
"Command",
",",
"args",
"[",
"]",
"string",
",",
"store",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"int",
"{",
"if",
"len",
"(... | // runCommand runs all the BQL statements available in the file. | [
"runCommand",
"runs",
"all",
"the",
"BQL",
"statements",
"available",
"in",
"the",
"file",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/run/run.go#L51-L78 |
12,514 | google/badwolf | tools/vcli/bw/run/run.go | BQL | func BQL(ctx context.Context, bql string, s storage.Store, chanSize, bulkSize int) (*table.Table, error) {
p, err := grammar.NewParser(grammar.SemanticBQL())
if err != nil {
return nil, fmt.Errorf("[ERROR] Failed to initilize a valid BQL parser")
}
stm := &semantic.Statement{}
if err := p.Parse(grammar.NewLLk(bq... | go | func BQL(ctx context.Context, bql string, s storage.Store, chanSize, bulkSize int) (*table.Table, error) {
p, err := grammar.NewParser(grammar.SemanticBQL())
if err != nil {
return nil, fmt.Errorf("[ERROR] Failed to initilize a valid BQL parser")
}
stm := &semantic.Statement{}
if err := p.Parse(grammar.NewLLk(bq... | [
"func",
"BQL",
"(",
"ctx",
"context",
".",
"Context",
",",
"bql",
"string",
",",
"s",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"(",
"*",
"table",
".",
"Table",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"grammar",
... | // BQL attempts to execute the provided query against the given store. | [
"BQL",
"attempts",
"to",
"execute",
"the",
"provided",
"query",
"against",
"the",
"given",
"store",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/run/run.go#L81-L99 |
12,515 | google/badwolf | bql/semantic/convert.go | NewConsumedToken | func NewConsumedToken(tkn *lexer.Token) ConsumedElement {
return ConsumedElement{
isSymbol: false,
token: tkn,
}
} | go | func NewConsumedToken(tkn *lexer.Token) ConsumedElement {
return ConsumedElement{
isSymbol: false,
token: tkn,
}
} | [
"func",
"NewConsumedToken",
"(",
"tkn",
"*",
"lexer",
".",
"Token",
")",
"ConsumedElement",
"{",
"return",
"ConsumedElement",
"{",
"isSymbol",
":",
"false",
",",
"token",
":",
"tkn",
",",
"}",
"\n",
"}"
] | // NewConsumedToken create a new consumed element that boxes a token. | [
"NewConsumedToken",
"create",
"a",
"new",
"consumed",
"element",
"that",
"boxes",
"a",
"token",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/convert.go#L50-L55 |
12,516 | google/badwolf | bql/semantic/convert.go | ToNode | func ToNode(ce ConsumedElement) (*node.Node, error) {
if ce.IsSymbol() {
return nil, fmt.Errorf("semantic.ToNode cannot convert symbol %v to a node", ce)
}
tkn := ce.Token()
if tkn.Type != lexer.ItemNode && tkn.Type != lexer.ItemBlankNode {
return nil, fmt.Errorf("semantic.ToNode cannot convert token type %s to... | go | func ToNode(ce ConsumedElement) (*node.Node, error) {
if ce.IsSymbol() {
return nil, fmt.Errorf("semantic.ToNode cannot convert symbol %v to a node", ce)
}
tkn := ce.Token()
if tkn.Type != lexer.ItemNode && tkn.Type != lexer.ItemBlankNode {
return nil, fmt.Errorf("semantic.ToNode cannot convert token type %s to... | [
"func",
"ToNode",
"(",
"ce",
"ConsumedElement",
")",
"(",
"*",
"node",
".",
"Node",
",",
"error",
")",
"{",
"if",
"ce",
".",
"IsSymbol",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ce",
")",
"\n",
"}",
"\n"... | // ToNode converts the node found by the lexer and converts it into a BadWolf
// node. | [
"ToNode",
"converts",
"the",
"node",
"found",
"by",
"the",
"lexer",
"and",
"converts",
"it",
"into",
"a",
"BadWolf",
"node",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/convert.go#L74-L83 |
12,517 | google/badwolf | bql/semantic/convert.go | ToPredicate | func ToPredicate(ce ConsumedElement) (*predicate.Predicate, error) {
if ce.IsSymbol() {
return nil, fmt.Errorf("semantic.ToPredicate cannot convert symbol %v to a predicate", ce)
}
tkn := ce.Token()
if tkn.Type != lexer.ItemPredicate {
return nil, fmt.Errorf("semantic.ToPredicate cannot convert token type %s to... | go | func ToPredicate(ce ConsumedElement) (*predicate.Predicate, error) {
if ce.IsSymbol() {
return nil, fmt.Errorf("semantic.ToPredicate cannot convert symbol %v to a predicate", ce)
}
tkn := ce.Token()
if tkn.Type != lexer.ItemPredicate {
return nil, fmt.Errorf("semantic.ToPredicate cannot convert token type %s to... | [
"func",
"ToPredicate",
"(",
"ce",
"ConsumedElement",
")",
"(",
"*",
"predicate",
".",
"Predicate",
",",
"error",
")",
"{",
"if",
"ce",
".",
"IsSymbol",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ce",
")",
"\n"... | // ToPredicate converts the node found by the lexer and converts it into a
// BadWolf predicate. | [
"ToPredicate",
"converts",
"the",
"node",
"found",
"by",
"the",
"lexer",
"and",
"converts",
"it",
"into",
"a",
"BadWolf",
"predicate",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/convert.go#L87-L96 |
12,518 | google/badwolf | bql/semantic/convert.go | ToLiteral | func ToLiteral(ce ConsumedElement) (*literal.Literal, error) {
if ce.IsSymbol() {
return nil, fmt.Errorf("semantic.ToLiteral cannot convert symbol %v to a literal", ce)
}
tkn := ce.Token()
if tkn.Type != lexer.ItemLiteral {
return nil, fmt.Errorf("semantic.ToLiteral cannot convert token type %s to a literal", t... | go | func ToLiteral(ce ConsumedElement) (*literal.Literal, error) {
if ce.IsSymbol() {
return nil, fmt.Errorf("semantic.ToLiteral cannot convert symbol %v to a literal", ce)
}
tkn := ce.Token()
if tkn.Type != lexer.ItemLiteral {
return nil, fmt.Errorf("semantic.ToLiteral cannot convert token type %s to a literal", t... | [
"func",
"ToLiteral",
"(",
"ce",
"ConsumedElement",
")",
"(",
"*",
"literal",
".",
"Literal",
",",
"error",
")",
"{",
"if",
"ce",
".",
"IsSymbol",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"ce",
")",
"\n",
"}... | // ToLiteral converts the node found by the lexer and converts it into a
// BadWolf literal. | [
"ToLiteral",
"converts",
"the",
"node",
"found",
"by",
"the",
"lexer",
"and",
"converts",
"it",
"into",
"a",
"BadWolf",
"literal",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/convert.go#L100-L109 |
12,519 | google/badwolf | triple/node/node.go | Covariant | func (t *Type) Covariant(ot *Type) bool {
if !strings.HasPrefix(t.String(), ot.String()) {
return false
}
// /type/foo is covariant of /type, but /typefoo is not covariant of /type.
return len(t.String()) == len(ot.String()) || t.String()[len(ot.String())] == '/'
} | go | func (t *Type) Covariant(ot *Type) bool {
if !strings.HasPrefix(t.String(), ot.String()) {
return false
}
// /type/foo is covariant of /type, but /typefoo is not covariant of /type.
return len(t.String()) == len(ot.String()) || t.String()[len(ot.String())] == '/'
} | [
"func",
"(",
"t",
"*",
"Type",
")",
"Covariant",
"(",
"ot",
"*",
"Type",
")",
"bool",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"t",
".",
"String",
"(",
")",
",",
"ot",
".",
"String",
"(",
")",
")",
"{",
"return",
"false",
"\n",
"}",
... | // Covariant checks for given two types A and B, A covariant B if B _is a_ A.
// In other word, A _covariant_ B if B is a prefix of A. | [
"Covariant",
"checks",
"for",
"given",
"two",
"types",
"A",
"and",
"B",
"A",
"covariant",
"B",
"if",
"B",
"_is",
"a_",
"A",
".",
"In",
"other",
"word",
"A",
"_covariant_",
"B",
"if",
"B",
"is",
"a",
"prefix",
"of",
"A",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L45-L51 |
12,520 | google/badwolf | triple/node/node.go | String | func (n *Node) String() string {
return fmt.Sprintf("%s<%s>", n.t.String(), n.id.String())
} | go | func (n *Node) String() string {
return fmt.Sprintf("%s<%s>", n.t.String(), n.id.String())
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"n",
".",
"t",
".",
"String",
"(",
")",
",",
"n",
".",
"id",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // String returns a pretty printing representation of Node. | [
"String",
"returns",
"a",
"pretty",
"printing",
"representation",
"of",
"Node",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L78-L80 |
12,521 | google/badwolf | triple/node/node.go | Parse | func Parse(s string) (*Node, error) {
raw := strings.TrimSpace(s)
switch raw[0] {
case slash:
idx := strings.Index(raw, "<")
if idx < 0 {
return nil, fmt.Errorf("node.Parse: invalid format, could not find ID in %v", raw)
}
t, err := NewType(raw[:idx])
if err != nil {
return nil, fmt.Errorf("node.Pars... | go | func Parse(s string) (*Node, error) {
raw := strings.TrimSpace(s)
switch raw[0] {
case slash:
idx := strings.Index(raw, "<")
if idx < 0 {
return nil, fmt.Errorf("node.Parse: invalid format, could not find ID in %v", raw)
}
t, err := NewType(raw[:idx])
if err != nil {
return nil, fmt.Errorf("node.Pars... | [
"func",
"Parse",
"(",
"s",
"string",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"raw",
":=",
"strings",
".",
"TrimSpace",
"(",
"s",
")",
"\n",
"switch",
"raw",
"[",
"0",
"]",
"{",
"case",
"slash",
":",
"idx",
":=",
"strings",
".",
"Index",
... | // Parse returns a node given a pretty printed representation of a Node or a BlankNode. | [
"Parse",
"returns",
"a",
"node",
"given",
"a",
"pretty",
"printed",
"representation",
"of",
"a",
"Node",
"or",
"a",
"BlankNode",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L83-L113 |
12,522 | google/badwolf | triple/node/node.go | Covariant | func (n *Node) Covariant(on *Node) bool {
return n.t.Covariant(on.t)
} | go | func (n *Node) Covariant(on *Node) bool {
return n.t.Covariant(on.t)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Covariant",
"(",
"on",
"*",
"Node",
")",
"bool",
"{",
"return",
"n",
".",
"t",
".",
"Covariant",
"(",
"on",
".",
"t",
")",
"\n",
"}"
] | // Covariant checks if the types of two nodes is covariant. | [
"Covariant",
"checks",
"if",
"the",
"types",
"of",
"two",
"nodes",
"is",
"covariant",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L116-L118 |
12,523 | google/badwolf | triple/node/node.go | NewType | func NewType(t string) (*Type, error) {
if strings.ContainsAny(t, " \t\n\r") {
return nil, fmt.Errorf("node.NewType(%q) does not allow spaces", t)
}
if !strings.HasPrefix(t, "/") || strings.HasSuffix(t, "/") {
return nil, fmt.Errorf("node.NewType(%q) should start with a '/' and do not end with '/'", t)
}
if t ... | go | func NewType(t string) (*Type, error) {
if strings.ContainsAny(t, " \t\n\r") {
return nil, fmt.Errorf("node.NewType(%q) does not allow spaces", t)
}
if !strings.HasPrefix(t, "/") || strings.HasSuffix(t, "/") {
return nil, fmt.Errorf("node.NewType(%q) should start with a '/' and do not end with '/'", t)
}
if t ... | [
"func",
"NewType",
"(",
"t",
"string",
")",
"(",
"*",
"Type",
",",
"error",
")",
"{",
"if",
"strings",
".",
"ContainsAny",
"(",
"t",
",",
"\"",
"\\t",
"\\n",
"\\r",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",... | // NewType creates a new type from plain string. | [
"NewType",
"creates",
"a",
"new",
"type",
"from",
"plain",
"string",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L121-L133 |
12,524 | google/badwolf | triple/node/node.go | NewID | func NewID(id string) (*ID, error) {
if strings.ContainsAny(id, "<>") {
return nil, fmt.Errorf("node.NewID(%q) does not allow '<' or '>'", id)
}
if id == "" {
return nil, fmt.Errorf("node.NewID(%q) cannot create empty ID", id)
}
nID := ID(id)
return &nID, nil
} | go | func NewID(id string) (*ID, error) {
if strings.ContainsAny(id, "<>") {
return nil, fmt.Errorf("node.NewID(%q) does not allow '<' or '>'", id)
}
if id == "" {
return nil, fmt.Errorf("node.NewID(%q) cannot create empty ID", id)
}
nID := ID(id)
return &nID, nil
} | [
"func",
"NewID",
"(",
"id",
"string",
")",
"(",
"*",
"ID",
",",
"error",
")",
"{",
"if",
"strings",
".",
"ContainsAny",
"(",
"id",
",",
"\"",
"\"",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"id",
")",
"\n",
"... | // NewID create a new ID from a plain string. | [
"NewID",
"create",
"a",
"new",
"ID",
"from",
"a",
"plain",
"string",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L136-L145 |
12,525 | google/badwolf | triple/node/node.go | NewNode | func NewNode(t *Type, id *ID) *Node {
return &Node{
t: t,
id: id,
}
} | go | func NewNode(t *Type, id *ID) *Node {
return &Node{
t: t,
id: id,
}
} | [
"func",
"NewNode",
"(",
"t",
"*",
"Type",
",",
"id",
"*",
"ID",
")",
"*",
"Node",
"{",
"return",
"&",
"Node",
"{",
"t",
":",
"t",
",",
"id",
":",
"id",
",",
"}",
"\n",
"}"
] | // NewNode returns a new node constructed from a type and an ID. | [
"NewNode",
"returns",
"a",
"new",
"node",
"constructed",
"from",
"a",
"type",
"and",
"an",
"ID",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L148-L153 |
12,526 | google/badwolf | triple/node/node.go | NewNodeFromStrings | func NewNodeFromStrings(sT, sID string) (*Node, error) {
t, err := NewType(sT)
if err != nil {
return nil, err
}
n, err := NewID(sID)
if err != nil {
return nil, err
}
return NewNode(t, n), nil
} | go | func NewNodeFromStrings(sT, sID string) (*Node, error) {
t, err := NewType(sT)
if err != nil {
return nil, err
}
n, err := NewID(sID)
if err != nil {
return nil, err
}
return NewNode(t, n), nil
} | [
"func",
"NewNodeFromStrings",
"(",
"sT",
",",
"sID",
"string",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"t",
",",
"err",
":=",
"NewType",
"(",
"sT",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"... | // NewNodeFromStrings returns a new node constructed from a type and ID
// represented as plain strings. | [
"NewNodeFromStrings",
"returns",
"a",
"new",
"node",
"constructed",
"from",
"a",
"type",
"and",
"ID",
"represented",
"as",
"plain",
"strings",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L157-L167 |
12,527 | google/badwolf | triple/node/node.go | NewBlankNode | func NewBlankNode() *Node {
uuid := <-nextVal
id := ID(uuid.String())
return &Node{
t: &tBlank,
id: &id,
}
} | go | func NewBlankNode() *Node {
uuid := <-nextVal
id := ID(uuid.String())
return &Node{
t: &tBlank,
id: &id,
}
} | [
"func",
"NewBlankNode",
"(",
")",
"*",
"Node",
"{",
"uuid",
":=",
"<-",
"nextVal",
"\n",
"id",
":=",
"ID",
"(",
"uuid",
".",
"String",
"(",
")",
")",
"\n",
"return",
"&",
"Node",
"{",
"t",
":",
"&",
"tBlank",
",",
"id",
":",
"&",
"id",
",",
"... | // NewBlankNode creates a new blank node. The blank node ID is guaranteed to
// be unique in BadWolf. | [
"NewBlankNode",
"creates",
"a",
"new",
"blank",
"node",
".",
"The",
"blank",
"node",
"ID",
"is",
"guaranteed",
"to",
"be",
"unique",
"in",
"BadWolf",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L215-L222 |
12,528 | google/badwolf | triple/node/node.go | UUID | func (n *Node) UUID() uuid.UUID {
var buffer bytes.Buffer
buffer.WriteString(string(*n.t))
buffer.WriteString(string(*n.id))
return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
} | go | func (n *Node) UUID() uuid.UUID {
var buffer bytes.Buffer
buffer.WriteString(string(*n.t))
buffer.WriteString(string(*n.id))
return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"UUID",
"(",
")",
"uuid",
".",
"UUID",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"buffer",
".",
"WriteString",
"(",
"string",
"(",
"*",
"n",
".",
"t",
")",
")",
"\n",
"buffer",
".",
"WriteString",
"("... | // UUID returns a global unique identifier for the given node. It is
// implemented as the SHA1 UUID of the node values. | [
"UUID",
"returns",
"a",
"global",
"unique",
"identifier",
"for",
"the",
"given",
"node",
".",
"It",
"is",
"implemented",
"as",
"the",
"SHA1",
"UUID",
"of",
"the",
"node",
"values",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/triple/node/node.go#L226-L231 |
12,529 | google/badwolf | bql/semantic/semantic.go | String | func (t StatementType) String() string {
switch t {
case Query:
return "QUERY"
case Insert:
return "INSERT"
case Delete:
return "DELETE"
case Create:
return "CREATE"
case Drop:
return "DROP"
case Construct:
return "CONSTRUCT"
case Deconstruct:
return "DECONSTRUCT"
case Show:
return "SHOW"
defa... | go | func (t StatementType) String() string {
switch t {
case Query:
return "QUERY"
case Insert:
return "INSERT"
case Delete:
return "DELETE"
case Create:
return "CREATE"
case Drop:
return "DROP"
case Construct:
return "CONSTRUCT"
case Deconstruct:
return "DECONSTRUCT"
case Show:
return "SHOW"
defa... | [
"func",
"(",
"t",
"StatementType",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"t",
"{",
"case",
"Query",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Insert",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Delete",
":",
"return",
"\"",
"\"",
"\n",
"... | // String provides a readable version of the StatementType. | [
"String",
"provides",
"a",
"readable",
"version",
"of",
"the",
"StatementType",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L60-L81 |
12,530 | google/badwolf | bql/semantic/semantic.go | BindingsMap | func (c *GraphClause) BindingsMap() map[string]int {
bm := make(map[string]int)
addToBindings(bm, c.SBinding)
addToBindings(bm, c.SAlias)
addToBindings(bm, c.STypeAlias)
addToBindings(bm, c.SIDAlias)
addToBindings(bm, c.PAlias)
addToBindings(bm, c.PAnchorBinding)
addToBindings(bm, c.PBinding)
addToBindings(bm... | go | func (c *GraphClause) BindingsMap() map[string]int {
bm := make(map[string]int)
addToBindings(bm, c.SBinding)
addToBindings(bm, c.SAlias)
addToBindings(bm, c.STypeAlias)
addToBindings(bm, c.SIDAlias)
addToBindings(bm, c.PAlias)
addToBindings(bm, c.PAnchorBinding)
addToBindings(bm, c.PBinding)
addToBindings(bm... | [
"func",
"(",
"c",
"*",
"GraphClause",
")",
"BindingsMap",
"(",
")",
"map",
"[",
"string",
"]",
"int",
"{",
"bm",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n\n",
"addToBindings",
"(",
"bm",
",",
"c",
".",
"SBinding",
")",
"\n",
"... | // BindingsMap returns the binding map for the graph clause. | [
"BindingsMap",
"returns",
"the",
"binding",
"map",
"for",
"the",
"graph",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L347-L371 |
12,531 | google/badwolf | bql/semantic/semantic.go | Bindings | func (c *GraphClause) Bindings() []string {
var bs []string
for k := range c.BindingsMap() {
bs = append(bs, k)
}
return bs
} | go | func (c *GraphClause) Bindings() []string {
var bs []string
for k := range c.BindingsMap() {
bs = append(bs, k)
}
return bs
} | [
"func",
"(",
"c",
"*",
"GraphClause",
")",
"Bindings",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"bs",
"[",
"]",
"string",
"\n",
"for",
"k",
":=",
"range",
"c",
".",
"BindingsMap",
"(",
")",
"{",
"bs",
"=",
"append",
"(",
"bs",
",",
"k",
")",
... | // Bindings returns the list of unique bindings listed in the graph clause. | [
"Bindings",
"returns",
"the",
"list",
"of",
"unique",
"bindings",
"listed",
"in",
"the",
"graph",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L374-L380 |
12,532 | google/badwolf | bql/semantic/semantic.go | String | func (c *ConstructClause) String() string {
b := bytes.NewBufferString("{ ")
// Subject section.
if c.S != nil {
b.WriteString(c.S.String())
} else {
b.WriteString(c.SBinding)
}
// Predicate-object pairs section.
for _, pop := range c.PredicateObjectPairs() {
b.WriteString(fmt.Sprintf("%v;", pop))
}
b.... | go | func (c *ConstructClause) String() string {
b := bytes.NewBufferString("{ ")
// Subject section.
if c.S != nil {
b.WriteString(c.S.String())
} else {
b.WriteString(c.SBinding)
}
// Predicate-object pairs section.
for _, pop := range c.PredicateObjectPairs() {
b.WriteString(fmt.Sprintf("%v;", pop))
}
b.... | [
"func",
"(",
"c",
"*",
"ConstructClause",
")",
"String",
"(",
")",
"string",
"{",
"b",
":=",
"bytes",
".",
"NewBufferString",
"(",
"\"",
"\"",
")",
"\n\n",
"// Subject section.",
"if",
"c",
".",
"S",
"!=",
"nil",
"{",
"b",
".",
"WriteString",
"(",
"c... | // String returns a readable representation of a construct clause. | [
"String",
"returns",
"a",
"readable",
"representation",
"of",
"a",
"construct",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L388-L405 |
12,533 | google/badwolf | bql/semantic/semantic.go | String | func (c *ConstructPredicateObjectPair) String() string {
b := bytes.NewBufferString("")
// Predicate section.
predicate := false
if c.P != nil {
b.WriteString(" ")
b.WriteString(c.P.String())
predicate = true
}
if c.PBinding != "" {
b.WriteString(" ")
b.WriteString(c.PBinding)
}
if c.PID != "" {
b.... | go | func (c *ConstructPredicateObjectPair) String() string {
b := bytes.NewBufferString("")
// Predicate section.
predicate := false
if c.P != nil {
b.WriteString(" ")
b.WriteString(c.P.String())
predicate = true
}
if c.PBinding != "" {
b.WriteString(" ")
b.WriteString(c.PBinding)
}
if c.PID != "" {
b.... | [
"func",
"(",
"c",
"*",
"ConstructPredicateObjectPair",
")",
"String",
"(",
")",
"string",
"{",
"b",
":=",
"bytes",
".",
"NewBufferString",
"(",
"\"",
"\"",
")",
"\n\n",
"// Predicate section.",
"predicate",
":=",
"false",
"\n",
"if",
"c",
".",
"P",
"!=",
... | // String returns a readable representation of a ConstructPredicateObjectPair. | [
"String",
"returns",
"a",
"readable",
"representation",
"of",
"a",
"ConstructPredicateObjectPair",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L413-L478 |
12,534 | google/badwolf | bql/semantic/semantic.go | AddGraph | func (s *Statement) AddGraph(g string) {
s.graphNames = append(s.graphNames, g)
} | go | func (s *Statement) AddGraph(g string) {
s.graphNames = append(s.graphNames, g)
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddGraph",
"(",
"g",
"string",
")",
"{",
"s",
".",
"graphNames",
"=",
"append",
"(",
"s",
".",
"graphNames",
",",
"g",
")",
"\n",
"}"
] | // AddGraph adds a graph to a given statement. | [
"AddGraph",
"adds",
"a",
"graph",
"to",
"a",
"given",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L496-L498 |
12,535 | google/badwolf | bql/semantic/semantic.go | AddInputGraph | func (s *Statement) AddInputGraph(g string) {
s.inputGraphNames = append(s.inputGraphNames, g)
} | go | func (s *Statement) AddInputGraph(g string) {
s.inputGraphNames = append(s.inputGraphNames, g)
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddInputGraph",
"(",
"g",
"string",
")",
"{",
"s",
".",
"inputGraphNames",
"=",
"append",
"(",
"s",
".",
"inputGraphNames",
",",
"g",
")",
"\n",
"}"
] | // AddInputGraph adds an input graph to a given statement. | [
"AddInputGraph",
"adds",
"an",
"input",
"graph",
"to",
"a",
"given",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L511-L513 |
12,536 | google/badwolf | bql/semantic/semantic.go | AddOutputGraph | func (s *Statement) AddOutputGraph(g string) {
s.outputGraphNames = append(s.outputGraphNames, g)
} | go | func (s *Statement) AddOutputGraph(g string) {
s.outputGraphNames = append(s.outputGraphNames, g)
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddOutputGraph",
"(",
"g",
"string",
")",
"{",
"s",
".",
"outputGraphNames",
"=",
"append",
"(",
"s",
".",
"outputGraphNames",
",",
"g",
")",
"\n",
"}"
] | // AddOutputGraph adds an output graph to a given statement. | [
"AddOutputGraph",
"adds",
"an",
"output",
"graph",
"to",
"a",
"given",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L526-L528 |
12,537 | google/badwolf | bql/semantic/semantic.go | Init | func (s *Statement) Init(ctx context.Context, st storage.Store) error {
for _, gn := range s.graphNames {
g, err := st.Graph(ctx, gn)
if err != nil {
return err
}
s.graphs = append(s.graphs, g)
}
for _, ign := range s.inputGraphNames {
ig, err := st.Graph(ctx, ign)
if err != nil {
return err
}
... | go | func (s *Statement) Init(ctx context.Context, st storage.Store) error {
for _, gn := range s.graphNames {
g, err := st.Graph(ctx, gn)
if err != nil {
return err
}
s.graphs = append(s.graphs, g)
}
for _, ign := range s.inputGraphNames {
ig, err := st.Graph(ctx, ign)
if err != nil {
return err
}
... | [
"func",
"(",
"s",
"*",
"Statement",
")",
"Init",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
")",
"error",
"{",
"for",
"_",
",",
"gn",
":=",
"range",
"s",
".",
"graphNames",
"{",
"g",
",",
"err",
":=",
"st",
".",
... | // Init initializes all graphs given the graph names. | [
"Init",
"initializes",
"all",
"graphs",
"given",
"the",
"graph",
"names",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L536-L559 |
12,538 | google/badwolf | bql/semantic/semantic.go | AddData | func (s *Statement) AddData(d *triple.Triple) {
s.data = append(s.data, d)
} | go | func (s *Statement) AddData(d *triple.Triple) {
s.data = append(s.data, d)
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddData",
"(",
"d",
"*",
"triple",
".",
"Triple",
")",
"{",
"s",
".",
"data",
"=",
"append",
"(",
"s",
".",
"data",
",",
"d",
")",
"\n",
"}"
] | // AddData adds a triple to a given statement's data. | [
"AddData",
"adds",
"a",
"triple",
"to",
"a",
"given",
"statement",
"s",
"data",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L567-L569 |
12,539 | google/badwolf | bql/semantic/semantic.go | AddWorkingGraphClause | func (s *Statement) AddWorkingGraphClause() {
if s.workingClause != nil && !s.workingClause.IsEmpty() {
s.pattern = append(s.pattern, s.workingClause)
}
s.ResetWorkingGraphClause()
} | go | func (s *Statement) AddWorkingGraphClause() {
if s.workingClause != nil && !s.workingClause.IsEmpty() {
s.pattern = append(s.pattern, s.workingClause)
}
s.ResetWorkingGraphClause()
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddWorkingGraphClause",
"(",
")",
"{",
"if",
"s",
".",
"workingClause",
"!=",
"nil",
"&&",
"!",
"s",
".",
"workingClause",
".",
"IsEmpty",
"(",
")",
"{",
"s",
".",
"pattern",
"=",
"append",
"(",
"s",
".",
"... | // AddWorkingGraphClause adds the current working graph clause to the set of
// clauses that form the graph pattern. | [
"AddWorkingGraphClause",
"adds",
"the",
"current",
"working",
"graph",
"clause",
"to",
"the",
"set",
"of",
"clauses",
"that",
"form",
"the",
"graph",
"pattern",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L593-L598 |
12,540 | google/badwolf | bql/semantic/semantic.go | BindingsMap | func (s *Statement) BindingsMap() map[string]int {
bm := make(map[string]int)
for _, cls := range s.pattern {
if cls != nil {
addToBindings(bm, cls.SBinding)
addToBindings(bm, cls.SAlias)
addToBindings(bm, cls.STypeAlias)
addToBindings(bm, cls.SIDAlias)
addToBindings(bm, cls.PAlias)
addToBindings... | go | func (s *Statement) BindingsMap() map[string]int {
bm := make(map[string]int)
for _, cls := range s.pattern {
if cls != nil {
addToBindings(bm, cls.SBinding)
addToBindings(bm, cls.SAlias)
addToBindings(bm, cls.STypeAlias)
addToBindings(bm, cls.SIDAlias)
addToBindings(bm, cls.PAlias)
addToBindings... | [
"func",
"(",
"s",
"*",
"Statement",
")",
"BindingsMap",
"(",
")",
"map",
"[",
"string",
"]",
"int",
"{",
"bm",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n\n",
"for",
"_",
",",
"cls",
":=",
"range",
"s",
".",
"pattern",
"{",
"i... | // BindingsMap returns the set of bindings available on the graph clauses for the
// statement. | [
"BindingsMap",
"returns",
"the",
"set",
"of",
"bindings",
"available",
"on",
"the",
"graph",
"clauses",
"for",
"the",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L634-L661 |
12,541 | google/badwolf | bql/semantic/semantic.go | Bindings | func (s *Statement) Bindings() []string {
var bs []string
for k := range s.BindingsMap() {
bs = append(bs, k)
}
return bs
} | go | func (s *Statement) Bindings() []string {
var bs []string
for k := range s.BindingsMap() {
bs = append(bs, k)
}
return bs
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"Bindings",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"bs",
"[",
"]",
"string",
"\n",
"for",
"k",
":=",
"range",
"s",
".",
"BindingsMap",
"(",
")",
"{",
"bs",
"=",
"append",
"(",
"bs",
",",
"k",
")",
"... | // Bindings returns the list of bindings available on the graph clauses for he
// statement. | [
"Bindings",
"returns",
"the",
"list",
"of",
"bindings",
"available",
"on",
"the",
"graph",
"clauses",
"for",
"he",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L665-L671 |
12,542 | google/badwolf | bql/semantic/semantic.go | Swap | func (s bySpecificity) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | go | func (s bySpecificity) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | [
"func",
"(",
"s",
"bySpecificity",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"s",
"[",
"i",
"]",
",",
"s",
"[",
"j",
"]",
"=",
"s",
"[",
"j",
"]",
",",
"s",
"[",
"i",
"]",
"\n",
"}"
] | // Swap exchanges the i and j elements in the clauses array. | [
"Swap",
"exchanges",
"the",
"i",
"and",
"j",
"elements",
"in",
"the",
"clauses",
"array",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L682-L684 |
12,543 | google/badwolf | bql/semantic/semantic.go | Less | func (s bySpecificity) Less(i, j int) bool {
return s[i].Specificity() >= s[j].Specificity()
} | go | func (s bySpecificity) Less(i, j int) bool {
return s[i].Specificity() >= s[j].Specificity()
} | [
"func",
"(",
"s",
"bySpecificity",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"s",
"[",
"i",
"]",
".",
"Specificity",
"(",
")",
">=",
"s",
"[",
"j",
"]",
".",
"Specificity",
"(",
")",
"\n",
"}"
] | // Less returns true if the i element is less specific than j one. | [
"Less",
"returns",
"true",
"if",
"the",
"i",
"element",
"is",
"less",
"specific",
"than",
"j",
"one",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L687-L689 |
12,544 | google/badwolf | bql/semantic/semantic.go | SortedGraphPatternClauses | func (s *Statement) SortedGraphPatternClauses() []*GraphClause {
var ptrns []*GraphClause
// Filter empty clauses.
for _, cls := range s.pattern {
if cls != nil && !cls.IsEmpty() {
ptrns = append(ptrns, cls)
}
}
sort.Sort(bySpecificity(ptrns))
return ptrns
} | go | func (s *Statement) SortedGraphPatternClauses() []*GraphClause {
var ptrns []*GraphClause
// Filter empty clauses.
for _, cls := range s.pattern {
if cls != nil && !cls.IsEmpty() {
ptrns = append(ptrns, cls)
}
}
sort.Sort(bySpecificity(ptrns))
return ptrns
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"SortedGraphPatternClauses",
"(",
")",
"[",
"]",
"*",
"GraphClause",
"{",
"var",
"ptrns",
"[",
"]",
"*",
"GraphClause",
"\n",
"// Filter empty clauses.",
"for",
"_",
",",
"cls",
":=",
"range",
"s",
".",
"pattern",
... | // SortedGraphPatternClauses return the list of graph pattern clauses | [
"SortedGraphPatternClauses",
"return",
"the",
"list",
"of",
"graph",
"pattern",
"clauses"
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L692-L702 |
12,545 | google/badwolf | bql/semantic/semantic.go | String | func (p *Projection) String() string {
b := bytes.NewBufferString(p.Binding)
b.WriteString(" as ")
b.WriteString(p.Binding)
if p.OP != lexer.ItemError {
b.WriteString(" via ")
b.WriteString(p.OP.String())
if p.Modifier != lexer.ItemError {
b.WriteString(" ")
b.WriteString(p.Modifier.String())
}
}
re... | go | func (p *Projection) String() string {
b := bytes.NewBufferString(p.Binding)
b.WriteString(" as ")
b.WriteString(p.Binding)
if p.OP != lexer.ItemError {
b.WriteString(" via ")
b.WriteString(p.OP.String())
if p.Modifier != lexer.ItemError {
b.WriteString(" ")
b.WriteString(p.Modifier.String())
}
}
re... | [
"func",
"(",
"p",
"*",
"Projection",
")",
"String",
"(",
")",
"string",
"{",
"b",
":=",
"bytes",
".",
"NewBufferString",
"(",
"p",
".",
"Binding",
")",
"\n",
"b",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"b",
".",
"WriteString",
"(",
"p",
... | // String returns a readable form of the projection. | [
"String",
"returns",
"a",
"readable",
"form",
"of",
"the",
"projection",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L715-L728 |
12,546 | google/badwolf | bql/semantic/semantic.go | IsEmpty | func (p *Projection) IsEmpty() bool {
return p.Binding == "" && p.Alias == "" && p.OP == lexer.ItemError && p.Modifier == lexer.ItemError
} | go | func (p *Projection) IsEmpty() bool {
return p.Binding == "" && p.Alias == "" && p.OP == lexer.ItemError && p.Modifier == lexer.ItemError
} | [
"func",
"(",
"p",
"*",
"Projection",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"p",
".",
"Binding",
"==",
"\"",
"\"",
"&&",
"p",
".",
"Alias",
"==",
"\"",
"\"",
"&&",
"p",
".",
"OP",
"==",
"lexer",
".",
"ItemError",
"&&",
"p",
".",
"Modi... | // IsEmpty checks if the given projection is empty. | [
"IsEmpty",
"checks",
"if",
"the",
"given",
"projection",
"is",
"empty",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L731-L733 |
12,547 | google/badwolf | bql/semantic/semantic.go | WorkingProjection | func (s *Statement) WorkingProjection() *Projection {
if s.workingProjection == nil {
s.ResetProjection()
}
return s.workingProjection
} | go | func (s *Statement) WorkingProjection() *Projection {
if s.workingProjection == nil {
s.ResetProjection()
}
return s.workingProjection
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"WorkingProjection",
"(",
")",
"*",
"Projection",
"{",
"if",
"s",
".",
"workingProjection",
"==",
"nil",
"{",
"s",
".",
"ResetProjection",
"(",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"workingProjection",
"\n",
... | // WorkingProjection returns the current working variable projection. | [
"WorkingProjection",
"returns",
"the",
"current",
"working",
"variable",
"projection",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L741-L746 |
12,548 | google/badwolf | bql/semantic/semantic.go | AddWorkingProjection | func (s *Statement) AddWorkingProjection() {
if s.workingProjection != nil && !s.workingProjection.IsEmpty() {
s.projection = append(s.projection, s.workingProjection)
}
s.ResetProjection()
} | go | func (s *Statement) AddWorkingProjection() {
if s.workingProjection != nil && !s.workingProjection.IsEmpty() {
s.projection = append(s.projection, s.workingProjection)
}
s.ResetProjection()
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddWorkingProjection",
"(",
")",
"{",
"if",
"s",
".",
"workingProjection",
"!=",
"nil",
"&&",
"!",
"s",
".",
"workingProjection",
".",
"IsEmpty",
"(",
")",
"{",
"s",
".",
"projection",
"=",
"append",
"(",
"s",
... | // AddWorkingProjection adds the current projection variable to the set of
// projects that this statement. | [
"AddWorkingProjection",
"adds",
"the",
"current",
"projection",
"variable",
"to",
"the",
"set",
"of",
"projects",
"that",
"this",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L750-L755 |
12,549 | google/badwolf | bql/semantic/semantic.go | InputBindings | func (s *Statement) InputBindings() []string {
var res []string
for _, p := range s.projection {
if p.Binding != "" {
res = append(res, p.Binding)
}
}
for _, c := range s.constructClauses {
if c.SBinding != "" {
res = append(res, c.SBinding)
}
for _, p := range c.predicateObjectPairs {
if p.PBind... | go | func (s *Statement) InputBindings() []string {
var res []string
for _, p := range s.projection {
if p.Binding != "" {
res = append(res, p.Binding)
}
}
for _, c := range s.constructClauses {
if c.SBinding != "" {
res = append(res, c.SBinding)
}
for _, p := range c.predicateObjectPairs {
if p.PBind... | [
"func",
"(",
"s",
"*",
"Statement",
")",
"InputBindings",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"res",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"s",
".",
"projection",
"{",
"if",
"p",
".",
"Binding",
"!=",
"\"",
"\"",
... | // InputBindings returns the list of incoming bindings feed from a where clause. | [
"InputBindings",
"returns",
"the",
"list",
"of",
"incoming",
"bindings",
"feed",
"from",
"a",
"where",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L763-L790 |
12,550 | google/badwolf | bql/semantic/semantic.go | OutputBindings | func (s *Statement) OutputBindings() []string {
var res []string
for _, p := range s.projection {
if p.Alias != "" {
res = append(res, p.Alias)
continue
}
if p.Binding != "" {
res = append(res, p.Binding)
}
}
set := make(map[string]bool)
set[""] = true
for _, c := range s.constructClauses {
if ... | go | func (s *Statement) OutputBindings() []string {
var res []string
for _, p := range s.projection {
if p.Alias != "" {
res = append(res, p.Alias)
continue
}
if p.Binding != "" {
res = append(res, p.Binding)
}
}
set := make(map[string]bool)
set[""] = true
for _, c := range s.constructClauses {
if ... | [
"func",
"(",
"s",
"*",
"Statement",
")",
"OutputBindings",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"res",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"s",
".",
"projection",
"{",
"if",
"p",
".",
"Alias",
"!=",
"\"",
"\"",
"... | // OutputBindings returns the list of binding that a query will return. | [
"OutputBindings",
"returns",
"the",
"list",
"of",
"binding",
"that",
"a",
"query",
"will",
"return",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L793-L831 |
12,551 | google/badwolf | bql/semantic/semantic.go | AddWorkingConstructClause | func (s *Statement) AddWorkingConstructClause() {
if s.workingConstructClause != nil && !s.workingConstructClause.IsEmpty() {
s.constructClauses = append(s.constructClauses, s.workingConstructClause)
}
s.ResetWorkingConstructClause()
} | go | func (s *Statement) AddWorkingConstructClause() {
if s.workingConstructClause != nil && !s.workingConstructClause.IsEmpty() {
s.constructClauses = append(s.constructClauses, s.workingConstructClause)
}
s.ResetWorkingConstructClause()
} | [
"func",
"(",
"s",
"*",
"Statement",
")",
"AddWorkingConstructClause",
"(",
")",
"{",
"if",
"s",
".",
"workingConstructClause",
"!=",
"nil",
"&&",
"!",
"s",
".",
"workingConstructClause",
".",
"IsEmpty",
"(",
")",
"{",
"s",
".",
"constructClauses",
"=",
"ap... | // AddWorkingConstructClause adds the current working construct clause to the set
// of construct clauses that form the construct statement. | [
"AddWorkingConstructClause",
"adds",
"the",
"current",
"working",
"construct",
"clause",
"to",
"the",
"set",
"of",
"construct",
"clauses",
"that",
"form",
"the",
"construct",
"statement",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L889-L894 |
12,552 | google/badwolf | bql/semantic/semantic.go | AddWorkingPredicateObjectPair | func (c *ConstructClause) AddWorkingPredicateObjectPair() {
if c.workingPredicateObjectPair != nil && !c.workingPredicateObjectPair.IsEmpty() {
c.predicateObjectPairs = append(c.predicateObjectPairs, c.workingPredicateObjectPair)
}
c.ResetWorkingPredicateObjectPair()
} | go | func (c *ConstructClause) AddWorkingPredicateObjectPair() {
if c.workingPredicateObjectPair != nil && !c.workingPredicateObjectPair.IsEmpty() {
c.predicateObjectPairs = append(c.predicateObjectPairs, c.workingPredicateObjectPair)
}
c.ResetWorkingPredicateObjectPair()
} | [
"func",
"(",
"c",
"*",
"ConstructClause",
")",
"AddWorkingPredicateObjectPair",
"(",
")",
"{",
"if",
"c",
".",
"workingPredicateObjectPair",
"!=",
"nil",
"&&",
"!",
"c",
".",
"workingPredicateObjectPair",
".",
"IsEmpty",
"(",
")",
"{",
"c",
".",
"predicateObje... | // AddWorkingPredicateObjectPair adds the working predicate-object pair to the set
// of predicate-object pairs belonging to the construct clause. | [
"AddWorkingPredicateObjectPair",
"adds",
"the",
"working",
"predicate",
"-",
"object",
"pair",
"to",
"the",
"set",
"of",
"predicate",
"-",
"object",
"pairs",
"belonging",
"to",
"the",
"construct",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/semantic/semantic.go#L916-L921 |
12,553 | google/badwolf | bql/grammar/parser.go | NewSymbol | func NewSymbol(s semantic.Symbol) Element {
return Element{
isSymbol: true,
symbol: s,
}
} | go | func NewSymbol(s semantic.Symbol) Element {
return Element{
isSymbol: true,
symbol: s,
}
} | [
"func",
"NewSymbol",
"(",
"s",
"semantic",
".",
"Symbol",
")",
"Element",
"{",
"return",
"Element",
"{",
"isSymbol",
":",
"true",
",",
"symbol",
":",
"s",
",",
"}",
"\n",
"}"
] | // NewSymbol creates a new element from a symbol. | [
"NewSymbol",
"creates",
"a",
"new",
"element",
"from",
"a",
"symbol",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/parser.go#L32-L37 |
12,554 | google/badwolf | bql/grammar/parser.go | NewTokenType | func NewTokenType(t lexer.TokenType) Element {
return Element{
isSymbol: false,
tokenType: t,
}
} | go | func NewTokenType(t lexer.TokenType) Element {
return Element{
isSymbol: false,
tokenType: t,
}
} | [
"func",
"NewTokenType",
"(",
"t",
"lexer",
".",
"TokenType",
")",
"Element",
"{",
"return",
"Element",
"{",
"isSymbol",
":",
"false",
",",
"tokenType",
":",
"t",
",",
"}",
"\n",
"}"
] | // NewTokenType creates a new element from a token. | [
"NewTokenType",
"creates",
"a",
"new",
"element",
"from",
"a",
"token",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/parser.go#L40-L45 |
12,555 | google/badwolf | bql/grammar/parser.go | NewParser | func NewParser(grammar *Grammar) (*Parser, error) {
// Check that the grammar is left factorized.
for _, clauses := range *grammar {
idx := 0
for _, cls := range clauses {
if len(cls.Elements) == 0 {
if idx == 0 {
idx++
continue
}
return nil, fmt.Errorf("grammar.NewParser: invalid extra e... | go | func NewParser(grammar *Grammar) (*Parser, error) {
// Check that the grammar is left factorized.
for _, clauses := range *grammar {
idx := 0
for _, cls := range clauses {
if len(cls.Elements) == 0 {
if idx == 0 {
idx++
continue
}
return nil, fmt.Errorf("grammar.NewParser: invalid extra e... | [
"func",
"NewParser",
"(",
"grammar",
"*",
"Grammar",
")",
"(",
"*",
"Parser",
",",
"error",
")",
"{",
"// Check that the grammar is left factorized.",
"for",
"_",
",",
"clauses",
":=",
"range",
"*",
"grammar",
"{",
"idx",
":=",
"0",
"\n",
"for",
"_",
",",
... | // NewParser creates a new recursive descent parser for a left factorized
// grammar. | [
"NewParser",
"creates",
"a",
"new",
"recursive",
"descent",
"parser",
"for",
"a",
"left",
"factorized",
"grammar",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/parser.go#L77-L97 |
12,556 | google/badwolf | bql/grammar/parser.go | Parse | func (p *Parser) Parse(llk *LLk, st *semantic.Statement) error {
b, err := p.consume(llk, st, "START")
if err != nil {
return err
}
if !b {
return fmt.Errorf("Parser.Parse: inconsitent parser, no error found, and no tokens were consumed")
}
return nil
} | go | func (p *Parser) Parse(llk *LLk, st *semantic.Statement) error {
b, err := p.consume(llk, st, "START")
if err != nil {
return err
}
if !b {
return fmt.Errorf("Parser.Parse: inconsitent parser, no error found, and no tokens were consumed")
}
return nil
} | [
"func",
"(",
"p",
"*",
"Parser",
")",
"Parse",
"(",
"llk",
"*",
"LLk",
",",
"st",
"*",
"semantic",
".",
"Statement",
")",
"error",
"{",
"b",
",",
"err",
":=",
"p",
".",
"consume",
"(",
"llk",
",",
"st",
",",
"\"",
"\"",
")",
"\n",
"if",
"err"... | // Parse attempts to run the parser for the given input. | [
"Parse",
"attempts",
"to",
"run",
"the",
"parser",
"for",
"the",
"given",
"input",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/parser.go#L100-L109 |
12,557 | google/badwolf | bql/grammar/parser.go | consume | func (p *Parser) consume(llk *LLk, st *semantic.Statement, s semantic.Symbol) (bool, error) {
for _, clause := range (*p.grammar)[s] {
if len(clause.Elements) == 0 {
return true, nil
}
elem := clause.Elements[0]
if elem.isSymbol {
return false, fmt.Errorf("Parser.consume: not left factored grammar in %v"... | go | func (p *Parser) consume(llk *LLk, st *semantic.Statement, s semantic.Symbol) (bool, error) {
for _, clause := range (*p.grammar)[s] {
if len(clause.Elements) == 0 {
return true, nil
}
elem := clause.Elements[0]
if elem.isSymbol {
return false, fmt.Errorf("Parser.consume: not left factored grammar in %v"... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"consume",
"(",
"llk",
"*",
"LLk",
",",
"st",
"*",
"semantic",
".",
"Statement",
",",
"s",
"semantic",
".",
"Symbol",
")",
"(",
"bool",
",",
"error",
")",
"{",
"for",
"_",
",",
"clause",
":=",
"range",
"(",
... | // consume attempts to consume all input tokens for the provided symbols given
// the parser grammar. | [
"consume",
"attempts",
"to",
"consume",
"all",
"input",
"tokens",
"for",
"the",
"provided",
"symbols",
"given",
"the",
"parser",
"grammar",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/parser.go#L113-L127 |
12,558 | google/badwolf | bql/grammar/parser.go | expect | func (p *Parser) expect(llk *LLk, st *semantic.Statement, s semantic.Symbol, cls *Clause) (bool, error) {
if cls.ProcessStart != nil {
if _, err := cls.ProcessStart(st, s); err != nil {
return false, err
}
}
for _, elem := range cls.Elements {
tkn := llk.Current()
if elem.isSymbol {
if b, err := p.cons... | go | func (p *Parser) expect(llk *LLk, st *semantic.Statement, s semantic.Symbol, cls *Clause) (bool, error) {
if cls.ProcessStart != nil {
if _, err := cls.ProcessStart(st, s); err != nil {
return false, err
}
}
for _, elem := range cls.Elements {
tkn := llk.Current()
if elem.isSymbol {
if b, err := p.cons... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"expect",
"(",
"llk",
"*",
"LLk",
",",
"st",
"*",
"semantic",
".",
"Statement",
",",
"s",
"semantic",
".",
"Symbol",
",",
"cls",
"*",
"Clause",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"cls",
".",
"P... | // expect given the input, symbol, and clause attempts to satisfy all elements. | [
"expect",
"given",
"the",
"input",
"symbol",
"and",
"clause",
"attempts",
"to",
"satisfy",
"all",
"elements",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/grammar/parser.go#L130-L165 |
12,559 | google/badwolf | tools/compliance/runner.go | getGraphFromStore | func getGraphFromStore(ctx context.Context, st storage.Store, id string) (storage.Graph, error) {
g, err := st.Graph(ctx, id)
if err == nil {
return g, nil
}
return st.NewGraph(ctx, id)
} | go | func getGraphFromStore(ctx context.Context, st storage.Store, id string) (storage.Graph, error) {
g, err := st.Graph(ctx, id)
if err == nil {
return g, nil
}
return st.NewGraph(ctx, id)
} | [
"func",
"getGraphFromStore",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"id",
"string",
")",
"(",
"storage",
".",
"Graph",
",",
"error",
")",
"{",
"g",
",",
"err",
":=",
"st",
".",
"Graph",
"(",
"ctx",
",",
"id"... | // getGraphFromStore returns a Graph. Will create it if it does not exist. | [
"getGraphFromStore",
"returns",
"a",
"Graph",
".",
"Will",
"create",
"it",
"if",
"it",
"does",
"not",
"exist",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/runner.go#L32-L38 |
12,560 | google/badwolf | tools/compliance/runner.go | populateSources | func (s *Story) populateSources(ctx context.Context, st storage.Store, b literal.Builder) error {
for _, src := range s.Sources {
g, err := getGraphFromStore(ctx, st, src.ID)
if err != nil {
return err
}
var trps []*triple.Triple
for _, trp := range src.Facts {
t, err := triple.Parse(trp, b)
if err ... | go | func (s *Story) populateSources(ctx context.Context, st storage.Store, b literal.Builder) error {
for _, src := range s.Sources {
g, err := getGraphFromStore(ctx, st, src.ID)
if err != nil {
return err
}
var trps []*triple.Triple
for _, trp := range src.Facts {
t, err := triple.Parse(trp, b)
if err ... | [
"func",
"(",
"s",
"*",
"Story",
")",
"populateSources",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"b",
"literal",
".",
"Builder",
")",
"error",
"{",
"for",
"_",
",",
"src",
":=",
"range",
"s",
".",
"Sources",
"... | // populateSources create all the graph required for the story and
// populates it with the provided data. | [
"populateSources",
"create",
"all",
"the",
"graph",
"required",
"for",
"the",
"story",
"and",
"populates",
"it",
"with",
"the",
"provided",
"data",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/runner.go#L42-L61 |
12,561 | google/badwolf | tools/compliance/runner.go | cleanSources | func (s *Story) cleanSources(ctx context.Context, st storage.Store) error {
for _, src := range s.Sources {
if err := st.DeleteGraph(ctx, src.ID); err != nil {
return err
}
}
return nil
} | go | func (s *Story) cleanSources(ctx context.Context, st storage.Store) error {
for _, src := range s.Sources {
if err := st.DeleteGraph(ctx, src.ID); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"s",
"*",
"Story",
")",
"cleanSources",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
")",
"error",
"{",
"for",
"_",
",",
"src",
":=",
"range",
"s",
".",
"Sources",
"{",
"if",
"err",
":=",
"st",
".",
"Del... | // cleanSources create all the graph required for the story and
// populates it with the provided data. | [
"cleanSources",
"create",
"all",
"the",
"graph",
"required",
"for",
"the",
"story",
"and",
"populates",
"it",
"with",
"the",
"provided",
"data",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/runner.go#L65-L72 |
12,562 | google/badwolf | tools/compliance/runner.go | runAssertion | func (a *Assertion) runAssertion(ctx context.Context, st storage.Store, chanSize, bulkSize int) (bool, *table.Table, *table.Table, error) {
errorizer := func(e error) (bool, *table.Table, *table.Table, error) {
if a.WillFail && e != nil {
return true, nil, nil, nil
}
return false, nil, nil, e
}
// Run the ... | go | func (a *Assertion) runAssertion(ctx context.Context, st storage.Store, chanSize, bulkSize int) (bool, *table.Table, *table.Table, error) {
errorizer := func(e error) (bool, *table.Table, *table.Table, error) {
if a.WillFail && e != nil {
return true, nil, nil, nil
}
return false, nil, nil, e
}
// Run the ... | [
"func",
"(",
"a",
"*",
"Assertion",
")",
"runAssertion",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"(",
"bool",
",",
"*",
"table",
".",
"Table",
",",
"*",
"table",
".",
... | // runAssertion runs the assertion and compares the outcome. Returns the outcome
// of comparing the obtained result table with the assertion table if there is
// no error during the assertion. | [
"runAssertion",
"runs",
"the",
"assertion",
"and",
"compares",
"the",
"outcome",
".",
"Returns",
"the",
"outcome",
"of",
"comparing",
"the",
"obtained",
"result",
"table",
"with",
"the",
"assertion",
"table",
"if",
"there",
"is",
"no",
"error",
"during",
"the"... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/runner.go#L77-L112 |
12,563 | google/badwolf | tools/compliance/runner.go | Run | func (s *Story) Run(ctx context.Context, st storage.Store, b literal.Builder, chanSize, bulkSize int) (map[string]*AssertionOutcome, error) {
// Populate the sources.
if err := s.populateSources(ctx, st, b); err != nil {
return nil, err
}
// Run assertions.
m := make(map[string]*AssertionOutcome)
for _, a := ra... | go | func (s *Story) Run(ctx context.Context, st storage.Store, b literal.Builder, chanSize, bulkSize int) (map[string]*AssertionOutcome, error) {
// Populate the sources.
if err := s.populateSources(ctx, st, b); err != nil {
return nil, err
}
// Run assertions.
m := make(map[string]*AssertionOutcome)
for _, a := ra... | [
"func",
"(",
"s",
"*",
"Story",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"b",
"literal",
".",
"Builder",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"Assertio... | // Run evaluates a story. Returns if the story is true or not. It will also
// return an error if something wrong happen along the way. It is worth
// mentioning that Run does not clear any data available in the provided
// storage. | [
"Run",
"evaluates",
"a",
"story",
".",
"Returns",
"if",
"the",
"story",
"is",
"true",
"or",
"not",
".",
"It",
"will",
"also",
"return",
"an",
"error",
"if",
"something",
"wrong",
"happen",
"along",
"the",
"way",
".",
"It",
"is",
"worth",
"mentioning",
... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/runner.go#L118-L142 |
12,564 | google/badwolf | tools/compliance/runner.go | RunStories | func RunStories(ctx context.Context, st storage.Store, b literal.Builder, stories []*Story, chanSize, bulkSize int) *AssertionBattery {
results := &AssertionBattery{}
for _, s := range stories {
o, err := s.Run(ctx, st, b, chanSize, bulkSize)
results.Entries = append(results.Entries, &AssertionBatteryEntry{
St... | go | func RunStories(ctx context.Context, st storage.Store, b literal.Builder, stories []*Story, chanSize, bulkSize int) *AssertionBattery {
results := &AssertionBattery{}
for _, s := range stories {
o, err := s.Run(ctx, st, b, chanSize, bulkSize)
results.Entries = append(results.Entries, &AssertionBatteryEntry{
St... | [
"func",
"RunStories",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"b",
"literal",
".",
"Builder",
",",
"stories",
"[",
"]",
"*",
"Story",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"*",
"AssertionBattery",
"{",
"r... | // RunStories runs a the provided stories and returns the outcome of each of
// them. | [
"RunStories",
"runs",
"a",
"the",
"provided",
"stories",
"and",
"returns",
"the",
"outcome",
"of",
"each",
"of",
"them",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/runner.go#L158-L169 |
12,565 | google/badwolf | tools/vcli/bw/server/server.go | runServer | func runServer(ctx context.Context, cmd *command.Command, args []string, store storage.Store, chanSize, bulkSize int) int {
// Check parameters.
if len(args) < 2 {
log.Printf("[%v] Missing required port number. ", time.Now())
cmd.Usage()
return 2
}
// Validate port number.
p := strings.TrimSpace(args[len(ar... | go | func runServer(ctx context.Context, cmd *command.Command, args []string, store storage.Store, chanSize, bulkSize int) int {
// Check parameters.
if len(args) < 2 {
log.Printf("[%v] Missing required port number. ", time.Now())
cmd.Usage()
return 2
}
// Validate port number.
p := strings.TrimSpace(args[len(ar... | [
"func",
"runServer",
"(",
"ctx",
"context",
".",
"Context",
",",
"cmd",
"*",
"command",
".",
"Command",
",",
"args",
"[",
"]",
"string",
",",
"store",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"int",
"{",
"// Check parameters... | // runServer runs the simple BQL endpoint. | [
"runServer",
"runs",
"the",
"simple",
"BQL",
"endpoint",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/server/server.go#L60-L90 |
12,566 | google/badwolf | tools/vcli/bw/server/server.go | bqlHandler | func (s *serverConfig) bqlHandler(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
w.WriteHeader(http.StatusMethodNotAllowed)
reportError(w, r, err)
return
}
if r.Method != http.MethodPost {
reportError(w, r, fmt.Errorf("invalid %s request on %q endpoint. Only POST request are ... | go | func (s *serverConfig) bqlHandler(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
w.WriteHeader(http.StatusMethodNotAllowed)
reportError(w, r, err)
return
}
if r.Method != http.MethodPost {
reportError(w, r, fmt.Errorf("invalid %s request on %q endpoint. Only POST request are ... | [
"func",
"(",
"s",
"*",
"serverConfig",
")",
"bqlHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"err",
":=",
"r",
".",
"ParseForm",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"w",
".",
"Write... | // bqlHandler imPathUnescapeplements the handler to server BQL requests. | [
"bqlHandler",
"imPathUnescapeplements",
"the",
"handler",
"to",
"server",
"BQL",
"requests",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/server/server.go#L93-L161 |
12,567 | google/badwolf | tools/vcli/bw/server/server.go | getQueries | func getQueries(raw []string) []string {
var res []string
for _, q := range raw {
for _, qs := range strings.Split(q, ";") {
if nq := strings.TrimSpace(qs); len(nq) > 0 {
res = append(res, nq+";")
}
}
}
return res
} | go | func getQueries(raw []string) []string {
var res []string
for _, q := range raw {
for _, qs := range strings.Split(q, ";") {
if nq := strings.TrimSpace(qs); len(nq) > 0 {
res = append(res, nq+";")
}
}
}
return res
} | [
"func",
"getQueries",
"(",
"raw",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"var",
"res",
"[",
"]",
"string",
"\n\n",
"for",
"_",
",",
"q",
":=",
"range",
"raw",
"{",
"for",
"_",
",",
"qs",
":=",
"range",
"strings",
".",
"Split",
"(",
"... | // getQueries returns the list of queries found. It will split them if needed. | [
"getQueries",
"returns",
"the",
"list",
"of",
"queries",
"found",
".",
"It",
"will",
"split",
"them",
"if",
"needed",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/server/server.go#L171-L183 |
12,568 | google/badwolf | tools/vcli/bw/server/server.go | defaultHandler | func defaultHandler(w http.ResponseWriter, r *http.Request) {
if err := defaultEntryTemplate.Execute(w, nil); err != nil {
reportError(w, r, err)
}
} | go | func defaultHandler(w http.ResponseWriter, r *http.Request) {
if err := defaultEntryTemplate.Execute(w, nil); err != nil {
reportError(w, r, err)
}
} | [
"func",
"defaultHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"err",
":=",
"defaultEntryTemplate",
".",
"Execute",
"(",
"w",
",",
"nil",
")",
";",
"err",
"!=",
"nil",
"{",
"reportError",
"(",
... | // defaultHandler implements the handler to server BQL requests. | [
"defaultHandler",
"implements",
"the",
"handler",
"to",
"server",
"BQL",
"requests",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/server/server.go#L207-L211 |
12,569 | google/badwolf | tools/vcli/bw/server/server.go | reportError | func reportError(w http.ResponseWriter, r *http.Request, err error) {
w.WriteHeader(http.StatusInternalServerError)
log.Printf("[%s] %v\n", time.Now(), err)
errorTemplate.Execute(w, err)
} | go | func reportError(w http.ResponseWriter, r *http.Request, err error) {
w.WriteHeader(http.StatusInternalServerError)
log.Printf("[%s] %v\n", time.Now(), err)
errorTemplate.Execute(w, err)
} | [
"func",
"reportError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"http",
".",
"StatusInternalServerError",
")",
"\n",
"log",
".",
"Printf",
"(",
"\"",
"\... | // reportError reports the given error. | [
"reportError",
"reports",
"the",
"given",
"error",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/server/server.go#L214-L218 |
12,570 | google/badwolf | tools/vcli/bw/repl/repl.go | REPL | func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, builderSize int, done chan bool) int {
var tracer io.Writer
ctx, isTracingToFile, sessionStart := context.Background(), false, time.Now()
driverPlain := func() storage.Store {
return od
}
driverWithMemoization := func() storage.Store... | go | func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, builderSize int, done chan bool) int {
var tracer io.Writer
ctx, isTracingToFile, sessionStart := context.Background(), false, time.Now()
driverPlain := func() storage.Store {
return od
}
driverWithMemoization := func() storage.Store... | [
"func",
"REPL",
"(",
"od",
"storage",
".",
"Store",
",",
"input",
"*",
"os",
".",
"File",
",",
"rl",
"ReadLiner",
",",
"chanSize",
",",
"bulkSize",
",",
"builderSize",
"int",
",",
"done",
"chan",
"bool",
")",
"int",
"{",
"var",
"tracer",
"io",
".",
... | // REPL starts a read-evaluation-print-loop to run BQL commands. | [
"REPL",
"starts",
"a",
"read",
"-",
"evaluation",
"-",
"print",
"-",
"loop",
"to",
"run",
"BQL",
"commands",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/repl/repl.go#L92-L244 |
12,571 | google/badwolf | tools/vcli/bw/repl/repl.go | printHelp | func printHelp() {
fmt.Println()
fmt.Println("help - prints help for the bw console.")
fmt.Println("disable memoization - disables partial result memoization on query resolution.")
fmt.Println("enable memoization ... | go | func printHelp() {
fmt.Println()
fmt.Println("help - prints help for the bw console.")
fmt.Println("disable memoization - disables partial result memoization on query resolution.")
fmt.Println("enable memoization ... | [
"func",
"printHelp",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"fmt",
".",
"P... | // printHelp prints help for the console commands. | [
"printHelp",
"prints",
"help",
"for",
"the",
"console",
"commands",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/repl/repl.go#L247-L260 |
12,572 | google/badwolf | tools/vcli/bw/repl/repl.go | runBQLFromFile | func runBQLFromFile(ctx context.Context, driver storage.Store, chanSize, bulkSize int, line string, w io.Writer) (string, int, error) {
ss := strings.Split(strings.TrimSpace(line), " ")
if len(ss) != 2 {
return "", 0, fmt.Errorf("wrong syntax: run <file_with_bql_statements>")
}
path := ss[1]
tracer.Trace(w, func... | go | func runBQLFromFile(ctx context.Context, driver storage.Store, chanSize, bulkSize int, line string, w io.Writer) (string, int, error) {
ss := strings.Split(strings.TrimSpace(line), " ")
if len(ss) != 2 {
return "", 0, fmt.Errorf("wrong syntax: run <file_with_bql_statements>")
}
path := ss[1]
tracer.Trace(w, func... | [
"func",
"runBQLFromFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"driver",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
",",
"line",
"string",
",",
"w",
"io",
".",
"Writer",
")",
"(",
"string",
",",
"int",
",",
"error",
")",
... | // runBQLFromFile loads all the statements in the file and runs them. | [
"runBQLFromFile",
"loads",
"all",
"the",
"statements",
"in",
"the",
"file",
"and",
"runs",
"them",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/repl/repl.go#L263-L293 |
12,573 | google/badwolf | tools/vcli/bw/repl/repl.go | runBQL | func runBQL(ctx context.Context, bql string, s storage.Store, chanSize, bulkSize int, w io.Writer) (*table.Table, error) {
tracer.Trace(w, func() []string {
return []string{fmt.Sprintf("Executing query: %s", bql)}
})
pln, err := planBQL(ctx, bql, s, chanSize, bulkSize, w)
if err != nil {
return nil, err
}
if ... | go | func runBQL(ctx context.Context, bql string, s storage.Store, chanSize, bulkSize int, w io.Writer) (*table.Table, error) {
tracer.Trace(w, func() []string {
return []string{fmt.Sprintf("Executing query: %s", bql)}
})
pln, err := planBQL(ctx, bql, s, chanSize, bulkSize, w)
if err != nil {
return nil, err
}
if ... | [
"func",
"runBQL",
"(",
"ctx",
"context",
".",
"Context",
",",
"bql",
"string",
",",
"s",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
",",
"w",
"io",
".",
"Writer",
")",
"(",
"*",
"table",
".",
"Table",
",",
"error",
")",
"{",
... | // runBQL attempts to execute the provided query against the given store. | [
"runBQL",
"attempts",
"to",
"execute",
"the",
"provided",
"query",
"against",
"the",
"given",
"store",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/repl/repl.go#L296-L319 |
12,574 | google/badwolf | tools/vcli/bw/repl/repl.go | planBQL | func planBQL(ctx context.Context, bql string, s storage.Store, chanSize, bulkSize int, w io.Writer) (planner.Executor, error) {
bql = strings.TrimSpace(bql)
if bql == ";" {
tracer.Trace(w, func() []string {
return []string{"Empty statement found"}
})
return nil, nil
}
p, err := grammar.NewParser(grammar.Se... | go | func planBQL(ctx context.Context, bql string, s storage.Store, chanSize, bulkSize int, w io.Writer) (planner.Executor, error) {
bql = strings.TrimSpace(bql)
if bql == ";" {
tracer.Trace(w, func() []string {
return []string{"Empty statement found"}
})
return nil, nil
}
p, err := grammar.NewParser(grammar.Se... | [
"func",
"planBQL",
"(",
"ctx",
"context",
".",
"Context",
",",
"bql",
"string",
",",
"s",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
",",
"w",
"io",
".",
"Writer",
")",
"(",
"planner",
".",
"Executor",
",",
"error",
")",
"{",
... | // planBQL attempts to create the execution plan for the provided query against the given store. | [
"planBQL",
"attempts",
"to",
"create",
"the",
"execution",
"plan",
"for",
"the",
"provided",
"query",
"against",
"the",
"given",
"store",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/repl/repl.go#L322-L358 |
12,575 | google/badwolf | tools/compliance/entry.go | Marshal | func (s *Story) Marshal() (string, error) {
b, err := json.MarshalIndent(s, "", " ")
if err != nil {
return "", err
}
return string(b), nil
} | go | func (s *Story) Marshal() (string, error) {
b, err := json.MarshalIndent(s, "", " ")
if err != nil {
return "", err
}
return string(b), nil
} | [
"func",
"(",
"s",
"*",
"Story",
")",
"Marshal",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"s",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // Marshal serializes the story into a JSON readable string. | [
"Marshal",
"serializes",
"the",
"story",
"into",
"a",
"JSON",
"readable",
"string",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/entry.go#L85-L91 |
12,576 | google/badwolf | tools/compliance/entry.go | Unmarshal | func (s *Story) Unmarshal(ss string) error {
return json.Unmarshal([]byte(ss), s)
} | go | func (s *Story) Unmarshal(ss string) error {
return json.Unmarshal([]byte(ss), s)
} | [
"func",
"(",
"s",
"*",
"Story",
")",
"Unmarshal",
"(",
"ss",
"string",
")",
"error",
"{",
"return",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"ss",
")",
",",
"s",
")",
"\n",
"}"
] | // Unmarshal rebuilds a story from a JSON readable string. | [
"Unmarshal",
"rebuilds",
"a",
"story",
"from",
"a",
"JSON",
"readable",
"string",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/entry.go#L94-L96 |
12,577 | google/badwolf | tools/compliance/entry.go | inferCell | func inferCell(s string) *table.Cell {
if n, err := node.Parse(s); err == nil {
return &table.Cell{N: n}
}
if p, err := predicate.Parse(s); err == nil {
return &table.Cell{P: p}
}
if l, err := literal.DefaultBuilder().Parse(s); err == nil {
return &table.Cell{L: l}
}
t, err := time.Parse(time.RFC3339Nano, ... | go | func inferCell(s string) *table.Cell {
if n, err := node.Parse(s); err == nil {
return &table.Cell{N: n}
}
if p, err := predicate.Parse(s); err == nil {
return &table.Cell{P: p}
}
if l, err := literal.DefaultBuilder().Parse(s); err == nil {
return &table.Cell{L: l}
}
t, err := time.Parse(time.RFC3339Nano, ... | [
"func",
"inferCell",
"(",
"s",
"string",
")",
"*",
"table",
".",
"Cell",
"{",
"if",
"n",
",",
"err",
":=",
"node",
".",
"Parse",
"(",
"s",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"&",
"table",
".",
"Cell",
"{",
"N",
":",
"n",
"}",
"\n",
... | // inferCell builds a Cell out of the provided string. | [
"inferCell",
"builds",
"a",
"Cell",
"out",
"of",
"the",
"provided",
"string",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/entry.go#L99-L114 |
12,578 | google/badwolf | tools/compliance/entry.go | OutputTable | func (a *Assertion) OutputTable(bo []string) (*table.Table, error) {
// Return the already computed output table.
if a.table != nil {
return a.table, nil
}
// Compute the output table.
var (
first bool
mBdngs map[string]bool
data []table.Row
bs []string
)
mBdngs, first = make(map[string]bool), t... | go | func (a *Assertion) OutputTable(bo []string) (*table.Table, error) {
// Return the already computed output table.
if a.table != nil {
return a.table, nil
}
// Compute the output table.
var (
first bool
mBdngs map[string]bool
data []table.Row
bs []string
)
mBdngs, first = make(map[string]bool), t... | [
"func",
"(",
"a",
"*",
"Assertion",
")",
"OutputTable",
"(",
"bo",
"[",
"]",
"string",
")",
"(",
"*",
"table",
".",
"Table",
",",
"error",
")",
"{",
"// Return the already computed output table.",
"if",
"a",
".",
"table",
"!=",
"nil",
"{",
"return",
"a",... | // OutputTable returns the expected result table for the must result table
// provided by the story. | [
"OutputTable",
"returns",
"the",
"expected",
"result",
"table",
"for",
"the",
"must",
"result",
"table",
"provided",
"by",
"the",
"story",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/compliance/entry.go#L118-L168 |
12,579 | google/badwolf | bql/planner/data_access.go | updateTimeBounds | func updateTimeBounds(lo *storage.LookupOptions, cls *semantic.GraphClause) *storage.LookupOptions {
nlo := &storage.LookupOptions{
MaxElements: lo.MaxElements,
LowerAnchor: lo.LowerAnchor,
UpperAnchor: lo.UpperAnchor,
}
if cls.PLowerBound != nil {
if lo.LowerAnchor == nil || (lo.LowerAnchor != nil && cls.PL... | go | func updateTimeBounds(lo *storage.LookupOptions, cls *semantic.GraphClause) *storage.LookupOptions {
nlo := &storage.LookupOptions{
MaxElements: lo.MaxElements,
LowerAnchor: lo.LowerAnchor,
UpperAnchor: lo.UpperAnchor,
}
if cls.PLowerBound != nil {
if lo.LowerAnchor == nil || (lo.LowerAnchor != nil && cls.PL... | [
"func",
"updateTimeBounds",
"(",
"lo",
"*",
"storage",
".",
"LookupOptions",
",",
"cls",
"*",
"semantic",
".",
"GraphClause",
")",
"*",
"storage",
".",
"LookupOptions",
"{",
"nlo",
":=",
"&",
"storage",
".",
"LookupOptions",
"{",
"MaxElements",
":",
"lo",
... | // updateTimeBounds updates the time bounds use for the lookup based on the
// provided graph clause. | [
"updateTimeBounds",
"updates",
"the",
"time",
"bounds",
"use",
"for",
"the",
"lookup",
"based",
"on",
"the",
"provided",
"graph",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/data_access.go#L35-L52 |
12,580 | google/badwolf | bql/planner/data_access.go | updateTimeBoundsForRow | func updateTimeBoundsForRow(lo *storage.LookupOptions, cls *semantic.GraphClause, r table.Row) (*storage.LookupOptions, error) {
lo = updateTimeBounds(lo, cls)
if cls.PLowerBoundAlias != "" {
v, ok := r[cls.PLowerBoundAlias]
if ok && v.T == nil {
return nil, fmt.Errorf("invalid time anchor value %v for bound %... | go | func updateTimeBoundsForRow(lo *storage.LookupOptions, cls *semantic.GraphClause, r table.Row) (*storage.LookupOptions, error) {
lo = updateTimeBounds(lo, cls)
if cls.PLowerBoundAlias != "" {
v, ok := r[cls.PLowerBoundAlias]
if ok && v.T == nil {
return nil, fmt.Errorf("invalid time anchor value %v for bound %... | [
"func",
"updateTimeBoundsForRow",
"(",
"lo",
"*",
"storage",
".",
"LookupOptions",
",",
"cls",
"*",
"semantic",
".",
"GraphClause",
",",
"r",
"table",
".",
"Row",
")",
"(",
"*",
"storage",
".",
"LookupOptions",
",",
"error",
")",
"{",
"lo",
"=",
"updateT... | // updateTimeBoundsForRow updates the time bounds use for the lookup based on
// the provided graph clause. | [
"updateTimeBoundsForRow",
"updates",
"the",
"time",
"bounds",
"use",
"for",
"the",
"lookup",
"based",
"on",
"the",
"provided",
"graph",
"clause",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/data_access.go#L56-L78 |
12,581 | google/badwolf | bql/planner/data_access.go | simpleExist | func simpleExist(ctx context.Context, gs []storage.Graph, cls *semantic.GraphClause, t *triple.Triple) (bool, *table.Table, error) {
unfeasible := true
tbl, err := table.New(cls.Bindings())
if err != nil {
return true, nil, err
}
for _, g := range gs {
b, err := g.Exist(ctx, t)
if err != nil {
return true... | go | func simpleExist(ctx context.Context, gs []storage.Graph, cls *semantic.GraphClause, t *triple.Triple) (bool, *table.Table, error) {
unfeasible := true
tbl, err := table.New(cls.Bindings())
if err != nil {
return true, nil, err
}
for _, g := range gs {
b, err := g.Exist(ctx, t)
if err != nil {
return true... | [
"func",
"simpleExist",
"(",
"ctx",
"context",
".",
"Context",
",",
"gs",
"[",
"]",
"storage",
".",
"Graph",
",",
"cls",
"*",
"semantic",
".",
"GraphClause",
",",
"t",
"*",
"triple",
".",
"Triple",
")",
"(",
"bool",
",",
"*",
"table",
".",
"Table",
... | // simpleExist returns true if the triple exist. Return the unfeasible state,
// the table and the error if present. | [
"simpleExist",
"returns",
"true",
"if",
"the",
"triple",
"exist",
".",
"Return",
"the",
"unfeasible",
"state",
"the",
"table",
"and",
"the",
"error",
"if",
"present",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/data_access.go#L82-L104 |
12,582 | google/badwolf | bql/planner/data_access.go | addTriples | func addTriples(ts <-chan *triple.Triple, cls *semantic.GraphClause, tbl *table.Table) error {
for t := range ts {
if cls.PID != "" {
// The triples need to be filtered.
if string(t.Predicate().ID()) != cls.PID {
continue
}
if cls.PTemporal {
if t.Predicate().Type() != predicate.Temporal {
c... | go | func addTriples(ts <-chan *triple.Triple, cls *semantic.GraphClause, tbl *table.Table) error {
for t := range ts {
if cls.PID != "" {
// The triples need to be filtered.
if string(t.Predicate().ID()) != cls.PID {
continue
}
if cls.PTemporal {
if t.Predicate().Type() != predicate.Temporal {
c... | [
"func",
"addTriples",
"(",
"ts",
"<-",
"chan",
"*",
"triple",
".",
"Triple",
",",
"cls",
"*",
"semantic",
".",
"GraphClause",
",",
"tbl",
"*",
"table",
".",
"Table",
")",
"error",
"{",
"for",
"t",
":=",
"range",
"ts",
"{",
"if",
"cls",
".",
"PID",
... | // addTriples add all the retrieved triples from the graphs into the results
// table. The semantic graph clause is also passed to be able to identify what
// bindings to set. | [
"addTriples",
"add",
"all",
"the",
"retrieved",
"triples",
"from",
"the",
"graphs",
"into",
"the",
"results",
"table",
".",
"The",
"semantic",
"graph",
"clause",
"is",
"also",
"passed",
"to",
"be",
"able",
"to",
"identify",
"what",
"bindings",
"to",
"set",
... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/data_access.go#L411-L468 |
12,583 | google/badwolf | bql/planner/data_access.go | objectToCell | func objectToCell(o *triple.Object) (*table.Cell, error) {
c := &table.Cell{}
if n, err := o.Node(); err == nil {
c.N = n
return c, nil
}
if p, err := o.Predicate(); err == nil {
c.P = p
return c, nil
}
if l, err := o.Literal(); err == nil {
c.L = l
return c, nil
}
return nil, fmt.Errorf("unknown ob... | go | func objectToCell(o *triple.Object) (*table.Cell, error) {
c := &table.Cell{}
if n, err := o.Node(); err == nil {
c.N = n
return c, nil
}
if p, err := o.Predicate(); err == nil {
c.P = p
return c, nil
}
if l, err := o.Literal(); err == nil {
c.L = l
return c, nil
}
return nil, fmt.Errorf("unknown ob... | [
"func",
"objectToCell",
"(",
"o",
"*",
"triple",
".",
"Object",
")",
"(",
"*",
"table",
".",
"Cell",
",",
"error",
")",
"{",
"c",
":=",
"&",
"table",
".",
"Cell",
"{",
"}",
"\n",
"if",
"n",
",",
"err",
":=",
"o",
".",
"Node",
"(",
")",
";",
... | // objectToCell returns a cell containing the data boxed in the object. | [
"objectToCell",
"returns",
"a",
"cell",
"containing",
"the",
"data",
"boxed",
"in",
"the",
"object",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/planner/data_access.go#L471-L486 |
12,584 | google/badwolf | tools/vcli/bw/benchmark/benchmark.go | runAll | func runAll(ctx context.Context, st storage.Store, chanSize, bulkSize int) int {
// - Add non existing triples. (done)
// - Add triples that already exist. (done)
// - Remove non existing triples. (done)
// - Remove existing triples. (done)
// - BQL tree walking from root. (done)... | go | func runAll(ctx context.Context, st storage.Store, chanSize, bulkSize int) int {
// - Add non existing triples. (done)
// - Add triples that already exist. (done)
// - Remove non existing triples. (done)
// - Remove existing triples. (done)
// - BQL tree walking from root. (done)... | [
"func",
"runAll",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"int",
"{",
"// - Add non existing triples. (done)",
"// - Add triples that already exist. (done)",
"// - Remove non ex... | // runAll executes all the canned benchmarks and prints out the stats. | [
"runAll",
"executes",
"all",
"the",
"canned",
"benchmarks",
"and",
"prints",
"out",
"the",
"stats",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/benchmark/benchmark.go#L48-L83 |
12,585 | google/badwolf | tools/vcli/bw/benchmark/benchmark.go | runBattery | func runBattery(ctx context.Context, st storage.Store, name string, chanSize, bulkSize int, f func(context.Context, storage.Store, int, int) ([]*runtime.BenchEntry, error)) int {
// Add triples.
fmt.Printf("Creating %s triples benchmark... ", name)
bes, err := f(ctx, st, chanSize, bulkSize)
if err != nil {
log.Pr... | go | func runBattery(ctx context.Context, st storage.Store, name string, chanSize, bulkSize int, f func(context.Context, storage.Store, int, int) ([]*runtime.BenchEntry, error)) int {
// Add triples.
fmt.Printf("Creating %s triples benchmark... ", name)
bes, err := f(ctx, st, chanSize, bulkSize)
if err != nil {
log.Pr... | [
"func",
"runBattery",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"name",
"string",
",",
"chanSize",
",",
"bulkSize",
"int",
",",
"f",
"func",
"(",
"context",
".",
"Context",
",",
"storage",
".",
"Store",
",",
"int",... | // runBattery executes all the canned benchmarks and prints out the stats. | [
"runBattery",
"executes",
"all",
"the",
"canned",
"benchmarks",
"and",
"prints",
"out",
"the",
"stats",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/benchmark/benchmark.go#L86-L140 |
12,586 | google/badwolf | tools/vcli/bw/io/io.go | GetStatementsFromFile | func GetStatementsFromFile(path string) ([]string, error) {
stms, err := ReadLines(path)
if err != nil {
return nil, err
}
return stms, nil
} | go | func GetStatementsFromFile(path string) ([]string, error) {
stms, err := ReadLines(path)
if err != nil {
return nil, err
}
return stms, nil
} | [
"func",
"GetStatementsFromFile",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"stms",
",",
"err",
":=",
"ReadLines",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n"... | // GetStatementsFromFile returns the statements found in the provided file. | [
"GetStatementsFromFile",
"returns",
"the",
"statements",
"found",
"in",
"the",
"provided",
"file",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/io/io.go#L26-L32 |
12,587 | google/badwolf | tools/vcli/bw/io/io.go | ReadLines | func ReadLines(path string) ([]string, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
var lines []string
scanner := bufio.NewScanner(f)
line := ""
for scanner.Scan() {
l := strings.TrimSpace(scanner.Text())
if len(l) == 0 || strings.Index(l, "#") == 0 {
continue
}... | go | func ReadLines(path string) ([]string, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
var lines []string
scanner := bufio.NewScanner(f)
line := ""
for scanner.Scan() {
l := strings.TrimSpace(scanner.Text())
if len(l) == 0 || strings.Index(l, "#") == 0 {
continue
}... | [
"func",
"ReadLines",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"... | // ReadLines from a file into a string array. | [
"ReadLines",
"from",
"a",
"file",
"into",
"a",
"string",
"array",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/io/io.go#L35-L60 |
12,588 | google/badwolf | tools/vcli/bw/io/io.go | ProcessLines | func ProcessLines(path string, fp func(line string) error) (int, error) {
f, err := os.Open(path)
if err != nil {
return 0, err
}
defer f.Close()
scanner := bufio.NewScanner(f)
cnt := 0
for scanner.Scan() {
l := strings.TrimSpace(scanner.Text())
cnt++
if len(l) == 0 || strings.Index(l, "#") == 0 {
co... | go | func ProcessLines(path string, fp func(line string) error) (int, error) {
f, err := os.Open(path)
if err != nil {
return 0, err
}
defer f.Close()
scanner := bufio.NewScanner(f)
cnt := 0
for scanner.Scan() {
l := strings.TrimSpace(scanner.Text())
cnt++
if len(l) == 0 || strings.Index(l, "#") == 0 {
co... | [
"func",
"ProcessLines",
"(",
"path",
"string",
",",
"fp",
"func",
"(",
"line",
"string",
")",
"error",
")",
"(",
"int",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // ProcessLines from a file using the provided call back. The error of the
// callback will be passed through. Returns the number of processed errors
// before the error. Returns the line where the error occurred or the total
// numbers of lines processed. | [
"ProcessLines",
"from",
"a",
"file",
"using",
"the",
"provided",
"call",
"back",
".",
"The",
"error",
"of",
"the",
"callback",
"will",
"be",
"passed",
"through",
".",
"Returns",
"the",
"number",
"of",
"processed",
"errors",
"before",
"the",
"error",
".",
"... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/io/io.go#L66-L86 |
12,589 | google/badwolf | io/io.go | ReadIntoGraph | func ReadIntoGraph(ctx context.Context, g storage.Graph, r io.Reader, b literal.Builder) (int, error) {
cnt, scanner := 0, bufio.NewScanner(r)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
text := strings.TrimSpace(scanner.Text())
if text == "" {
continue
}
t, err := triple.Parse(text, b)
if err !... | go | func ReadIntoGraph(ctx context.Context, g storage.Graph, r io.Reader, b literal.Builder) (int, error) {
cnt, scanner := 0, bufio.NewScanner(r)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
text := strings.TrimSpace(scanner.Text())
if text == "" {
continue
}
t, err := triple.Parse(text, b)
if err !... | [
"func",
"ReadIntoGraph",
"(",
"ctx",
"context",
".",
"Context",
",",
"g",
"storage",
".",
"Graph",
",",
"r",
"io",
".",
"Reader",
",",
"b",
"literal",
".",
"Builder",
")",
"(",
"int",
",",
"error",
")",
"{",
"cnt",
",",
"scanner",
":=",
"0",
",",
... | // ReadIntoGraph reads a graph out of the provided reader. The data on the
// reader is interpret as text. Each line represents one triple using the
// standard serialized format. ReadIntoGraph will stop if fails to Parse
// a triple on the stream. The triples read till then would have also been
// added to the graph. ... | [
"ReadIntoGraph",
"reads",
"a",
"graph",
"out",
"of",
"the",
"provided",
"reader",
".",
"The",
"data",
"on",
"the",
"reader",
"is",
"interpret",
"as",
"text",
".",
"Each",
"line",
"represents",
"one",
"triple",
"using",
"the",
"standard",
"serialized",
"forma... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/io/io.go#L36-L52 |
12,590 | google/badwolf | io/io.go | WriteGraph | func WriteGraph(ctx context.Context, w io.Writer, g storage.Graph) (int, error) {
var (
wg sync.WaitGroup
tErr error
wErr error
)
cnt, ts := 0, make(chan *triple.Triple)
wg.Add(1)
go func() {
defer wg.Done()
tErr = g.Triples(ctx, storage.DefaultLookup, ts)
}()
for t := range ts {
if wErr != nil {
... | go | func WriteGraph(ctx context.Context, w io.Writer, g storage.Graph) (int, error) {
var (
wg sync.WaitGroup
tErr error
wErr error
)
cnt, ts := 0, make(chan *triple.Triple)
wg.Add(1)
go func() {
defer wg.Done()
tErr = g.Triples(ctx, storage.DefaultLookup, ts)
}()
for t := range ts {
if wErr != nil {
... | [
"func",
"WriteGraph",
"(",
"ctx",
"context",
".",
"Context",
",",
"w",
"io",
".",
"Writer",
",",
"g",
"storage",
".",
"Graph",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"(",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"tErr",
"error",
"\n",
"wErr",... | // WriteGraph serializes the graph into the writer where each triple is
// marshaled into a separate line. If there is an error writing the
// serialization will stop. It returns the number of triples serialized
// regardless if it succeeded or failed partially. | [
"WriteGraph",
"serializes",
"the",
"graph",
"into",
"the",
"writer",
"where",
"each",
"triple",
"is",
"marshaled",
"into",
"a",
"separate",
"line",
".",
"If",
"there",
"is",
"an",
"error",
"writing",
"the",
"serialization",
"will",
"stop",
".",
"It",
"return... | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/io/io.go#L58-L88 |
12,591 | google/badwolf | tools/benchmark/batteries/add.go | AddGraphTriplesBenchmark | func AddGraphTriplesBenchmark(ctx context.Context, st storage.Store, chanSize, bulkSize int) ([]*runtime.BenchEntry, error) {
nodes := []int{317, 1000}
sizes := []int{10, 1000, 100000}
var trplSets [][]*triple.Triple
var ids []string
var gids []string
var gSizes []int
gs, err := getGraphGenerators(nodes)
if err... | go | func AddGraphTriplesBenchmark(ctx context.Context, st storage.Store, chanSize, bulkSize int) ([]*runtime.BenchEntry, error) {
nodes := []int{317, 1000}
sizes := []int{10, 1000, 100000}
var trplSets [][]*triple.Triple
var ids []string
var gids []string
var gSizes []int
gs, err := getGraphGenerators(nodes)
if err... | [
"func",
"AddGraphTriplesBenchmark",
"(",
"ctx",
"context",
".",
"Context",
",",
"st",
"storage",
".",
"Store",
",",
"chanSize",
",",
"bulkSize",
"int",
")",
"(",
"[",
"]",
"*",
"runtime",
".",
"BenchEntry",
",",
"error",
")",
"{",
"nodes",
":=",
"[",
"... | // AddGraphTriplesBenchmark creates the benchmark. | [
"AddGraphTriplesBenchmark",
"creates",
"the",
"benchmark",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/benchmark/batteries/add.go#L137-L187 |
12,592 | google/badwolf | tools/vcli/bw/main.go | registerDrivers | func registerDrivers() {
registeredDrivers = map[string]common.StoreGenerator{
// Memory only storage driver.
"VOLATILE": func() (storage.Store, error) {
return memory.NewStore(), nil
},
}
} | go | func registerDrivers() {
registeredDrivers = map[string]common.StoreGenerator{
// Memory only storage driver.
"VOLATILE": func() (storage.Store, error) {
return memory.NewStore(), nil
},
}
} | [
"func",
"registerDrivers",
"(",
")",
"{",
"registeredDrivers",
"=",
"map",
"[",
"string",
"]",
"common",
".",
"StoreGenerator",
"{",
"// Memory only storage driver.",
"\"",
"\"",
":",
"func",
"(",
")",
"(",
"storage",
".",
"Store",
",",
"error",
")",
"{",
... | // Registers the available drivers. | [
"Registers",
"the",
"available",
"drivers",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/tools/vcli/bw/main.go#L46-L53 |
12,593 | google/badwolf | bql/lexer/lexer.go | lex | func lex(input string, capacity int) (*lexer, <-chan Token) {
l := &lexer{
input: input,
tokens: make(chan Token, capacity),
}
go l.run() // Concurrently run state machine.
return l, l.tokens
} | go | func lex(input string, capacity int) (*lexer, <-chan Token) {
l := &lexer{
input: input,
tokens: make(chan Token, capacity),
}
go l.run() // Concurrently run state machine.
return l, l.tokens
} | [
"func",
"lex",
"(",
"input",
"string",
",",
"capacity",
"int",
")",
"(",
"*",
"lexer",
",",
"<-",
"chan",
"Token",
")",
"{",
"l",
":=",
"&",
"lexer",
"{",
"input",
":",
"input",
",",
"tokens",
":",
"make",
"(",
"chan",
"Token",
",",
"capacity",
"... | // lex creates a new lexer for the given input | [
"lex",
"creates",
"a",
"new",
"lexer",
"for",
"the",
"given",
"input"
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L350-L357 |
12,594 | google/badwolf | bql/lexer/lexer.go | New | func New(input string, capacity int) <-chan Token {
if capacity < 0 {
capacity = 0
}
_, c := lex(input, capacity)
return c
} | go | func New(input string, capacity int) <-chan Token {
if capacity < 0 {
capacity = 0
}
_, c := lex(input, capacity)
return c
} | [
"func",
"New",
"(",
"input",
"string",
",",
"capacity",
"int",
")",
"<-",
"chan",
"Token",
"{",
"if",
"capacity",
"<",
"0",
"{",
"capacity",
"=",
"0",
"\n",
"}",
"\n",
"_",
",",
"c",
":=",
"lex",
"(",
"input",
",",
"capacity",
")",
"\n",
"return"... | // New return a new read only channel with the tokens found in the provided
// input string. | [
"New",
"return",
"a",
"new",
"read",
"only",
"channel",
"with",
"the",
"tokens",
"found",
"in",
"the",
"provided",
"input",
"string",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L361-L367 |
12,595 | google/badwolf | bql/lexer/lexer.go | lexToken | func lexToken(l *lexer) stateFn {
for {
{
r := l.peek()
switch r {
case binding:
l.next()
return lexBinding
case slash:
return lexNode
case underscore:
l.next()
return lexBlankNode
case quote:
return lexPredicateOrLiteral
}
if unicode.IsLetter(r) {
return lexKeywor... | go | func lexToken(l *lexer) stateFn {
for {
{
r := l.peek()
switch r {
case binding:
l.next()
return lexBinding
case slash:
return lexNode
case underscore:
l.next()
return lexBlankNode
case quote:
return lexPredicateOrLiteral
}
if unicode.IsLetter(r) {
return lexKeywor... | [
"func",
"lexToken",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"for",
"{",
"{",
"r",
":=",
"l",
".",
"peek",
"(",
")",
"\n",
"switch",
"r",
"{",
"case",
"binding",
":",
"l",
".",
"next",
"(",
")",
"\n",
"return",
"lexBinding",
"\n",
"case",
"... | // lexToken represents the initial state for token identification. | [
"lexToken",
"represents",
"the",
"initial",
"state",
"for",
"token",
"identification",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L370-L433 |
12,596 | google/badwolf | bql/lexer/lexer.go | isSingleSymbolToken | func isSingleSymbolToken(l *lexer, tt TokenType, symbol rune) stateFn {
if r := l.peek(); r == symbol {
l.next()
l.emit(tt)
return lexSpace // Next state.
}
return nil
} | go | func isSingleSymbolToken(l *lexer, tt TokenType, symbol rune) stateFn {
if r := l.peek(); r == symbol {
l.next()
l.emit(tt)
return lexSpace // Next state.
}
return nil
} | [
"func",
"isSingleSymbolToken",
"(",
"l",
"*",
"lexer",
",",
"tt",
"TokenType",
",",
"symbol",
"rune",
")",
"stateFn",
"{",
"if",
"r",
":=",
"l",
".",
"peek",
"(",
")",
";",
"r",
"==",
"symbol",
"{",
"l",
".",
"next",
"(",
")",
"\n",
"l",
".",
"... | // isSingleSymbolToken checks if a single char should be lexed. | [
"isSingleSymbolToken",
"checks",
"if",
"a",
"single",
"char",
"should",
"be",
"lexed",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L436-L443 |
12,597 | google/badwolf | bql/lexer/lexer.go | lexBinding | func lexBinding(l *lexer) stateFn {
for {
if r := l.next(); !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != rune('_') || r == eof {
l.backup()
l.emit(ItemBinding)
break
}
}
return lexSpace
} | go | func lexBinding(l *lexer) stateFn {
for {
if r := l.next(); !unicode.IsLetter(r) && !unicode.IsDigit(r) && r != rune('_') || r == eof {
l.backup()
l.emit(ItemBinding)
break
}
}
return lexSpace
} | [
"func",
"lexBinding",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"for",
"{",
"if",
"r",
":=",
"l",
".",
"next",
"(",
")",
";",
"!",
"unicode",
".",
"IsLetter",
"(",
"r",
")",
"&&",
"!",
"unicode",
".",
"IsDigit",
"(",
"r",
")",
"&&",
"r",
"... | // lexBinding lexes a binding variable. | [
"lexBinding",
"lexes",
"a",
"binding",
"variable",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L446-L455 |
12,598 | google/badwolf | bql/lexer/lexer.go | lexSpace | func lexSpace(l *lexer) stateFn {
for {
if r := l.next(); !unicode.IsSpace(r) || r == eof {
break
}
}
l.backup()
l.ignore()
return lexToken
} | go | func lexSpace(l *lexer) stateFn {
for {
if r := l.next(); !unicode.IsSpace(r) || r == eof {
break
}
}
l.backup()
l.ignore()
return lexToken
} | [
"func",
"lexSpace",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"for",
"{",
"if",
"r",
":=",
"l",
".",
"next",
"(",
")",
";",
"!",
"unicode",
".",
"IsSpace",
"(",
"r",
")",
"||",
"r",
"==",
"eof",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n",
... | // lexSpace consumes spaces without emitting any token. | [
"lexSpace",
"consumes",
"spaces",
"without",
"emitting",
"any",
"token",
"."
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L458-L467 |
12,599 | google/badwolf | bql/lexer/lexer.go | lexBlankNode | func lexBlankNode(l *lexer) stateFn {
if r := l.next(); r != colon {
l.emitError("blank node should start with _:")
return nil
}
if r := l.next(); !unicode.IsLetter(r) {
l.emitError("blank node label should begin with a letter")
return nil
}
for {
if r := l.next(); !unicode.IsLetter(r) && !unicode.IsDigi... | go | func lexBlankNode(l *lexer) stateFn {
if r := l.next(); r != colon {
l.emitError("blank node should start with _:")
return nil
}
if r := l.next(); !unicode.IsLetter(r) {
l.emitError("blank node label should begin with a letter")
return nil
}
for {
if r := l.next(); !unicode.IsLetter(r) && !unicode.IsDigi... | [
"func",
"lexBlankNode",
"(",
"l",
"*",
"lexer",
")",
"stateFn",
"{",
"if",
"r",
":=",
"l",
".",
"next",
"(",
")",
";",
"r",
"!=",
"colon",
"{",
"l",
".",
"emitError",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"r",
":... | // lexBlankNode tries to lex a blank node out of the input | [
"lexBlankNode",
"tries",
"to",
"lex",
"a",
"blank",
"node",
"out",
"of",
"the",
"input"
] | f6c3103546450641440a719b2ed52cc74bae6237 | https://github.com/google/badwolf/blob/f6c3103546450641440a719b2ed52cc74bae6237/bql/lexer/lexer.go#L656-L673 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.