repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1 value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rethinkdb/rethinkdb-go | rethinkdb.go | SetVerbose | func SetVerbose(verbose bool) {
if verbose {
Log.Level = logrus.DebugLevel
return
}
Log.Level = logrus.InfoLevel
} | go | func SetVerbose(verbose bool) {
if verbose {
Log.Level = logrus.DebugLevel
return
}
Log.Level = logrus.InfoLevel
} | [
"func",
"SetVerbose",
"(",
"verbose",
"bool",
")",
"{",
"if",
"verbose",
"{",
"Log",
".",
"Level",
"=",
"logrus",
".",
"DebugLevel",
"\n",
"return",
"\n",
"}",
"\n\n",
"Log",
".",
"Level",
"=",
"logrus",
".",
"InfoLevel",
"\n",
"}"
] | // SetVerbose allows the driver logging level to be set. If true is passed then
// the log level is set to Debug otherwise it defaults to Info. | [
"SetVerbose",
"allows",
"the",
"driver",
"logging",
"level",
"to",
"be",
"set",
".",
"If",
"true",
"is",
"passed",
"then",
"the",
"log",
"level",
"is",
"set",
"to",
"Debug",
"otherwise",
"it",
"defaults",
"to",
"Info",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/rethinkdb.go#L43-L50 | train |
rethinkdb/rethinkdb-go | query.go | Build | func (t Term) Build() (interface{}, error) {
var err error
if t.lastErr != nil {
return nil, t.lastErr
}
if t.rawQuery {
return t.data, nil
}
switch t.termType {
case p.Term_DATUM:
return t.data, nil
case p.Term_MAKE_OBJ:
res := map[string]interface{}{}
for k, v := range t.optArgs {
res[k], err = v.Build()
if err != nil {
return nil, err
}
}
return res, nil
case p.Term_BINARY:
if len(t.args) == 0 {
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": t.data,
}, nil
}
}
args := make([]interface{}, len(t.args))
optArgs := make(map[string]interface{}, len(t.optArgs))
for i, v := range t.args {
arg, err := v.Build()
if err != nil {
return nil, err
}
args[i] = arg
}
for k, v := range t.optArgs {
optArgs[k], err = v.Build()
if err != nil {
return nil, err
}
}
ret := []interface{}{int(t.termType)}
if len(args) > 0 {
ret = append(ret, args)
}
if len(optArgs) > 0 {
ret = append(ret, optArgs)
}
return ret, nil
} | go | func (t Term) Build() (interface{}, error) {
var err error
if t.lastErr != nil {
return nil, t.lastErr
}
if t.rawQuery {
return t.data, nil
}
switch t.termType {
case p.Term_DATUM:
return t.data, nil
case p.Term_MAKE_OBJ:
res := map[string]interface{}{}
for k, v := range t.optArgs {
res[k], err = v.Build()
if err != nil {
return nil, err
}
}
return res, nil
case p.Term_BINARY:
if len(t.args) == 0 {
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": t.data,
}, nil
}
}
args := make([]interface{}, len(t.args))
optArgs := make(map[string]interface{}, len(t.optArgs))
for i, v := range t.args {
arg, err := v.Build()
if err != nil {
return nil, err
}
args[i] = arg
}
for k, v := range t.optArgs {
optArgs[k], err = v.Build()
if err != nil {
return nil, err
}
}
ret := []interface{}{int(t.termType)}
if len(args) > 0 {
ret = append(ret, args)
}
if len(optArgs) > 0 {
ret = append(ret, optArgs)
}
return ret, nil
} | [
"func",
"(",
"t",
"Term",
")",
"Build",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"if",
"t",
".",
"lastErr",
"!=",
"nil",
"{",
"return",
"nil",
",",
"t",
".",
"lastErr",
"\n",
"}",
"\n\n",
"if"... | // build takes the query tree and prepares it to be sent as a JSON
// expression | [
"build",
"takes",
"the",
"query",
"tree",
"and",
"prepares",
"it",
"to",
"be",
"sent",
"as",
"a",
"JSON",
"expression"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L128-L188 | train |
rethinkdb/rethinkdb-go | query.go | String | func (t Term) String() string {
if t.isMockAnything {
return "r.MockAnything()"
}
switch t.termType {
case p.Term_MAKE_ARRAY:
return fmt.Sprintf("[%s]", strings.Join(argsToStringSlice(t.args), ", "))
case p.Term_MAKE_OBJ:
return fmt.Sprintf("{%s}", strings.Join(optArgsToStringSlice(t.optArgs), ", "))
case p.Term_FUNC:
// Get string representation of each argument
args := []string{}
for _, v := range t.args[0].args {
args = append(args, fmt.Sprintf("var_%d", v.data))
}
return fmt.Sprintf("func(%s r.Term) r.Term { return %s }",
strings.Join(args, ", "),
t.args[1].String(),
)
case p.Term_VAR:
return fmt.Sprintf("var_%s", t.args[0])
case p.Term_IMPLICIT_VAR:
return "r.Row"
case p.Term_DATUM:
switch v := t.data.(type) {
case string:
return strconv.Quote(v)
default:
return fmt.Sprintf("%v", v)
}
case p.Term_BINARY:
if len(t.args) == 0 {
return fmt.Sprintf("r.binary(<data>)")
}
}
if t.rootTerm {
return fmt.Sprintf("r.%s(%s)", t.name, strings.Join(allArgsToStringSlice(t.args, t.optArgs), ", "))
}
if t.args == nil {
return "r"
}
return fmt.Sprintf("%s.%s(%s)", t.args[0].String(), t.name, strings.Join(allArgsToStringSlice(t.args[1:], t.optArgs), ", "))
} | go | func (t Term) String() string {
if t.isMockAnything {
return "r.MockAnything()"
}
switch t.termType {
case p.Term_MAKE_ARRAY:
return fmt.Sprintf("[%s]", strings.Join(argsToStringSlice(t.args), ", "))
case p.Term_MAKE_OBJ:
return fmt.Sprintf("{%s}", strings.Join(optArgsToStringSlice(t.optArgs), ", "))
case p.Term_FUNC:
// Get string representation of each argument
args := []string{}
for _, v := range t.args[0].args {
args = append(args, fmt.Sprintf("var_%d", v.data))
}
return fmt.Sprintf("func(%s r.Term) r.Term { return %s }",
strings.Join(args, ", "),
t.args[1].String(),
)
case p.Term_VAR:
return fmt.Sprintf("var_%s", t.args[0])
case p.Term_IMPLICIT_VAR:
return "r.Row"
case p.Term_DATUM:
switch v := t.data.(type) {
case string:
return strconv.Quote(v)
default:
return fmt.Sprintf("%v", v)
}
case p.Term_BINARY:
if len(t.args) == 0 {
return fmt.Sprintf("r.binary(<data>)")
}
}
if t.rootTerm {
return fmt.Sprintf("r.%s(%s)", t.name, strings.Join(allArgsToStringSlice(t.args, t.optArgs), ", "))
}
if t.args == nil {
return "r"
}
return fmt.Sprintf("%s.%s(%s)", t.args[0].String(), t.name, strings.Join(allArgsToStringSlice(t.args[1:], t.optArgs), ", "))
} | [
"func",
"(",
"t",
"Term",
")",
"String",
"(",
")",
"string",
"{",
"if",
"t",
".",
"isMockAnything",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"switch",
"t",
".",
"termType",
"{",
"case",
"p",
".",
"Term_MAKE_ARRAY",
":",
"return",
"fmt",
".",
"... | // String returns a string representation of the query tree | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"the",
"query",
"tree"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L191-L238 | train |
rethinkdb/rethinkdb-go | query.go | ReadOne | func (t Term) ReadOne(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.One(dest)
} | go | func (t Term) ReadOne(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.One(dest)
} | [
"func",
"(",
"t",
"Term",
")",
"ReadOne",
"(",
"dest",
"interface",
"{",
"}",
",",
"s",
"QueryExecutor",
",",
"optArgs",
"...",
"RunOpts",
")",
"error",
"{",
"res",
",",
"err",
":=",
"t",
".",
"Run",
"(",
"s",
",",
"optArgs",
"...",
")",
"\n",
"i... | // ReadOne is a shortcut method that runs the query on the given connection
// and reads one response from the cursor before closing it.
//
// It returns any errors encountered from running the query or reading the response | [
"ReadOne",
"is",
"a",
"shortcut",
"method",
"that",
"runs",
"the",
"query",
"on",
"the",
"given",
"connection",
"and",
"reads",
"one",
"response",
"from",
"the",
"cursor",
"before",
"closing",
"it",
".",
"It",
"returns",
"any",
"errors",
"encountered",
"from... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L387-L393 | train |
rethinkdb/rethinkdb-go | query.go | ReadAll | func (t Term) ReadAll(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.All(dest)
} | go | func (t Term) ReadAll(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.All(dest)
} | [
"func",
"(",
"t",
"Term",
")",
"ReadAll",
"(",
"dest",
"interface",
"{",
"}",
",",
"s",
"QueryExecutor",
",",
"optArgs",
"...",
"RunOpts",
")",
"error",
"{",
"res",
",",
"err",
":=",
"t",
".",
"Run",
"(",
"s",
",",
"optArgs",
"...",
")",
"\n",
"i... | // ReadAll is a shortcut method that runs the query on the given connection
// and reads all of the responses from the cursor before closing it.
//
// It returns any errors encountered from running the query or reading the responses | [
"ReadAll",
"is",
"a",
"shortcut",
"method",
"that",
"runs",
"the",
"query",
"on",
"the",
"given",
"connection",
"and",
"reads",
"all",
"of",
"the",
"responses",
"from",
"the",
"cursor",
"before",
"closing",
"it",
".",
"It",
"returns",
"any",
"errors",
"enc... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L399-L405 | train |
rethinkdb/rethinkdb-go | errors.go | IsConflictErr | func IsConflictErr(err error) bool {
if err == nil {
return false
}
return strings.HasPrefix(err.Error(), "Duplicate primary key")
} | go | func IsConflictErr(err error) bool {
if err == nil {
return false
}
return strings.HasPrefix(err.Error(), "Duplicate primary key")
} | [
"func",
"IsConflictErr",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"strings",
".",
"HasPrefix",
"(",
"err",
".",
"Error",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // Error type helpers
// IsConflictErr returns true if the error is non-nil and the query failed
// due to a duplicate primary key. | [
"Error",
"type",
"helpers",
"IsConflictErr",
"returns",
"true",
"if",
"the",
"error",
"is",
"non",
"-",
"nil",
"and",
"the",
"query",
"failed",
"due",
"to",
"a",
"duplicate",
"primary",
"key",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/errors.go#L176-L182 | train |
rethinkdb/rethinkdb-go | mock.go | MockAnything | func MockAnything() Term {
t := constructRootTerm("MockAnything", p.Term_DATUM, nil, nil)
t.isMockAnything = true
return t
} | go | func MockAnything() Term {
t := constructRootTerm("MockAnything", p.Term_DATUM, nil, nil)
t.isMockAnything = true
return t
} | [
"func",
"MockAnything",
"(",
")",
"Term",
"{",
"t",
":=",
"constructRootTerm",
"(",
"\"",
"\"",
",",
"p",
".",
"Term_DATUM",
",",
"nil",
",",
"nil",
")",
"\n",
"t",
".",
"isMockAnything",
"=",
"true",
"\n\n",
"return",
"t",
"\n",
"}"
] | // MockAnything can be used in place of any term, this is useful when you want
// mock similar queries or queries that you don't quite know the exact structure
// of. | [
"MockAnything",
"can",
"be",
"used",
"in",
"place",
"of",
"any",
"term",
"this",
"is",
"useful",
"when",
"you",
"want",
"mock",
"similar",
"queries",
"or",
"queries",
"that",
"you",
"don",
"t",
"quite",
"know",
"the",
"exact",
"structure",
"of",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L26-L31 | train |
rethinkdb/rethinkdb-go | mock.go | NewMock | func NewMock(opts ...ConnectOpts) *Mock {
m := &Mock{
ExpectedQueries: make([]*MockQuery, 0),
Queries: make([]MockQuery, 0),
}
if len(opts) > 0 {
m.opts = opts[0]
}
return m
} | go | func NewMock(opts ...ConnectOpts) *Mock {
m := &Mock{
ExpectedQueries: make([]*MockQuery, 0),
Queries: make([]MockQuery, 0),
}
if len(opts) > 0 {
m.opts = opts[0]
}
return m
} | [
"func",
"NewMock",
"(",
"opts",
"...",
"ConnectOpts",
")",
"*",
"Mock",
"{",
"m",
":=",
"&",
"Mock",
"{",
"ExpectedQueries",
":",
"make",
"(",
"[",
"]",
"*",
"MockQuery",
",",
"0",
")",
",",
"Queries",
":",
"make",
"(",
"[",
"]",
"MockQuery",
",",
... | // NewMock creates an instance of Mock, you can optionally pass ConnectOpts to
// the function, if passed any mocked query will be generated using those
// options. | [
"NewMock",
"creates",
"an",
"instance",
"of",
"Mock",
"you",
"can",
"optionally",
"pass",
"ConnectOpts",
"to",
"the",
"function",
"if",
"passed",
"any",
"mocked",
"query",
"will",
"be",
"generated",
"using",
"those",
"options",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L190-L201 | train |
rethinkdb/rethinkdb-go | mock.go | AssertExpectations | func (m *Mock) AssertExpectations(t testingT) bool {
var somethingMissing bool
var failedExpectations int
// iterate through each expectation
expectedQueries := m.expectedQueries()
for _, expectedQuery := range expectedQueries {
if !m.queryWasExecuted(expectedQuery) && expectedQuery.executed == 0 {
somethingMissing = true
failedExpectations++
t.Logf("❌\t%s", expectedQuery.Query.Term.String())
} else {
m.mu.Lock()
if expectedQuery.Repeatability > 0 {
somethingMissing = true
failedExpectations++
} else {
t.Logf("✅\t%s", expectedQuery.Query.Term.String())
}
m.mu.Unlock()
}
}
if somethingMissing {
t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe query you are testing needs to be executed %d more times(s).", len(expectedQueries)-failedExpectations, len(expectedQueries), failedExpectations)
}
return !somethingMissing
} | go | func (m *Mock) AssertExpectations(t testingT) bool {
var somethingMissing bool
var failedExpectations int
// iterate through each expectation
expectedQueries := m.expectedQueries()
for _, expectedQuery := range expectedQueries {
if !m.queryWasExecuted(expectedQuery) && expectedQuery.executed == 0 {
somethingMissing = true
failedExpectations++
t.Logf("❌\t%s", expectedQuery.Query.Term.String())
} else {
m.mu.Lock()
if expectedQuery.Repeatability > 0 {
somethingMissing = true
failedExpectations++
} else {
t.Logf("✅\t%s", expectedQuery.Query.Term.String())
}
m.mu.Unlock()
}
}
if somethingMissing {
t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe query you are testing needs to be executed %d more times(s).", len(expectedQueries)-failedExpectations, len(expectedQueries), failedExpectations)
}
return !somethingMissing
} | [
"func",
"(",
"m",
"*",
"Mock",
")",
"AssertExpectations",
"(",
"t",
"testingT",
")",
"bool",
"{",
"var",
"somethingMissing",
"bool",
"\n",
"var",
"failedExpectations",
"int",
"\n\n",
"// iterate through each expectation",
"expectedQueries",
":=",
"m",
".",
"expect... | // AssertExpectations asserts that everything specified with On and Return was
// in fact executed as expected. Queries may have been executed in any order. | [
"AssertExpectations",
"asserts",
"that",
"everything",
"specified",
"with",
"On",
"and",
"Return",
"was",
"in",
"fact",
"executed",
"as",
"expected",
".",
"Queries",
"may",
"have",
"been",
"executed",
"in",
"any",
"order",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L222-L250 | train |
rethinkdb/rethinkdb-go | mock.go | AssertNumberOfExecutions | func (m *Mock) AssertNumberOfExecutions(t testingT, expectedQuery *MockQuery, expectedExecutions int) bool {
var actualExecutions int
for _, query := range m.queries() {
if query.Query.Term.compare(*expectedQuery.Query.Term, map[int64]int64{}) && query.Repeatability > -1 {
// if bytes.Equal(query.BuiltQuery, expectedQuery.BuiltQuery) {
actualExecutions++
}
}
if expectedExecutions != actualExecutions {
t.Errorf("Expected number of executions (%d) does not match the actual number of executions (%d).", expectedExecutions, actualExecutions)
return false
}
return true
} | go | func (m *Mock) AssertNumberOfExecutions(t testingT, expectedQuery *MockQuery, expectedExecutions int) bool {
var actualExecutions int
for _, query := range m.queries() {
if query.Query.Term.compare(*expectedQuery.Query.Term, map[int64]int64{}) && query.Repeatability > -1 {
// if bytes.Equal(query.BuiltQuery, expectedQuery.BuiltQuery) {
actualExecutions++
}
}
if expectedExecutions != actualExecutions {
t.Errorf("Expected number of executions (%d) does not match the actual number of executions (%d).", expectedExecutions, actualExecutions)
return false
}
return true
} | [
"func",
"(",
"m",
"*",
"Mock",
")",
"AssertNumberOfExecutions",
"(",
"t",
"testingT",
",",
"expectedQuery",
"*",
"MockQuery",
",",
"expectedExecutions",
"int",
")",
"bool",
"{",
"var",
"actualExecutions",
"int",
"\n",
"for",
"_",
",",
"query",
":=",
"range",... | // AssertNumberOfExecutions asserts that the query was executed expectedExecutions times. | [
"AssertNumberOfExecutions",
"asserts",
"that",
"the",
"query",
"was",
"executed",
"expectedExecutions",
"times",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L253-L268 | train |
rethinkdb/rethinkdb-go | mock.go | AssertExecuted | func (m *Mock) AssertExecuted(t testingT, expectedQuery *MockQuery) bool {
if !m.queryWasExecuted(expectedQuery) {
t.Errorf("The query \"%s\" should have been executed, but was not.", expectedQuery.Query.Term.String())
return false
}
return true
} | go | func (m *Mock) AssertExecuted(t testingT, expectedQuery *MockQuery) bool {
if !m.queryWasExecuted(expectedQuery) {
t.Errorf("The query \"%s\" should have been executed, but was not.", expectedQuery.Query.Term.String())
return false
}
return true
} | [
"func",
"(",
"m",
"*",
"Mock",
")",
"AssertExecuted",
"(",
"t",
"testingT",
",",
"expectedQuery",
"*",
"MockQuery",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"queryWasExecuted",
"(",
"expectedQuery",
")",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\""... | // AssertExecuted asserts that the method was executed.
// It can produce a false result when an argument is a pointer type and the underlying value changed after executing the mocked method. | [
"AssertExecuted",
"asserts",
"that",
"the",
"method",
"was",
"executed",
".",
"It",
"can",
"produce",
"a",
"false",
"result",
"when",
"an",
"argument",
"is",
"a",
"pointer",
"type",
"and",
"the",
"underlying",
"value",
"changed",
"after",
"executing",
"the",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L272-L278 | train |
rethinkdb/rethinkdb-go | encoding/decoder.go | decodeValue | func decodeValue(dv, sv reflect.Value, blank bool) error {
return valueDecoder(dv, sv, blank)(dv, sv)
} | go | func decodeValue(dv, sv reflect.Value, blank bool) error {
return valueDecoder(dv, sv, blank)(dv, sv)
} | [
"func",
"decodeValue",
"(",
"dv",
",",
"sv",
"reflect",
".",
"Value",
",",
"blank",
"bool",
")",
"error",
"{",
"return",
"valueDecoder",
"(",
"dv",
",",
"sv",
",",
"blank",
")",
"(",
"dv",
",",
"sv",
")",
"\n",
"}"
] | // decodeValue decodes the source value into the destination value | [
"decodeValue",
"decodes",
"the",
"source",
"value",
"into",
"the",
"destination",
"value"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/decoder.go#L61-L63 | train |
rethinkdb/rethinkdb-go | encoding/decoder.go | indirect | func indirect(v reflect.Value, decodeNull bool) reflect.Value {
// If v is a named type and is addressable,
// start with its address, so that if the type has pointer methods,
// we find them.
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
v = v.Addr()
}
for {
// Load value from interface, but only if the result will be
// usefully addressable.
if v.Kind() == reflect.Interface && !v.IsNil() {
e := v.Elem()
if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodeNull || e.Elem().Kind() == reflect.Ptr) {
v = e
continue
}
}
if v.Kind() != reflect.Ptr {
break
}
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}
v = v.Elem()
}
return v
} | go | func indirect(v reflect.Value, decodeNull bool) reflect.Value {
// If v is a named type and is addressable,
// start with its address, so that if the type has pointer methods,
// we find them.
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
v = v.Addr()
}
for {
// Load value from interface, but only if the result will be
// usefully addressable.
if v.Kind() == reflect.Interface && !v.IsNil() {
e := v.Elem()
if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodeNull || e.Elem().Kind() == reflect.Ptr) {
v = e
continue
}
}
if v.Kind() != reflect.Ptr {
break
}
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}
v = v.Elem()
}
return v
} | [
"func",
"indirect",
"(",
"v",
"reflect",
".",
"Value",
",",
"decodeNull",
"bool",
")",
"reflect",
".",
"Value",
"{",
"// If v is a named type and is addressable,",
"// start with its address, so that if the type has pointer methods,",
"// we find them.",
"if",
"v",
".",
"Ki... | // indirect walks down v allocating pointers as needed,
// until it gets to a non-pointer. | [
"indirect",
"walks",
"down",
"v",
"allocating",
"pointers",
"as",
"needed",
"until",
"it",
"gets",
"to",
"a",
"non",
"-",
"pointer",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/decoder.go#L122-L150 | train |
rethinkdb/rethinkdb-go | node.go | Closed | func (n *Node) Closed() bool {
n.mu.RLock()
defer n.mu.RUnlock()
return n.closed
} | go | func (n *Node) Closed() bool {
n.mu.RLock()
defer n.mu.RUnlock()
return n.closed
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Closed",
"(",
")",
"bool",
"{",
"n",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"n",
".",
"closed",
"\n",
"}"
] | // Closed returns true if the node is closed | [
"Closed",
"returns",
"true",
"if",
"the",
"node",
"is",
"closed"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/node.go#L36-L41 | train |
rethinkdb/rethinkdb-go | node.go | Query | func (n *Node) Query(ctx context.Context, q Query) (cursor *Cursor, err error) {
if n.Closed() {
return nil, ErrInvalidNode
}
return n.pool.Query(ctx, q)
} | go | func (n *Node) Query(ctx context.Context, q Query) (cursor *Cursor, err error) {
if n.Closed() {
return nil, ErrInvalidNode
}
return n.pool.Query(ctx, q)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"cursor",
"*",
"Cursor",
",",
"err",
"error",
")",
"{",
"if",
"n",
".",
"Closed",
"(",
")",
"{",
"return",
"nil",
",",
"ErrInvalidNod... | // Query executes a ReQL query using this nodes connection pool. | [
"Query",
"executes",
"a",
"ReQL",
"query",
"using",
"this",
"nodes",
"connection",
"pool",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/node.go#L93-L99 | train |
rethinkdb/rethinkdb-go | node.go | Exec | func (n *Node) Exec(ctx context.Context, q Query) (err error) {
if n.Closed() {
return ErrInvalidNode
}
return n.pool.Exec(ctx, q)
} | go | func (n *Node) Exec(ctx context.Context, q Query) (err error) {
if n.Closed() {
return ErrInvalidNode
}
return n.pool.Exec(ctx, q)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"err",
"error",
")",
"{",
"if",
"n",
".",
"Closed",
"(",
")",
"{",
"return",
"ErrInvalidNode",
"\n",
"}",
"\n\n",
"return",
"n",
".",
... | // Exec executes a ReQL query using this nodes connection pool. | [
"Exec",
"executes",
"a",
"ReQL",
"query",
"using",
"this",
"nodes",
"connection",
"pool",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/node.go#L102-L108 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Group | func (t Term) Group(fieldOrFunctions ...interface{}) Term {
return constructMethodTerm(t, "Group", p.Term_GROUP, funcWrapArgs(fieldOrFunctions), map[string]interface{}{})
} | go | func (t Term) Group(fieldOrFunctions ...interface{}) Term {
return constructMethodTerm(t, "Group", p.Term_GROUP, funcWrapArgs(fieldOrFunctions), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Group",
"(",
"fieldOrFunctions",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GROUP",
",",
"funcWrapArgs",
"(",
"fieldOrFunctions",
")",
"... | // Group takes a stream and partitions it into multiple groups based on the
// fields or functions provided. Commands chained after group will be
// called on each of these grouped sub-streams, producing grouped data. | [
"Group",
"takes",
"a",
"stream",
"and",
"partitions",
"it",
"into",
"multiple",
"groups",
"based",
"on",
"the",
"fields",
"or",
"functions",
"provided",
".",
"Commands",
"chained",
"after",
"group",
"will",
"be",
"called",
"on",
"each",
"of",
"these",
"group... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L106-L108 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Contains | func (t Term) Contains(args ...interface{}) Term {
return constructMethodTerm(t, "Contains", p.Term_CONTAINS, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Contains(args ...interface{}) Term {
return constructMethodTerm(t, "Contains", p.Term_CONTAINS, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Contains",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_CONTAINS",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"["... | // Contains returns whether or not a sequence contains all the specified values,
// or if functions are provided instead, returns whether or not a sequence
// contains values matching all the specified functions. | [
"Contains",
"returns",
"whether",
"or",
"not",
"a",
"sequence",
"contains",
"all",
"the",
"specified",
"values",
"or",
"if",
"functions",
"are",
"provided",
"instead",
"returns",
"whether",
"or",
"not",
"a",
"sequence",
"contains",
"values",
"matching",
"all",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L167-L169 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Count | func (t Term) Count(args ...interface{}) Term {
return constructMethodTerm(t, "Count", p.Term_COUNT, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Count(args ...interface{}) Term {
return constructMethodTerm(t, "Count", p.Term_COUNT, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Count",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_COUNT",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"s... | // Count the number of elements in the sequence. With a single argument,
// count the number of elements equal to it. If the argument is a function,
// it is equivalent to calling filter before count. | [
"Count",
"the",
"number",
"of",
"elements",
"in",
"the",
"sequence",
".",
"With",
"a",
"single",
"argument",
"count",
"the",
"number",
"of",
"elements",
"equal",
"to",
"it",
".",
"If",
"the",
"argument",
"is",
"a",
"function",
"it",
"is",
"equivalent",
"... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L184-L186 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Sum | func (t Term) Sum(args ...interface{}) Term {
return constructMethodTerm(t, "Sum", p.Term_SUM, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Sum(args ...interface{}) Term {
return constructMethodTerm(t, "Sum", p.Term_SUM, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Sum",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SUM",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Sum returns the sum of all the elements of a sequence. If called with a field
// name, sums all the values of that field in the sequence, skipping elements of
// the sequence that lack that field. If called with a function, calls that
// function on every element of the sequence and sums the results, skipping
// elements of the sequence where that function returns null or a non-existence
// error. | [
"Sum",
"returns",
"the",
"sum",
"of",
"all",
"the",
"elements",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"sums",
"all",
"the",
"values",
"of",
"that",
"field",
"in",
"the",
"sequence",
"skipping",
"elements",
"of",
"the",... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L204-L206 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Avg | func (t Term) Avg(args ...interface{}) Term {
return constructMethodTerm(t, "Avg", p.Term_AVG, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Avg(args ...interface{}) Term {
return constructMethodTerm(t, "Avg", p.Term_AVG, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Avg",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_AVG",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Avg returns the average of all the elements of a sequence. If called with a field
// name, averages all the values of that field in the sequence, skipping elements of
// the sequence that lack that field. If called with a function, calls that function
// on every element of the sequence and averages the results, skipping elements of the
// sequence where that function returns null or a non-existence error. | [
"Avg",
"returns",
"the",
"average",
"of",
"all",
"the",
"elements",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"averages",
"all",
"the",
"values",
"of",
"that",
"field",
"in",
"the",
"sequence",
"skipping",
"elements",
"of",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L222-L224 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Min | func (t Term) Min(args ...interface{}) Term {
return constructMethodTerm(t, "Min", p.Term_MIN, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Min(args ...interface{}) Term {
return constructMethodTerm(t, "Min", p.Term_MIN, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Min",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MIN",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Min finds the minimum of a sequence. If called with a field name, finds the element
// of that sequence with the smallest value in that field. If called with a function,
// calls that function on every element of the sequence and returns the element
// which produced the smallest value, ignoring any elements where the function
// returns null or produces a non-existence error. | [
"Min",
"finds",
"the",
"minimum",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"finds",
"the",
"element",
"of",
"that",
"sequence",
"with",
"the",
"smallest",
"value",
"in",
"that",
"field",
".",
"If",
"called",
"with",
"a",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L249-L251 | train |
rethinkdb/rethinkdb-go | query_aggregation.go | Max | func (t Term) Max(args ...interface{}) Term {
return constructMethodTerm(t, "Max", p.Term_MAX, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Max(args ...interface{}) Term {
return constructMethodTerm(t, "Max", p.Term_MAX, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Max",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MAX",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Max finds the maximum of a sequence. If called with a field name, finds the element
// of that sequence with the largest value in that field. If called with a function,
// calls that function on every element of the sequence and returns the element
// which produced the largest value, ignoring any elements where the function
// returns null or produces a non-existence error. | [
"Max",
"finds",
"the",
"maximum",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"finds",
"the",
"element",
"of",
"that",
"sequence",
"with",
"the",
"largest",
"value",
"in",
"that",
"field",
".",
"If",
"called",
"with",
"a",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L298-L300 | train |
rethinkdb/rethinkdb-go | utils.go | constructRootTerm | func constructRootTerm(name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
return Term{
name: name,
rootTerm: true,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj(optArgs),
}
} | go | func constructRootTerm(name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
return Term{
name: name,
rootTerm: true,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj(optArgs),
}
} | [
"func",
"constructRootTerm",
"(",
"name",
"string",
",",
"termType",
"p",
".",
"Term_TermType",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"optArgs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"Term",
"{",
"na... | // Helper functions for constructing terms
// constructRootTerm is an alias for creating a new term. | [
"Helper",
"functions",
"for",
"constructing",
"terms",
"constructRootTerm",
"is",
"an",
"alias",
"for",
"creating",
"a",
"new",
"term",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L16-L24 | train |
rethinkdb/rethinkdb-go | utils.go | constructMethodTerm | func constructMethodTerm(prevVal Term, name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
args = append([]interface{}{prevVal}, args...)
return Term{
name: name,
rootTerm: false,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj(optArgs),
}
} | go | func constructMethodTerm(prevVal Term, name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
args = append([]interface{}{prevVal}, args...)
return Term{
name: name,
rootTerm: false,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj(optArgs),
}
} | [
"func",
"constructMethodTerm",
"(",
"prevVal",
"Term",
",",
"name",
"string",
",",
"termType",
"p",
".",
"Term_TermType",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"optArgs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"Term",
"{",
... | // constructMethodTerm is an alias for creating a new term. Unlike constructRootTerm
// this function adds the previous expression in the tree to the argument list to
// create a method term. | [
"constructMethodTerm",
"is",
"an",
"alias",
"for",
"creating",
"a",
"new",
"term",
".",
"Unlike",
"constructRootTerm",
"this",
"function",
"adds",
"the",
"previous",
"expression",
"in",
"the",
"tree",
"to",
"the",
"argument",
"list",
"to",
"create",
"a",
"meth... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L29-L39 | train |
rethinkdb/rethinkdb-go | utils.go | newQuery | func newQuery(t Term, qopts map[string]interface{}, copts *ConnectOpts) (q Query, err error) {
queryOpts := map[string]interface{}{}
for k, v := range qopts {
queryOpts[k], err = Expr(v).Build()
if err != nil {
return
}
}
if copts.Database != "" {
queryOpts["db"], err = DB(copts.Database).Build()
if err != nil {
return
}
}
builtTerm, err := t.Build()
if err != nil {
return q, err
}
// Construct query
return Query{
Type: p.Query_START,
Term: &t,
Opts: queryOpts,
builtTerm: builtTerm,
}, nil
} | go | func newQuery(t Term, qopts map[string]interface{}, copts *ConnectOpts) (q Query, err error) {
queryOpts := map[string]interface{}{}
for k, v := range qopts {
queryOpts[k], err = Expr(v).Build()
if err != nil {
return
}
}
if copts.Database != "" {
queryOpts["db"], err = DB(copts.Database).Build()
if err != nil {
return
}
}
builtTerm, err := t.Build()
if err != nil {
return q, err
}
// Construct query
return Query{
Type: p.Query_START,
Term: &t,
Opts: queryOpts,
builtTerm: builtTerm,
}, nil
} | [
"func",
"newQuery",
"(",
"t",
"Term",
",",
"qopts",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"copts",
"*",
"ConnectOpts",
")",
"(",
"q",
"Query",
",",
"err",
"error",
")",
"{",
"queryOpts",
":=",
"map",
"[",
"string",
"]",
"interface",
... | // Helper functions for creating internal RQL types | [
"Helper",
"functions",
"for",
"creating",
"internal",
"RQL",
"types"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L43-L70 | train |
rethinkdb/rethinkdb-go | utils.go | makeArray | func makeArray(args termsList) Term {
return Term{
name: "[...]",
termType: p.Term_MAKE_ARRAY,
args: args,
}
} | go | func makeArray(args termsList) Term {
return Term{
name: "[...]",
termType: p.Term_MAKE_ARRAY,
args: args,
}
} | [
"func",
"makeArray",
"(",
"args",
"termsList",
")",
"Term",
"{",
"return",
"Term",
"{",
"name",
":",
"\"",
"\"",
",",
"termType",
":",
"p",
".",
"Term_MAKE_ARRAY",
",",
"args",
":",
"args",
",",
"}",
"\n",
"}"
] | // makeArray takes a slice of terms and produces a single MAKE_ARRAY term | [
"makeArray",
"takes",
"a",
"slice",
"of",
"terms",
"and",
"produces",
"a",
"single",
"MAKE_ARRAY",
"term"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L73-L79 | train |
rethinkdb/rethinkdb-go | utils.go | makeObject | func makeObject(args termsObj) Term {
return Term{
name: "{...}",
termType: p.Term_MAKE_OBJ,
optArgs: args,
}
} | go | func makeObject(args termsObj) Term {
return Term{
name: "{...}",
termType: p.Term_MAKE_OBJ,
optArgs: args,
}
} | [
"func",
"makeObject",
"(",
"args",
"termsObj",
")",
"Term",
"{",
"return",
"Term",
"{",
"name",
":",
"\"",
"\"",
",",
"termType",
":",
"p",
".",
"Term_MAKE_OBJ",
",",
"optArgs",
":",
"args",
",",
"}",
"\n",
"}"
] | // makeObject takes a map of terms and produces a single MAKE_OBJECT term | [
"makeObject",
"takes",
"a",
"map",
"of",
"terms",
"and",
"produces",
"a",
"single",
"MAKE_OBJECT",
"term"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L82-L88 | train |
rethinkdb/rethinkdb-go | utils.go | implVarScan | func implVarScan(value Term) bool {
if value.termType == p.Term_IMPLICIT_VAR {
return true
}
for _, v := range value.args {
if implVarScan(v) {
return true
}
}
for _, v := range value.optArgs {
if implVarScan(v) {
return true
}
}
return false
} | go | func implVarScan(value Term) bool {
if value.termType == p.Term_IMPLICIT_VAR {
return true
}
for _, v := range value.args {
if implVarScan(v) {
return true
}
}
for _, v := range value.optArgs {
if implVarScan(v) {
return true
}
}
return false
} | [
"func",
"implVarScan",
"(",
"value",
"Term",
")",
"bool",
"{",
"if",
"value",
".",
"termType",
"==",
"p",
".",
"Term_IMPLICIT_VAR",
"{",
"return",
"true",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"value",
".",
"args",
"{",
"if",
"implVar... | // implVarScan recursivly checks a value to see if it contains an
// IMPLICIT_VAR term. If it does it returns true | [
"implVarScan",
"recursivly",
"checks",
"a",
"value",
"to",
"see",
"if",
"it",
"contains",
"an",
"IMPLICIT_VAR",
"term",
".",
"If",
"it",
"does",
"it",
"returns",
"true"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L142-L159 | train |
rethinkdb/rethinkdb-go | utils.go | optArgsToMap | func optArgsToMap(optArgs OptArgs) map[string]interface{} {
data, err := encode(optArgs)
if err == nil && data != nil {
if m, ok := data.(map[string]interface{}); ok {
return m
}
}
return map[string]interface{}{}
} | go | func optArgsToMap(optArgs OptArgs) map[string]interface{} {
data, err := encode(optArgs)
if err == nil && data != nil {
if m, ok := data.(map[string]interface{}); ok {
return m
}
}
return map[string]interface{}{}
} | [
"func",
"optArgsToMap",
"(",
"optArgs",
"OptArgs",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"data",
",",
"err",
":=",
"encode",
"(",
"optArgs",
")",
"\n\n",
"if",
"err",
"==",
"nil",
"&&",
"data",
"!=",
"nil",
"{",
"if",
"m",
","... | // Convert an opt args struct to a map. | [
"Convert",
"an",
"opt",
"args",
"struct",
"to",
"a",
"map",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L162-L172 | train |
rethinkdb/rethinkdb-go | utils.go | convertTermList | func convertTermList(l []interface{}) termsList {
if len(l) == 0 {
return nil
}
terms := make(termsList, len(l))
for i, v := range l {
terms[i] = Expr(v)
}
return terms
} | go | func convertTermList(l []interface{}) termsList {
if len(l) == 0 {
return nil
}
terms := make(termsList, len(l))
for i, v := range l {
terms[i] = Expr(v)
}
return terms
} | [
"func",
"convertTermList",
"(",
"l",
"[",
"]",
"interface",
"{",
"}",
")",
"termsList",
"{",
"if",
"len",
"(",
"l",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"terms",
":=",
"make",
"(",
"termsList",
",",
"len",
"(",
"l",
")",
")",
... | // Convert a list into a slice of terms | [
"Convert",
"a",
"list",
"into",
"a",
"slice",
"of",
"terms"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L175-L186 | train |
rethinkdb/rethinkdb-go | utils.go | convertTermObj | func convertTermObj(o map[string]interface{}) termsObj {
if len(o) == 0 {
return nil
}
terms := make(termsObj, len(o))
for k, v := range o {
terms[k] = Expr(v)
}
return terms
} | go | func convertTermObj(o map[string]interface{}) termsObj {
if len(o) == 0 {
return nil
}
terms := make(termsObj, len(o))
for k, v := range o {
terms[k] = Expr(v)
}
return terms
} | [
"func",
"convertTermObj",
"(",
"o",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"termsObj",
"{",
"if",
"len",
"(",
"o",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"terms",
":=",
"make",
"(",
"termsObj",
",",
"len",
"(",
"... | // Convert a map into a map of terms | [
"Convert",
"a",
"map",
"into",
"a",
"map",
"of",
"terms"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L189-L200 | train |
rethinkdb/rethinkdb-go | utils.go | allArgsToStringSlice | func allArgsToStringSlice(args termsList, optArgs termsObj) []string {
allArgs := make([]string, len(args)+len(optArgs))
i := 0
for _, v := range args {
allArgs[i] = v.String()
i++
}
for k, v := range optArgs {
allArgs[i] = k + "=" + v.String()
i++
}
return allArgs
} | go | func allArgsToStringSlice(args termsList, optArgs termsObj) []string {
allArgs := make([]string, len(args)+len(optArgs))
i := 0
for _, v := range args {
allArgs[i] = v.String()
i++
}
for k, v := range optArgs {
allArgs[i] = k + "=" + v.String()
i++
}
return allArgs
} | [
"func",
"allArgsToStringSlice",
"(",
"args",
"termsList",
",",
"optArgs",
"termsObj",
")",
"[",
"]",
"string",
"{",
"allArgs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"args",
")",
"+",
"len",
"(",
"optArgs",
")",
")",
"\n",
"i",
":=",... | // Helper functions for debugging | [
"Helper",
"functions",
"for",
"debugging"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L204-L218 | train |
rethinkdb/rethinkdb-go | utils.go | shouldRetryQuery | func shouldRetryQuery(q Query, err error) bool {
if err == nil {
return false
}
if _, ok := err.(RQLConnectionError); ok {
return true
}
return err == ErrConnectionClosed
} | go | func shouldRetryQuery(q Query, err error) bool {
if err == nil {
return false
}
if _, ok := err.(RQLConnectionError); ok {
return true
}
return err == ErrConnectionClosed
} | [
"func",
"shouldRetryQuery",
"(",
"q",
"Query",
",",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"RQLConnectionError",
")",
";",
"ok",
"{",
"retu... | // shouldRetryQuery checks the result of a query and returns true if the query
// should be retried | [
"shouldRetryQuery",
"checks",
"the",
"result",
"of",
"a",
"query",
"and",
"returns",
"true",
"if",
"the",
"query",
"should",
"be",
"retried"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L273-L283 | train |
rethinkdb/rethinkdb-go | query_time.go | ISO8601 | func ISO8601(date interface{}, optArgs ...ISO8601Opts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("ISO8601", p.Term_ISO8601, []interface{}{date}, opts)
} | go | func ISO8601(date interface{}, optArgs ...ISO8601Opts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("ISO8601", p.Term_ISO8601, []interface{}{date}, opts)
} | [
"func",
"ISO8601",
"(",
"date",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"ISO8601Opts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",... | // ISO8601 returns a time object based on an ISO8601 formatted date-time string | [
"ISO8601",
"returns",
"a",
"time",
"object",
"based",
"on",
"an",
"ISO8601",
"formatted",
"date",
"-",
"time",
"string"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L32-L39 | train |
rethinkdb/rethinkdb-go | query_time.go | Timezone | func (t Term) Timezone(args ...interface{}) Term {
return constructMethodTerm(t, "Timezone", p.Term_TIMEZONE, args, map[string]interface{}{})
} | go | func (t Term) Timezone(args ...interface{}) Term {
return constructMethodTerm(t, "Timezone", p.Term_TIMEZONE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Timezone",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TIMEZONE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfac... | // Timezone returns the timezone of the time object | [
"Timezone",
"returns",
"the",
"timezone",
"of",
"the",
"time",
"object"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L50-L52 | train |
rethinkdb/rethinkdb-go | query_time.go | TimeOfDay | func (t Term) TimeOfDay(args ...interface{}) Term {
return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
} | go | func (t Term) TimeOfDay(args ...interface{}) Term {
return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TimeOfDay",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TIME_OF_DAY",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inte... | // TimeOfDay returns the number of seconds elapsed since the beginning of the
// day stored in the time object. | [
"TimeOfDay",
"returns",
"the",
"number",
"of",
"seconds",
"elapsed",
"since",
"the",
"beginning",
"of",
"the",
"day",
"stored",
"in",
"the",
"time",
"object",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L82-L84 | train |
rethinkdb/rethinkdb-go | query_time.go | Year | func (t Term) Year(args ...interface{}) Term {
return constructMethodTerm(t, "Year", p.Term_YEAR, args, map[string]interface{}{})
} | go | func (t Term) Year(args ...interface{}) Term {
return constructMethodTerm(t, "Year", p.Term_YEAR, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Year",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_YEAR",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Year returns the year of a time object. | [
"Year",
"returns",
"the",
"year",
"of",
"a",
"time",
"object",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L87-L89 | train |
rethinkdb/rethinkdb-go | query_time.go | Day | func (t Term) Day(args ...interface{}) Term {
return constructMethodTerm(t, "Day", p.Term_DAY, args, map[string]interface{}{})
} | go | func (t Term) Day(args ...interface{}) Term {
return constructMethodTerm(t, "Day", p.Term_DAY, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Day",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_DAY",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Day return the day of a time object as a number between 1 and 31. | [
"Day",
"return",
"the",
"day",
"of",
"a",
"time",
"object",
"as",
"a",
"number",
"between",
"1",
"and",
"31",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L99-L101 | train |
rethinkdb/rethinkdb-go | query_time.go | Hours | func (t Term) Hours(args ...interface{}) Term {
return constructMethodTerm(t, "Hours", p.Term_HOURS, args, map[string]interface{}{})
} | go | func (t Term) Hours(args ...interface{}) Term {
return constructMethodTerm(t, "Hours", p.Term_HOURS, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Hours",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_HOURS",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Hours returns the hour in a time object as a number between 0 and 23. | [
"Hours",
"returns",
"the",
"hour",
"in",
"a",
"time",
"object",
"as",
"a",
"number",
"between",
"0",
"and",
"23",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L118-L120 | train |
rethinkdb/rethinkdb-go | query_time.go | Minutes | func (t Term) Minutes(args ...interface{}) Term {
return constructMethodTerm(t, "Minutes", p.Term_MINUTES, args, map[string]interface{}{})
} | go | func (t Term) Minutes(args ...interface{}) Term {
return constructMethodTerm(t, "Minutes", p.Term_MINUTES, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Minutes",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MINUTES",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // Minutes returns the minute in a time object as a number between 0 and 59. | [
"Minutes",
"returns",
"the",
"minute",
"in",
"a",
"time",
"object",
"as",
"a",
"number",
"between",
"0",
"and",
"59",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L123-L125 | train |
rethinkdb/rethinkdb-go | query_time.go | ToISO8601 | func (t Term) ToISO8601(args ...interface{}) Term {
return constructMethodTerm(t, "ToISO8601", p.Term_TO_ISO8601, args, map[string]interface{}{})
} | go | func (t Term) ToISO8601(args ...interface{}) Term {
return constructMethodTerm(t, "ToISO8601", p.Term_TO_ISO8601, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ToISO8601",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TO_ISO8601",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // ToISO8601 converts a time object to its iso 8601 format. | [
"ToISO8601",
"converts",
"a",
"time",
"object",
"to",
"its",
"iso",
"8601",
"format",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L134-L136 | train |
rethinkdb/rethinkdb-go | query_time.go | ToEpochTime | func (t Term) ToEpochTime(args ...interface{}) Term {
return constructMethodTerm(t, "ToEpochTime", p.Term_TO_EPOCH_TIME, args, map[string]interface{}{})
} | go | func (t Term) ToEpochTime(args ...interface{}) Term {
return constructMethodTerm(t, "ToEpochTime", p.Term_TO_EPOCH_TIME, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ToEpochTime",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TO_EPOCH_TIME",
",",
"args",
",",
"map",
"[",
"string",
"]",
"... | // ToEpochTime converts a time object to its epoch time. | [
"ToEpochTime",
"converts",
"a",
"time",
"object",
"to",
"its",
"epoch",
"time",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L139-L141 | train |
rethinkdb/rethinkdb-go | connection_helper.go | writeData | func (c *Connection) writeData(data []byte) error {
_, err := c.Conn.Write(data[:])
return err
} | go | func (c *Connection) writeData(data []byte) error {
_, err := c.Conn.Write(data[:])
return err
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"writeData",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"Conn",
".",
"Write",
"(",
"data",
"[",
":",
"]",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] | // Write 'data' to conn | [
"Write",
"data",
"to",
"conn"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection_helper.go#L9-L13 | train |
rethinkdb/rethinkdb-go | query_join.go | OuterJoin | func (t Term) OuterJoin(args ...interface{}) Term {
return constructMethodTerm(t, "OuterJoin", p.Term_OUTER_JOIN, args, map[string]interface{}{})
} | go | func (t Term) OuterJoin(args ...interface{}) Term {
return constructMethodTerm(t, "OuterJoin", p.Term_OUTER_JOIN, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"OuterJoin",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_OUTER_JOIN",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // OuterJoin computes a left outer join by retaining each row in the left table even
// if no match was found in the right table. | [
"OuterJoin",
"computes",
"a",
"left",
"outer",
"join",
"by",
"retaining",
"each",
"row",
"in",
"the",
"left",
"table",
"even",
"if",
"no",
"match",
"was",
"found",
"in",
"the",
"right",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_join.go#L18-L20 | train |
rethinkdb/rethinkdb-go | query_join.go | Zip | func (t Term) Zip(args ...interface{}) Term {
return constructMethodTerm(t, "Zip", p.Term_ZIP, args, map[string]interface{}{})
} | go | func (t Term) Zip(args ...interface{}) Term {
return constructMethodTerm(t, "Zip", p.Term_ZIP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Zip",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_ZIP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Zip is used to 'zip' up the result of a join by merging the 'right' fields into 'left'
// fields of each member of the sequence. | [
"Zip",
"is",
"used",
"to",
"zip",
"up",
"the",
"result",
"of",
"a",
"join",
"by",
"merging",
"the",
"right",
"fields",
"into",
"left",
"fields",
"of",
"each",
"member",
"of",
"the",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_join.go#L45-L47 | train |
rethinkdb/rethinkdb-go | query_math.go | Add | func (t Term) Add(args ...interface{}) Term {
return constructMethodTerm(t, "Add", p.Term_ADD, args, map[string]interface{}{})
} | go | func (t Term) Add(args ...interface{}) Term {
return constructMethodTerm(t, "Add", p.Term_ADD, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Add",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_ADD",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Add sums two numbers or concatenates two arrays. | [
"Add",
"sums",
"two",
"numbers",
"or",
"concatenates",
"two",
"arrays",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L15-L17 | train |
rethinkdb/rethinkdb-go | query_math.go | Mod | func (t Term) Mod(args ...interface{}) Term {
return constructMethodTerm(t, "Mod", p.Term_MOD, args, map[string]interface{}{})
} | go | func (t Term) Mod(args ...interface{}) Term {
return constructMethodTerm(t, "Mod", p.Term_MOD, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Mod",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MOD",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Mod divides two numbers and returns the remainder. | [
"Mod",
"divides",
"two",
"numbers",
"and",
"returns",
"the",
"remainder",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L55-L57 | train |
rethinkdb/rethinkdb-go | query_math.go | And | func (t Term) And(args ...interface{}) Term {
return constructMethodTerm(t, "And", p.Term_AND, args, map[string]interface{}{})
} | go | func (t Term) And(args ...interface{}) Term {
return constructMethodTerm(t, "And", p.Term_AND, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"And",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_AND",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // And performs a logical and on two values. | [
"And",
"performs",
"a",
"logical",
"and",
"on",
"two",
"values",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L65-L67 | train |
rethinkdb/rethinkdb-go | query_math.go | Or | func (t Term) Or(args ...interface{}) Term {
return constructMethodTerm(t, "Or", p.Term_OR, args, map[string]interface{}{})
} | go | func (t Term) Or(args ...interface{}) Term {
return constructMethodTerm(t, "Or", p.Term_OR, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Or",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_OR",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Or performs a logical or on two values. | [
"Or",
"performs",
"a",
"logical",
"or",
"on",
"two",
"values",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L75-L77 | train |
rethinkdb/rethinkdb-go | query_math.go | Eq | func (t Term) Eq(args ...interface{}) Term {
return constructMethodTerm(t, "Eq", p.Term_EQ, args, map[string]interface{}{})
} | go | func (t Term) Eq(args ...interface{}) Term {
return constructMethodTerm(t, "Eq", p.Term_EQ, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Eq",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_EQ",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Eq returns true if two values are equal. | [
"Eq",
"returns",
"true",
"if",
"two",
"values",
"are",
"equal",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L85-L87 | train |
rethinkdb/rethinkdb-go | query_math.go | Ne | func (t Term) Ne(args ...interface{}) Term {
return constructMethodTerm(t, "Ne", p.Term_NE, args, map[string]interface{}{})
} | go | func (t Term) Ne(args ...interface{}) Term {
return constructMethodTerm(t, "Ne", p.Term_NE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Ne",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_NE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Ne returns true if two values are not equal. | [
"Ne",
"returns",
"true",
"if",
"two",
"values",
"are",
"not",
"equal",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L95-L97 | train |
rethinkdb/rethinkdb-go | query_math.go | Gt | func (t Term) Gt(args ...interface{}) Term {
return constructMethodTerm(t, "Gt", p.Term_GT, args, map[string]interface{}{})
} | go | func (t Term) Gt(args ...interface{}) Term {
return constructMethodTerm(t, "Gt", p.Term_GT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Gt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Gt returns true if the first value is greater than the second. | [
"Gt",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"greater",
"than",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L105-L107 | train |
rethinkdb/rethinkdb-go | query_math.go | Ge | func (t Term) Ge(args ...interface{}) Term {
return constructMethodTerm(t, "Ge", p.Term_GE, args, map[string]interface{}{})
} | go | func (t Term) Ge(args ...interface{}) Term {
return constructMethodTerm(t, "Ge", p.Term_GE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Ge",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Ge returns true if the first value is greater than or equal to the second. | [
"Ge",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"greater",
"than",
"or",
"equal",
"to",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L115-L117 | train |
rethinkdb/rethinkdb-go | query_math.go | Lt | func (t Term) Lt(args ...interface{}) Term {
return constructMethodTerm(t, "Lt", p.Term_LT, args, map[string]interface{}{})
} | go | func (t Term) Lt(args ...interface{}) Term {
return constructMethodTerm(t, "Lt", p.Term_LT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Lt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_LT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Lt returns true if the first value is less than the second. | [
"Lt",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"less",
"than",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L125-L127 | train |
rethinkdb/rethinkdb-go | query_math.go | Le | func (t Term) Le(args ...interface{}) Term {
return constructMethodTerm(t, "Le", p.Term_LE, args, map[string]interface{}{})
} | go | func (t Term) Le(args ...interface{}) Term {
return constructMethodTerm(t, "Le", p.Term_LE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Le",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_LE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Le returns true if the first value is less than or equal to the second. | [
"Le",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"less",
"than",
"or",
"equal",
"to",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L135-L137 | train |
rethinkdb/rethinkdb-go | query_math.go | Not | func (t Term) Not(args ...interface{}) Term {
return constructMethodTerm(t, "Not", p.Term_NOT, args, map[string]interface{}{})
} | go | func (t Term) Not(args ...interface{}) Term {
return constructMethodTerm(t, "Not", p.Term_NOT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Not",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_NOT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Not performs a logical not on a value. | [
"Not",
"performs",
"a",
"logical",
"not",
"on",
"a",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L145-L147 | train |
rethinkdb/rethinkdb-go | query_math.go | Round | func (t Term) Round(args ...interface{}) Term {
return constructMethodTerm(t, "Round", p.Term_ROUND, args, map[string]interface{}{})
} | go | func (t Term) Round(args ...interface{}) Term {
return constructMethodTerm(t, "Round", p.Term_ROUND, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Round",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_ROUND",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Round causes the input number to be rounded the given value to the nearest whole integer. | [
"Round",
"causes",
"the",
"input",
"number",
"to",
"be",
"rounded",
"the",
"given",
"value",
"to",
"the",
"nearest",
"whole",
"integer",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L198-L200 | train |
rethinkdb/rethinkdb-go | query_table.go | TableDrop | func (t Term) TableDrop(args ...interface{}) Term {
return constructMethodTerm(t, "TableDrop", p.Term_TABLE_DROP, args, map[string]interface{}{})
} | go | func (t Term) TableDrop(args ...interface{}) Term {
return constructMethodTerm(t, "TableDrop", p.Term_TABLE_DROP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TableDrop",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TABLE_DROP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // TableDrop deletes a table. The table and all its data will be deleted. | [
"TableDrop",
"deletes",
"a",
"table",
".",
"The",
"table",
"and",
"all",
"its",
"data",
"will",
"be",
"deleted",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L51-L53 | train |
rethinkdb/rethinkdb-go | query_table.go | TableList | func (t Term) TableList(args ...interface{}) Term {
return constructMethodTerm(t, "TableList", p.Term_TABLE_LIST, args, map[string]interface{}{})
} | go | func (t Term) TableList(args ...interface{}) Term {
return constructMethodTerm(t, "TableList", p.Term_TABLE_LIST, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TableList",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TABLE_LIST",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // TableList lists all table names in a database. | [
"TableList",
"lists",
"all",
"table",
"names",
"in",
"a",
"database",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L61-L63 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexCreate | func (t Term) IndexCreate(name interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name}, opts)
} | go | func (t Term) IndexCreate(name interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"IndexCreate",
"(",
"name",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"IndexCreateOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",... | // IndexCreate creates a new secondary index on a table. Secondary indexes
// improve the speed of many read queries at the slight cost of increased
// storage space and decreased write performance.
//
// IndexCreate supports the creation of the following types of indexes, to create
// indexes using arbitrary expressions use IndexCreateFunc.
// - Simple indexes based on the value of a single field.
// - Geospatial indexes based on indexes of geometry objects, created when the
// geo optional argument is true. | [
"IndexCreate",
"creates",
"a",
"new",
"secondary",
"index",
"on",
"a",
"table",
".",
"Secondary",
"indexes",
"improve",
"the",
"speed",
"of",
"many",
"read",
"queries",
"at",
"the",
"slight",
"cost",
"of",
"increased",
"storage",
"space",
"and",
"decreased",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L84-L90 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexCreateFunc | func (t Term) IndexCreateFunc(name, indexFunction interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name, funcWrap(indexFunction)}, opts)
} | go | func (t Term) IndexCreateFunc(name, indexFunction interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name, funcWrap(indexFunction)}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"IndexCreateFunc",
"(",
"name",
",",
"indexFunction",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"IndexCreateOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if"... | // IndexCreateFunc creates a new secondary index on a table. Secondary indexes
// improve the speed of many read queries at the slight cost of increased
// storage space and decreased write performance. The function takes a index
// name and RQL term as the index value , the term can be an anonymous function
// or a binary representation obtained from the function field of indexStatus.
//
// It supports the creation of the following types of indexes.
// - Simple indexes based on the value of a single field where the index has a
// different name to the field.
// - Compound indexes based on multiple fields.
// - Multi indexes based on arrays of values, created when the multi optional argument is true. | [
"IndexCreateFunc",
"creates",
"a",
"new",
"secondary",
"index",
"on",
"a",
"table",
".",
"Secondary",
"indexes",
"improve",
"the",
"speed",
"of",
"many",
"read",
"queries",
"at",
"the",
"slight",
"cost",
"of",
"increased",
"storage",
"space",
"and",
"decreased... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L103-L109 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexDrop | func (t Term) IndexDrop(args ...interface{}) Term {
return constructMethodTerm(t, "IndexDrop", p.Term_INDEX_DROP, args, map[string]interface{}{})
} | go | func (t Term) IndexDrop(args ...interface{}) Term {
return constructMethodTerm(t, "IndexDrop", p.Term_INDEX_DROP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexDrop",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_DROP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // IndexDrop deletes a previously created secondary index of a table. | [
"IndexDrop",
"deletes",
"a",
"previously",
"created",
"secondary",
"index",
"of",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L112-L114 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexList | func (t Term) IndexList(args ...interface{}) Term {
return constructMethodTerm(t, "IndexList", p.Term_INDEX_LIST, args, map[string]interface{}{})
} | go | func (t Term) IndexList(args ...interface{}) Term {
return constructMethodTerm(t, "IndexList", p.Term_INDEX_LIST, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexList",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_LIST",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // IndexList lists all the secondary indexes of a table. | [
"IndexList",
"lists",
"all",
"the",
"secondary",
"indexes",
"of",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L117-L119 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexRename | func (t Term) IndexRename(oldName, newName interface{}, optArgs ...IndexRenameOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexRename", p.Term_INDEX_RENAME, []interface{}{oldName, newName}, opts)
} | go | func (t Term) IndexRename(oldName, newName interface{}, optArgs ...IndexRenameOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexRename", p.Term_INDEX_RENAME, []interface{}{oldName, newName}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"IndexRename",
"(",
"oldName",
",",
"newName",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"IndexRenameOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"le... | // IndexRename renames an existing secondary index on a table. | [
"IndexRename",
"renames",
"an",
"existing",
"secondary",
"index",
"on",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L131-L137 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexStatus | func (t Term) IndexStatus(args ...interface{}) Term {
return constructMethodTerm(t, "IndexStatus", p.Term_INDEX_STATUS, args, map[string]interface{}{})
} | go | func (t Term) IndexStatus(args ...interface{}) Term {
return constructMethodTerm(t, "IndexStatus", p.Term_INDEX_STATUS, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexStatus",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_STATUS",
",",
"args",
",",
"map",
"[",
"string",
"]",
"i... | // IndexStatus gets the status of the specified indexes on this table, or the
// status of all indexes on this table if no indexes are specified. | [
"IndexStatus",
"gets",
"the",
"status",
"of",
"the",
"specified",
"indexes",
"on",
"this",
"table",
"or",
"the",
"status",
"of",
"all",
"indexes",
"on",
"this",
"table",
"if",
"no",
"indexes",
"are",
"specified",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L141-L143 | train |
rethinkdb/rethinkdb-go | query_table.go | IndexWait | func (t Term) IndexWait(args ...interface{}) Term {
return constructMethodTerm(t, "IndexWait", p.Term_INDEX_WAIT, args, map[string]interface{}{})
} | go | func (t Term) IndexWait(args ...interface{}) Term {
return constructMethodTerm(t, "IndexWait", p.Term_INDEX_WAIT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexWait",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_WAIT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // IndexWait waits for the specified indexes on this table to be ready, or for
// all indexes on this table to be ready if no indexes are specified. | [
"IndexWait",
"waits",
"for",
"the",
"specified",
"indexes",
"on",
"this",
"table",
"to",
"be",
"ready",
"or",
"for",
"all",
"indexes",
"on",
"this",
"table",
"to",
"be",
"ready",
"if",
"no",
"indexes",
"are",
"specified",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L147-L149 | train |
rethinkdb/rethinkdb-go | query_table.go | Changes | func (t Term) Changes(optArgs ...ChangesOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Changes", p.Term_CHANGES, []interface{}{}, opts)
} | go | func (t Term) Changes(optArgs ...ChangesOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Changes", p.Term_CHANGES, []interface{}{}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Changes",
"(",
"optArgs",
"...",
"ChangesOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
"optA... | // Changes returns an infinite stream of objects representing changes to a query. | [
"Changes",
"returns",
"an",
"infinite",
"stream",
"of",
"objects",
"representing",
"changes",
"to",
"a",
"query",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L167-L173 | train |
rethinkdb/rethinkdb-go | query_transformation.go | ConcatMap | func (t Term) ConcatMap(args ...interface{}) Term {
return constructMethodTerm(t, "ConcatMap", p.Term_CONCAT_MAP, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) ConcatMap(args ...interface{}) Term {
return constructMethodTerm(t, "ConcatMap", p.Term_CONCAT_MAP, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ConcatMap",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_CONCAT_MAP",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
... | // ConcatMap concatenates one or more elements into a single sequence using a
// mapping function. ConcatMap works in a similar fashion to Map, applying the
// given function to each element in a sequence, but it will always return a
// single sequence. | [
"ConcatMap",
"concatenates",
"one",
"or",
"more",
"elements",
"into",
"a",
"single",
"sequence",
"using",
"a",
"mapping",
"function",
".",
"ConcatMap",
"works",
"in",
"a",
"similar",
"fashion",
"to",
"Map",
"applying",
"the",
"given",
"function",
"to",
"each",... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L50-L52 | train |
rethinkdb/rethinkdb-go | query_transformation.go | Skip | func (t Term) Skip(args ...interface{}) Term {
return constructMethodTerm(t, "Skip", p.Term_SKIP, args, map[string]interface{}{})
} | go | func (t Term) Skip(args ...interface{}) Term {
return constructMethodTerm(t, "Skip", p.Term_SKIP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Skip",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SKIP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Skip skips a number of elements from the head of the sequence. | [
"Skip",
"skips",
"a",
"number",
"of",
"elements",
"from",
"the",
"head",
"of",
"the",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L103-L105 | train |
rethinkdb/rethinkdb-go | query_transformation.go | Limit | func (t Term) Limit(args ...interface{}) Term {
return constructMethodTerm(t, "Limit", p.Term_LIMIT, args, map[string]interface{}{})
} | go | func (t Term) Limit(args ...interface{}) Term {
return constructMethodTerm(t, "Limit", p.Term_LIMIT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Limit",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_LIMIT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Limit ends the sequence after the given number of elements. | [
"Limit",
"ends",
"the",
"sequence",
"after",
"the",
"given",
"number",
"of",
"elements",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L108-L110 | train |
rethinkdb/rethinkdb-go | query_transformation.go | Slice | func (t Term) Slice(args ...interface{}) Term {
var opts = map[string]interface{}{}
// Look for options map
if len(args) > 0 {
if possibleOpts, ok := args[len(args)-1].(SliceOpts); ok {
opts = possibleOpts.toMap()
args = args[:len(args)-1]
}
}
return constructMethodTerm(t, "Slice", p.Term_SLICE, args, opts)
} | go | func (t Term) Slice(args ...interface{}) Term {
var opts = map[string]interface{}{}
// Look for options map
if len(args) > 0 {
if possibleOpts, ok := args[len(args)-1].(SliceOpts); ok {
opts = possibleOpts.toMap()
args = args[:len(args)-1]
}
}
return constructMethodTerm(t, "Slice", p.Term_SLICE, args, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Slice",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"var",
"opts",
"=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n\n",
"// Look for options map",
"if",
"len",
"(",
"args",
")",
"... | // Slice trims the sequence to within the bounds provided. | [
"Slice",
"trims",
"the",
"sequence",
"to",
"within",
"the",
"bounds",
"provided",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L123-L135 | train |
rethinkdb/rethinkdb-go | query_transformation.go | AtIndex | func (t Term) AtIndex(args ...interface{}) Term {
return constructMethodTerm(t, "AtIndex", p.Term_BRACKET, args, map[string]interface{}{})
} | go | func (t Term) AtIndex(args ...interface{}) Term {
return constructMethodTerm(t, "AtIndex", p.Term_BRACKET, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"AtIndex",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_BRACKET",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // AtIndex gets a single field from an object or the nth element from a sequence. | [
"AtIndex",
"gets",
"a",
"single",
"field",
"from",
"an",
"object",
"or",
"the",
"nth",
"element",
"from",
"a",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L138-L140 | train |
rethinkdb/rethinkdb-go | query_transformation.go | Nth | func (t Term) Nth(args ...interface{}) Term {
return constructMethodTerm(t, "Nth", p.Term_NTH, args, map[string]interface{}{})
} | go | func (t Term) Nth(args ...interface{}) Term {
return constructMethodTerm(t, "Nth", p.Term_NTH, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Nth",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_NTH",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Nth gets the nth element from a sequence. | [
"Nth",
"gets",
"the",
"nth",
"element",
"from",
"a",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L143-L145 | train |
rethinkdb/rethinkdb-go | query_transformation.go | OffsetsOf | func (t Term) OffsetsOf(args ...interface{}) Term {
return constructMethodTerm(t, "OffsetsOf", p.Term_OFFSETS_OF, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) OffsetsOf(args ...interface{}) Term {
return constructMethodTerm(t, "OffsetsOf", p.Term_OFFSETS_OF, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"OffsetsOf",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_OFFSETS_OF",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
... | // OffsetsOf gets the indexes of an element in a sequence. If the argument is a
// predicate, get the indexes of all elements matching it. | [
"OffsetsOf",
"gets",
"the",
"indexes",
"of",
"an",
"element",
"in",
"a",
"sequence",
".",
"If",
"the",
"argument",
"is",
"a",
"predicate",
"get",
"the",
"indexes",
"of",
"all",
"elements",
"matching",
"it",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L149-L151 | train |
rethinkdb/rethinkdb-go | query_transformation.go | IsEmpty | func (t Term) IsEmpty(args ...interface{}) Term {
return constructMethodTerm(t, "IsEmpty", p.Term_IS_EMPTY, args, map[string]interface{}{})
} | go | func (t Term) IsEmpty(args ...interface{}) Term {
return constructMethodTerm(t, "IsEmpty", p.Term_IS_EMPTY, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IsEmpty",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_IS_EMPTY",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface... | // IsEmpty tests if a sequence is empty. | [
"IsEmpty",
"tests",
"if",
"a",
"sequence",
"is",
"empty",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L154-L156 | train |
rethinkdb/rethinkdb-go | query_transformation.go | Union | func (t Term) Union(args ...interface{}) Term {
return constructMethodTerm(t, "Union", p.Term_UNION, args, map[string]interface{}{})
} | go | func (t Term) Union(args ...interface{}) Term {
return constructMethodTerm(t, "Union", p.Term_UNION, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Union",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_UNION",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Union concatenates two sequences. | [
"Union",
"concatenates",
"two",
"sequences",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L173-L175 | train |
rethinkdb/rethinkdb-go | query_transformation.go | Sample | func (t Term) Sample(args ...interface{}) Term {
return constructMethodTerm(t, "Sample", p.Term_SAMPLE, args, map[string]interface{}{})
} | go | func (t Term) Sample(args ...interface{}) Term {
return constructMethodTerm(t, "Sample", p.Term_SAMPLE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Sample",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SAMPLE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Sample selects a given number of elements from a sequence with uniform random
// distribution. Selection is done without replacement. | [
"Sample",
"selects",
"a",
"given",
"number",
"of",
"elements",
"from",
"a",
"sequence",
"with",
"uniform",
"random",
"distribution",
".",
"Selection",
"is",
"done",
"without",
"replacement",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L191-L193 | train |
rethinkdb/rethinkdb-go | query_admin.go | Reconfigure | func (t Term) Reconfigure(optArgs ...ReconfigureOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts)
} | go | func (t Term) Reconfigure(optArgs ...ReconfigureOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Reconfigure",
"(",
"optArgs",
"...",
"ReconfigureOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",... | // Reconfigure a table's sharding and replication. | [
"Reconfigure",
"a",
"table",
"s",
"sharding",
"and",
"replication",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_admin.go#L34-L40 | train |
rethinkdb/rethinkdb-go | query_admin.go | Grant | func (t Term) Grant(args ...interface{}) Term {
return constructMethodTerm(t, "Grant", p.Term_GRANT, args, map[string]interface{}{})
} | go | func (t Term) Grant(args ...interface{}) Term {
return constructMethodTerm(t, "Grant", p.Term_GRANT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Grant",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GRANT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Grant modifies access permissions for a user account, globally or on a
// per-database or per-table basis. | [
"Grant",
"modifies",
"access",
"permissions",
"for",
"a",
"user",
"account",
"globally",
"or",
"on",
"a",
"per",
"-",
"database",
"or",
"per",
"-",
"table",
"basis",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_admin.go#L83-L85 | train |
rethinkdb/rethinkdb-go | encoding/encoder_types.go | timePseudoTypeEncoder | func timePseudoTypeEncoder(v reflect.Value) (interface{}, error) {
t := v.Interface().(time.Time)
timeVal := float64(t.UnixNano()) / float64(time.Second)
// use seconds-since-epoch precision if time.Time `t`
// is before the oldest nanosecond time
if t.Before(time.Unix(0, math.MinInt64)) {
timeVal = float64(t.Unix())
}
return map[string]interface{}{
"$reql_type$": "TIME",
"epoch_time": timeVal,
"timezone": t.Format("-07:00"),
}, nil
} | go | func timePseudoTypeEncoder(v reflect.Value) (interface{}, error) {
t := v.Interface().(time.Time)
timeVal := float64(t.UnixNano()) / float64(time.Second)
// use seconds-since-epoch precision if time.Time `t`
// is before the oldest nanosecond time
if t.Before(time.Unix(0, math.MinInt64)) {
timeVal = float64(t.Unix())
}
return map[string]interface{}{
"$reql_type$": "TIME",
"epoch_time": timeVal,
"timezone": t.Format("-07:00"),
}, nil
} | [
"func",
"timePseudoTypeEncoder",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"t",
":=",
"v",
".",
"Interface",
"(",
")",
".",
"(",
"time",
".",
"Time",
")",
"\n\n",
"timeVal",
":=",
"float64",
"(",
"t... | // Pseudo-type encoders
// Encode a time.Time value to the TIME RQL type | [
"Pseudo",
"-",
"type",
"encoders",
"Encode",
"a",
"time",
".",
"Time",
"value",
"to",
"the",
"TIME",
"RQL",
"type"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoder_types.go#L377-L393 | train |
rethinkdb/rethinkdb-go | encoding/encoder_types.go | encodeByteSlice | func encodeByteSlice(v reflect.Value) (interface{}, error) {
var b []byte
if !v.IsNil() {
b = v.Bytes()
}
dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
base64.StdEncoding.Encode(dst, b)
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": string(dst),
}, nil
} | go | func encodeByteSlice(v reflect.Value) (interface{}, error) {
var b []byte
if !v.IsNil() {
b = v.Bytes()
}
dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
base64.StdEncoding.Encode(dst, b)
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": string(dst),
}, nil
} | [
"func",
"encodeByteSlice",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"if",
"!",
"v",
".",
"IsNil",
"(",
")",
"{",
"b",
"=",
"v",
".",
"Bytes",
"(",
")",
"\n... | // Encode a byte slice to the BINARY RQL type | [
"Encode",
"a",
"byte",
"slice",
"to",
"the",
"BINARY",
"RQL",
"type"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoder_types.go#L396-L409 | train |
rethinkdb/rethinkdb-go | encoding/encoder_types.go | encodeByteArray | func encodeByteArray(v reflect.Value) (interface{}, error) {
b := make([]byte, v.Len())
for i := 0; i < v.Len(); i++ {
b[i] = v.Index(i).Interface().(byte)
}
dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
base64.StdEncoding.Encode(dst, b)
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": string(dst),
}, nil
} | go | func encodeByteArray(v reflect.Value) (interface{}, error) {
b := make([]byte, v.Len())
for i := 0; i < v.Len(); i++ {
b[i] = v.Index(i).Interface().(byte)
}
dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
base64.StdEncoding.Encode(dst, b)
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": string(dst),
}, nil
} | [
"func",
"encodeByteArray",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"v",
".",
"Len",
"(",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
... | // Encode a byte array to the BINARY RQL type | [
"Encode",
"a",
"byte",
"array",
"to",
"the",
"BINARY",
"RQL",
"type"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoder_types.go#L412-L425 | train |
rethinkdb/rethinkdb-go | encoding/encoding.go | IgnoreType | func IgnoreType(t reflect.Type) {
encoderCache.Lock()
encoderCache.m[t] = doNothingEncoder
encoderCache.Unlock()
} | go | func IgnoreType(t reflect.Type) {
encoderCache.Lock()
encoderCache.m[t] = doNothingEncoder
encoderCache.Unlock()
} | [
"func",
"IgnoreType",
"(",
"t",
"reflect",
".",
"Type",
")",
"{",
"encoderCache",
".",
"Lock",
"(",
")",
"\n",
"encoderCache",
".",
"m",
"[",
"t",
"]",
"=",
"doNothingEncoder",
"\n",
"encoderCache",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // IgnoreType causes the encoder to ignore a type when encoding | [
"IgnoreType",
"causes",
"the",
"encoder",
"to",
"ignore",
"a",
"type",
"when",
"encoding"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoding.go#L38-L42 | train |
rethinkdb/rethinkdb-go | query_string.go | Upcase | func (t Term) Upcase(args ...interface{}) Term {
return constructMethodTerm(t, "Upcase", p.Term_UPCASE, args, map[string]interface{}{})
} | go | func (t Term) Upcase(args ...interface{}) Term {
return constructMethodTerm(t, "Upcase", p.Term_UPCASE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Upcase",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_UPCASE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Upcase upper-cases a string. | [
"Upcase",
"upper",
"-",
"cases",
"a",
"string",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_string.go#L37-L39 | train |
rethinkdb/rethinkdb-go | query_string.go | Downcase | func (t Term) Downcase(args ...interface{}) Term {
return constructMethodTerm(t, "Downcase", p.Term_DOWNCASE, args, map[string]interface{}{})
} | go | func (t Term) Downcase(args ...interface{}) Term {
return constructMethodTerm(t, "Downcase", p.Term_DOWNCASE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Downcase",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_DOWNCASE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfac... | // Downcase lower-cases a string. | [
"Downcase",
"lower",
"-",
"cases",
"a",
"string",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_string.go#L42-L44 | train |
rethinkdb/rethinkdb-go | query_control.go | JS | func JS(jssrc interface{}, optArgs ...JSOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Js", p.Term_JAVASCRIPT, []interface{}{jssrc}, opts)
} | go | func JS(jssrc interface{}, optArgs ...JSOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Js", p.Term_JAVASCRIPT, []interface{}{jssrc}, opts)
} | [
"func",
"JS",
"(",
"jssrc",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"JSOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
... | // JS creates a JavaScript expression which is evaluated by the database when
// running the query. | [
"JS",
"creates",
"a",
"JavaScript",
"expression",
"which",
"is",
"evaluated",
"by",
"the",
"database",
"when",
"running",
"the",
"query",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L171-L177 | train |
rethinkdb/rethinkdb-go | query_control.go | HTTP | func HTTP(url interface{}, optArgs ...HTTPOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Http", p.Term_HTTP, []interface{}{url}, opts)
} | go | func HTTP(url interface{}, optArgs ...HTTPOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Http", p.Term_HTTP, []interface{}{url}, opts)
} | [
"func",
"HTTP",
"(",
"url",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"HTTPOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",... | // HTTP retrieves data from the specified URL over HTTP. The return type depends
// on the resultFormat option, which checks the Content-Type of the response by
// default. | [
"HTTP",
"retrieves",
"data",
"from",
"the",
"specified",
"URL",
"over",
"HTTP",
".",
"The",
"return",
"type",
"depends",
"on",
"the",
"resultFormat",
"option",
"which",
"checks",
"the",
"Content",
"-",
"Type",
"of",
"the",
"response",
"by",
"default",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L207-L213 | train |
rethinkdb/rethinkdb-go | query_control.go | Do | func Do(args ...interface{}) Term {
newArgs := []interface{}{}
newArgs = append(newArgs, funcWrap(args[len(args)-1]))
newArgs = append(newArgs, args[:len(args)-1]...)
return constructRootTerm("Do", p.Term_FUNCALL, newArgs, map[string]interface{}{})
} | go | func Do(args ...interface{}) Term {
newArgs := []interface{}{}
newArgs = append(newArgs, funcWrap(args[len(args)-1]))
newArgs = append(newArgs, args[:len(args)-1]...)
return constructRootTerm("Do", p.Term_FUNCALL, newArgs, map[string]interface{}{})
} | [
"func",
"Do",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"newArgs",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"newArgs",
"=",
"append",
"(",
"newArgs",
",",
"funcWrap",
"(",
"args",
"[",
"len",
"(",
"args",
")",
"-"... | // Do evaluates the expr in the context of one or more value bindings. The type of
// the result is the type of the value returned from expr. | [
"Do",
"evaluates",
"the",
"expr",
"in",
"the",
"context",
"of",
"one",
"or",
"more",
"value",
"bindings",
".",
"The",
"type",
"of",
"the",
"result",
"is",
"the",
"type",
"of",
"the",
"value",
"returned",
"from",
"expr",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L290-L296 | train |
rethinkdb/rethinkdb-go | query_control.go | Branch | func (t Term) Branch(args ...interface{}) Term {
return constructMethodTerm(t, "Branch", p.Term_BRANCH, args, map[string]interface{}{})
} | go | func (t Term) Branch(args ...interface{}) Term {
return constructMethodTerm(t, "Branch", p.Term_BRANCH, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Branch",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_BRANCH",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Branch evaluates one of two control paths based on the value of an expression.
// branch is effectively an if renamed due to language constraints.
//
// The type of the result is determined by the type of the branch that gets executed. | [
"Branch",
"evaluates",
"one",
"of",
"two",
"control",
"paths",
"based",
"on",
"the",
"value",
"of",
"an",
"expression",
".",
"branch",
"is",
"effectively",
"an",
"if",
"renamed",
"due",
"to",
"language",
"constraints",
".",
"The",
"type",
"of",
"the",
"res... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L310-L312 | train |
rethinkdb/rethinkdb-go | query_control.go | TypeOf | func (t Term) TypeOf(args ...interface{}) Term {
return constructMethodTerm(t, "TypeOf", p.Term_TYPE_OF, args, map[string]interface{}{})
} | go | func (t Term) TypeOf(args ...interface{}) Term {
return constructMethodTerm(t, "TypeOf", p.Term_TYPE_OF, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TypeOf",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TYPE_OF",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",... | // TypeOf gets the type of a value. | [
"TypeOf",
"gets",
"the",
"type",
"of",
"a",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L355-L357 | train |
rethinkdb/rethinkdb-go | query_control.go | Info | func (t Term) Info(args ...interface{}) Term {
return constructMethodTerm(t, "Info", p.Term_INFO, args, map[string]interface{}{})
} | go | func (t Term) Info(args ...interface{}) Term {
return constructMethodTerm(t, "Info", p.Term_INFO, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Info",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INFO",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Info gets information about a RQL value. | [
"Info",
"gets",
"information",
"about",
"a",
"RQL",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L365-L367 | train |
rethinkdb/rethinkdb-go | query_control.go | RawQuery | func RawQuery(q []byte) Term {
data := json.RawMessage(q)
return Term{
name: "RawQuery",
rootTerm: true,
rawQuery: true,
data: &data,
args: []Term{
Term{
termType: p.Term_DATUM,
data: string(q),
},
},
}
} | go | func RawQuery(q []byte) Term {
data := json.RawMessage(q)
return Term{
name: "RawQuery",
rootTerm: true,
rawQuery: true,
data: &data,
args: []Term{
Term{
termType: p.Term_DATUM,
data: string(q),
},
},
}
} | [
"func",
"RawQuery",
"(",
"q",
"[",
"]",
"byte",
")",
"Term",
"{",
"data",
":=",
"json",
".",
"RawMessage",
"(",
"q",
")",
"\n",
"return",
"Term",
"{",
"name",
":",
"\"",
"\"",
",",
"rootTerm",
":",
"true",
",",
"rawQuery",
":",
"true",
",",
"data... | // RawQuery creates a new query from a JSON string, this bypasses any encoding
// done by RethinkDB-go. The query should not contain the query type or any options
// as this should be handled using the normal driver API.
//
// THis query will only work if this is the only term in the query. | [
"RawQuery",
"creates",
"a",
"new",
"query",
"from",
"a",
"JSON",
"string",
"this",
"bypasses",
"any",
"encoding",
"done",
"by",
"RethinkDB",
"-",
"go",
".",
"The",
"query",
"should",
"not",
"contain",
"the",
"query",
"type",
"or",
"any",
"options",
"as",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L381-L395 | train |
rethinkdb/rethinkdb-go | internal/utils/conn_counter.go | NewCountingConn | func NewCountingConn(conn net.Conn) net.Conn {
c := &connCounting{
Conn: conn,
closed: false,
}
runtime.SetFinalizer(c, func(cc *connCounting) {
if !cc.closed {
atomic.AddInt64(&connsCount, -1)
cc.closed = true
}
})
atomic.AddInt64(&connsCount, 1)
printer.Do(func() {
go func() {
t := time.NewTicker(time.Second)
f, err := os.Create("sockets.ticker")
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create sockets.ticker file: %v\n", err)
return
}
for {
<-t.C
fmt.Fprintf(f, "Connections count: %v\n", atomic.LoadInt64(&connsCount))
f.Sync()
}
}()
})
st := string(debug.Stack())
st = st[strings.Index(st, "\n")+1:]
st = reg.ReplaceAllString(st, "")
mu.Lock()
_, has := createdStacks[st]
if !has {
createdStacks[st] = 1
} else {
createdStacks[st]++
}
printStacks()
mu.Unlock()
return c
} | go | func NewCountingConn(conn net.Conn) net.Conn {
c := &connCounting{
Conn: conn,
closed: false,
}
runtime.SetFinalizer(c, func(cc *connCounting) {
if !cc.closed {
atomic.AddInt64(&connsCount, -1)
cc.closed = true
}
})
atomic.AddInt64(&connsCount, 1)
printer.Do(func() {
go func() {
t := time.NewTicker(time.Second)
f, err := os.Create("sockets.ticker")
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create sockets.ticker file: %v\n", err)
return
}
for {
<-t.C
fmt.Fprintf(f, "Connections count: %v\n", atomic.LoadInt64(&connsCount))
f.Sync()
}
}()
})
st := string(debug.Stack())
st = st[strings.Index(st, "\n")+1:]
st = reg.ReplaceAllString(st, "")
mu.Lock()
_, has := createdStacks[st]
if !has {
createdStacks[st] = 1
} else {
createdStacks[st]++
}
printStacks()
mu.Unlock()
return c
} | [
"func",
"NewCountingConn",
"(",
"conn",
"net",
".",
"Conn",
")",
"net",
".",
"Conn",
"{",
"c",
":=",
"&",
"connCounting",
"{",
"Conn",
":",
"conn",
",",
"closed",
":",
"false",
",",
"}",
"\n",
"runtime",
".",
"SetFinalizer",
"(",
"c",
",",
"func",
... | // Socket leak debug net.Conn wrapper | [
"Socket",
"leak",
"debug",
"net",
".",
"Conn",
"wrapper"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/internal/utils/conn_counter.go#L30-L74 | train |
apex/log | default.go | handleStdLog | func handleStdLog(e *Entry) error {
level := levelNames[e.Level]
var fields []field
for k, v := range e.Fields {
fields = append(fields, field{k, v})
}
sort.Sort(byName(fields))
var b bytes.Buffer
fmt.Fprintf(&b, "%5s %-25s", level, e.Message)
for _, f := range fields {
fmt.Fprintf(&b, " %s=%v", f.Name, f.Value)
}
log.Println(b.String())
return nil
} | go | func handleStdLog(e *Entry) error {
level := levelNames[e.Level]
var fields []field
for k, v := range e.Fields {
fields = append(fields, field{k, v})
}
sort.Sort(byName(fields))
var b bytes.Buffer
fmt.Fprintf(&b, "%5s %-25s", level, e.Message)
for _, f := range fields {
fmt.Fprintf(&b, " %s=%v", f.Name, f.Value)
}
log.Println(b.String())
return nil
} | [
"func",
"handleStdLog",
"(",
"e",
"*",
"Entry",
")",
"error",
"{",
"level",
":=",
"levelNames",
"[",
"e",
".",
"Level",
"]",
"\n\n",
"var",
"fields",
"[",
"]",
"field",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"e",
".",
"Fields",
"{",
"fields",... | // handleStdLog outpouts to the stlib log. | [
"handleStdLog",
"outpouts",
"to",
"the",
"stlib",
"log",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/default.go#L24-L45 | train |
apex/log | entry.go | WithField | func (e *Entry) WithField(key string, value interface{}) *Entry {
return e.WithFields(Fields{key: value})
} | go | func (e *Entry) WithField(key string, value interface{}) *Entry {
return e.WithFields(Fields{key: value})
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"WithField",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"*",
"Entry",
"{",
"return",
"e",
".",
"WithFields",
"(",
"Fields",
"{",
"key",
":",
"value",
"}",
")",
"\n",
"}"
] | // WithField returns a new entry with the `key` and `value` set. | [
"WithField",
"returns",
"a",
"new",
"entry",
"with",
"the",
"key",
"and",
"value",
"set",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L46-L48 | train |
apex/log | entry.go | Debug | func (e *Entry) Debug(msg string) {
e.Logger.log(DebugLevel, e, msg)
} | go | func (e *Entry) Debug(msg string) {
e.Logger.log(DebugLevel, e, msg)
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Debug",
"(",
"msg",
"string",
")",
"{",
"e",
".",
"Logger",
".",
"log",
"(",
"DebugLevel",
",",
"e",
",",
"msg",
")",
"\n",
"}"
] | // Debug level message. | [
"Debug",
"level",
"message",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L80-L82 | train |
apex/log | entry.go | Info | func (e *Entry) Info(msg string) {
e.Logger.log(InfoLevel, e, msg)
} | go | func (e *Entry) Info(msg string) {
e.Logger.log(InfoLevel, e, msg)
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Info",
"(",
"msg",
"string",
")",
"{",
"e",
".",
"Logger",
".",
"log",
"(",
"InfoLevel",
",",
"e",
",",
"msg",
")",
"\n",
"}"
] | // Info level message. | [
"Info",
"level",
"message",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L85-L87 | train |
apex/log | entry.go | Warn | func (e *Entry) Warn(msg string) {
e.Logger.log(WarnLevel, e, msg)
} | go | func (e *Entry) Warn(msg string) {
e.Logger.log(WarnLevel, e, msg)
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Warn",
"(",
"msg",
"string",
")",
"{",
"e",
".",
"Logger",
".",
"log",
"(",
"WarnLevel",
",",
"e",
",",
"msg",
")",
"\n",
"}"
] | // Warn level message. | [
"Warn",
"level",
"message",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L90-L92 | train |
apex/log | entry.go | Error | func (e *Entry) Error(msg string) {
e.Logger.log(ErrorLevel, e, msg)
} | go | func (e *Entry) Error(msg string) {
e.Logger.log(ErrorLevel, e, msg)
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Error",
"(",
"msg",
"string",
")",
"{",
"e",
".",
"Logger",
".",
"log",
"(",
"ErrorLevel",
",",
"e",
",",
"msg",
")",
"\n",
"}"
] | // Error level message. | [
"Error",
"level",
"message",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L95-L97 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.