id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
152,300 | 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 |
152,301 | 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",
"implVarScan",
"(",
"v",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"value",
".",
"optArgs",
"{",
"if",
"implVarScan",
"(",
"v",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // 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 |
152,302 | 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",
",",
"ok",
":=",
"data",
".",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
";",
"ok",
"{",
"return",
"m",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"}"
] | // 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 |
152,303 | 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",
")",
")",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"l",
"{",
"terms",
"[",
"i",
"]",
"=",
"Expr",
"(",
"v",
")",
"\n",
"}",
"\n\n",
"return",
"terms",
"\n",
"}"
] | // 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 |
152,304 | 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",
"(",
"o",
")",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"o",
"{",
"terms",
"[",
"k",
"]",
"=",
"Expr",
"(",
"v",
")",
"\n",
"}",
"\n\n",
"return",
"terms",
"\n",
"}"
] | // 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 |
152,305 | 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",
":=",
"0",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"args",
"{",
"allArgs",
"[",
"i",
"]",
"=",
"v",
".",
"String",
"(",
")",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"optArgs",
"{",
"allArgs",
"[",
"i",
"]",
"=",
"k",
"+",
"\"",
"\"",
"+",
"v",
".",
"String",
"(",
")",
"\n",
"i",
"++",
"\n",
"}",
"\n\n",
"return",
"allArgs",
"\n",
"}"
] | // Helper functions for debugging | [
"Helper",
"functions",
"for",
"debugging"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L204-L218 |
152,306 | 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",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"err",
"==",
"ErrConnectionClosed",
"\n",
"}"
] | // 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 |
152,307 | 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",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructRootTerm",
"(",
"\"",
"\"",
",",
"p",
".",
"Term_ISO8601",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"date",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,308 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,309 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,310 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,311 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,312 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,313 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,314 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,315 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,316 | 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 |
152,317 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,318 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,319 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,320 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,321 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,322 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,323 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,324 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,325 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,326 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,327 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,328 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,329 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,330 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,331 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,332 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,333 | 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",
")",
">=",
"1",
"{",
"opts",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_CREATE",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"name",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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",
"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",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L84-L90 |
152,334 | 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",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_CREATE",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"name",
",",
"funcWrap",
"(",
"indexFunction",
")",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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",
"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",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L103-L109 |
152,335 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,336 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,337 | 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",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_RENAME",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"oldName",
",",
"newName",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,338 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,339 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,340 | 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",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_CHANGES",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,341 | 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",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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",
"element",
"in",
"a",
"sequence",
"but",
"it",
"will",
"always",
"return",
"a",
"single",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L50-L52 |
152,342 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,343 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,344 | 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",
")",
">",
"0",
"{",
"if",
"possibleOpts",
",",
"ok",
":=",
"args",
"[",
"len",
"(",
"args",
")",
"-",
"1",
"]",
".",
"(",
"SliceOpts",
")",
";",
"ok",
"{",
"opts",
"=",
"possibleOpts",
".",
"toMap",
"(",
")",
"\n",
"args",
"=",
"args",
"[",
":",
"len",
"(",
"args",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SLICE",
",",
"args",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,345 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,346 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,347 | 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",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,348 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,349 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // Union concatenates two sequences. | [
"Union",
"concatenates",
"two",
"sequences",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L173-L175 |
152,350 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,351 | 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",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_RECONFIGURE",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,352 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,353 | 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",
".",
"UnixNano",
"(",
")",
")",
"/",
"float64",
"(",
"time",
".",
"Second",
")",
"\n\n",
"// 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",
"(",
")",
")",
"\n",
"}",
"\n\n",
"return",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"timeVal",
",",
"\"",
"\"",
":",
"t",
".",
"Format",
"(",
"\"",
"\"",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // 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 |
152,354 | 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",
"}",
"\n\n",
"dst",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"base64",
".",
"StdEncoding",
".",
"EncodedLen",
"(",
"len",
"(",
"b",
")",
")",
")",
"\n",
"base64",
".",
"StdEncoding",
".",
"Encode",
"(",
"dst",
",",
"b",
")",
"\n\n",
"return",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"string",
"(",
"dst",
")",
",",
"}",
",",
"nil",
"\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 |
152,355 | 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",
"<",
"v",
".",
"Len",
"(",
")",
";",
"i",
"++",
"{",
"b",
"[",
"i",
"]",
"=",
"v",
".",
"Index",
"(",
"i",
")",
".",
"Interface",
"(",
")",
".",
"(",
"byte",
")",
"\n",
"}",
"\n\n",
"dst",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"base64",
".",
"StdEncoding",
".",
"EncodedLen",
"(",
"len",
"(",
"b",
")",
")",
")",
"\n",
"base64",
".",
"StdEncoding",
".",
"Encode",
"(",
"dst",
",",
"b",
")",
"\n\n",
"return",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"string",
"(",
"dst",
")",
",",
"}",
",",
"nil",
"\n",
"}"
] | // 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 |
152,356 | 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 |
152,357 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // Upcase upper-cases a string. | [
"Upcase",
"upper",
"-",
"cases",
"a",
"string",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_string.go#L37-L39 |
152,358 | 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",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // Downcase lower-cases a string. | [
"Downcase",
"lower",
"-",
"cases",
"a",
"string",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_string.go#L42-L44 |
152,359 | 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",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructRootTerm",
"(",
"\"",
"\"",
",",
"p",
".",
"Term_JAVASCRIPT",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"jssrc",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,360 | 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",
"=",
"optArgs",
"[",
"0",
"]",
".",
"toMap",
"(",
")",
"\n",
"}",
"\n",
"return",
"constructRootTerm",
"(",
"\"",
"\"",
",",
"p",
".",
"Term_HTTP",
",",
"[",
"]",
"interface",
"{",
"}",
"{",
"url",
"}",
",",
"opts",
")",
"\n",
"}"
] | // 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 |
152,361 | 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",
")",
"-",
"1",
"]",
")",
")",
"\n",
"newArgs",
"=",
"append",
"(",
"newArgs",
",",
"args",
"[",
":",
"len",
"(",
"args",
")",
"-",
"1",
"]",
"...",
")",
"\n\n",
"return",
"constructRootTerm",
"(",
"\"",
"\"",
",",
"p",
".",
"Term_FUNCALL",
",",
"newArgs",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,362 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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",
"result",
"is",
"determined",
"by",
"the",
"type",
"of",
"the",
"branch",
"that",
"gets",
"executed",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L310-L312 |
152,363 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,364 | 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",
"{",
"}",
"{",
"}",
")",
"\n",
"}"
] | // 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 |
152,365 | 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",
":",
"&",
"data",
",",
"args",
":",
"[",
"]",
"Term",
"{",
"Term",
"{",
"termType",
":",
"p",
".",
"Term_DATUM",
",",
"data",
":",
"string",
"(",
"q",
")",
",",
"}",
",",
"}",
",",
"}",
"\n",
"}"
] | // 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",
"this",
"should",
"be",
"handled",
"using",
"the",
"normal",
"driver",
"API",
".",
"THis",
"query",
"will",
"only",
"work",
"if",
"this",
"is",
"the",
"only",
"term",
"in",
"the",
"query",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L381-L395 |
152,366 | 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",
"(",
"cc",
"*",
"connCounting",
")",
"{",
"if",
"!",
"cc",
".",
"closed",
"{",
"atomic",
".",
"AddInt64",
"(",
"&",
"connsCount",
",",
"-",
"1",
")",
"\n",
"cc",
".",
"closed",
"=",
"true",
"\n",
"}",
"\n",
"}",
")",
"\n\n",
"atomic",
".",
"AddInt64",
"(",
"&",
"connsCount",
",",
"1",
")",
"\n",
"printer",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"t",
":=",
"time",
".",
"NewTicker",
"(",
"time",
".",
"Second",
")",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"",
"\\n",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"for",
"{",
"<-",
"t",
".",
"C",
"\n",
"fmt",
".",
"Fprintf",
"(",
"f",
",",
"\"",
"\\n",
"\"",
",",
"atomic",
".",
"LoadInt64",
"(",
"&",
"connsCount",
")",
")",
"\n",
"f",
".",
"Sync",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}",
")",
"\n\n",
"st",
":=",
"string",
"(",
"debug",
".",
"Stack",
"(",
")",
")",
"\n",
"st",
"=",
"st",
"[",
"strings",
".",
"Index",
"(",
"st",
",",
"\"",
"\\n",
"\"",
")",
"+",
"1",
":",
"]",
"\n",
"st",
"=",
"reg",
".",
"ReplaceAllString",
"(",
"st",
",",
"\"",
"\"",
")",
"\n\n",
"mu",
".",
"Lock",
"(",
")",
"\n",
"_",
",",
"has",
":=",
"createdStacks",
"[",
"st",
"]",
"\n",
"if",
"!",
"has",
"{",
"createdStacks",
"[",
"st",
"]",
"=",
"1",
"\n",
"}",
"else",
"{",
"createdStacks",
"[",
"st",
"]",
"++",
"\n",
"}",
"\n",
"printStacks",
"(",
")",
"\n",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"c",
"\n",
"}"
] | // 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 |
152,367 | 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",
"=",
"append",
"(",
"fields",
",",
"field",
"{",
"k",
",",
"v",
"}",
")",
"\n",
"}",
"\n\n",
"sort",
".",
"Sort",
"(",
"byName",
"(",
"fields",
")",
")",
"\n\n",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\"",
",",
"level",
",",
"e",
".",
"Message",
")",
"\n\n",
"for",
"_",
",",
"f",
":=",
"range",
"fields",
"{",
"fmt",
".",
"Fprintf",
"(",
"&",
"b",
",",
"\"",
"\"",
",",
"f",
".",
"Name",
",",
"f",
".",
"Value",
")",
"\n",
"}",
"\n\n",
"log",
".",
"Println",
"(",
"b",
".",
"String",
"(",
")",
")",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // handleStdLog outpouts to the stlib log. | [
"handleStdLog",
"outpouts",
"to",
"the",
"stlib",
"log",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/default.go#L24-L45 |
152,368 | 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 |
152,369 | 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 |
152,370 | 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 |
152,371 | 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 |
152,372 | 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 |
152,373 | apex/log | entry.go | Fatal | func (e *Entry) Fatal(msg string) {
e.Logger.log(FatalLevel, e, msg)
os.Exit(1)
} | go | func (e *Entry) Fatal(msg string) {
e.Logger.log(FatalLevel, e, msg)
os.Exit(1)
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Fatal",
"(",
"msg",
"string",
")",
"{",
"e",
".",
"Logger",
".",
"log",
"(",
"FatalLevel",
",",
"e",
",",
"msg",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}"
] | // Fatal level message, followed by an exit. | [
"Fatal",
"level",
"message",
"followed",
"by",
"an",
"exit",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L100-L103 |
152,374 | apex/log | entry.go | Stop | func (e *Entry) Stop(err *error) {
if err == nil || *err == nil {
e.WithField("duration", time.Since(e.start)).Info(e.Message)
} else {
e.WithField("duration", time.Since(e.start)).WithError(*err).Error(e.Message)
}
} | go | func (e *Entry) Stop(err *error) {
if err == nil || *err == nil {
e.WithField("duration", time.Since(e.start)).Info(e.Message)
} else {
e.WithField("duration", time.Since(e.start)).WithError(*err).Error(e.Message)
}
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Stop",
"(",
"err",
"*",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"||",
"*",
"err",
"==",
"nil",
"{",
"e",
".",
"WithField",
"(",
"\"",
"\"",
",",
"time",
".",
"Since",
"(",
"e",
".",
"start",
")",
")",
".",
"Info",
"(",
"e",
".",
"Message",
")",
"\n",
"}",
"else",
"{",
"e",
".",
"WithField",
"(",
"\"",
"\"",
",",
"time",
".",
"Since",
"(",
"e",
".",
"start",
")",
")",
".",
"WithError",
"(",
"*",
"err",
")",
".",
"Error",
"(",
"e",
".",
"Message",
")",
"\n",
"}",
"\n",
"}"
] | // Stop should be used with Trace, to fire off the completion message. When
// an `err` is passed the "error" field is set, and the log level is error. | [
"Stop",
"should",
"be",
"used",
"with",
"Trace",
"to",
"fire",
"off",
"the",
"completion",
"message",
".",
"When",
"an",
"err",
"is",
"passed",
"the",
"error",
"field",
"is",
"set",
"and",
"the",
"log",
"level",
"is",
"error",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L142-L148 |
152,375 | apex/log | entry.go | mergedFields | func (e *Entry) mergedFields() Fields {
f := Fields{}
for _, fields := range e.fields {
for k, v := range fields {
f[k] = v
}
}
return f
} | go | func (e *Entry) mergedFields() Fields {
f := Fields{}
for _, fields := range e.fields {
for k, v := range fields {
f[k] = v
}
}
return f
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"mergedFields",
"(",
")",
"Fields",
"{",
"f",
":=",
"Fields",
"{",
"}",
"\n\n",
"for",
"_",
",",
"fields",
":=",
"range",
"e",
".",
"fields",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"fields",
"{",
"f",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"f",
"\n",
"}"
] | // mergedFields returns the fields list collapsed into a single map. | [
"mergedFields",
"returns",
"the",
"fields",
"list",
"collapsed",
"into",
"a",
"single",
"map",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L151-L161 |
152,376 | apex/log | entry.go | finalize | func (e *Entry) finalize(level Level, msg string) *Entry {
return &Entry{
Logger: e.Logger,
Fields: e.mergedFields(),
Level: level,
Message: msg,
Timestamp: Now(),
}
} | go | func (e *Entry) finalize(level Level, msg string) *Entry {
return &Entry{
Logger: e.Logger,
Fields: e.mergedFields(),
Level: level,
Message: msg,
Timestamp: Now(),
}
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"finalize",
"(",
"level",
"Level",
",",
"msg",
"string",
")",
"*",
"Entry",
"{",
"return",
"&",
"Entry",
"{",
"Logger",
":",
"e",
".",
"Logger",
",",
"Fields",
":",
"e",
".",
"mergedFields",
"(",
")",
",",
"Level",
":",
"level",
",",
"Message",
":",
"msg",
",",
"Timestamp",
":",
"Now",
"(",
")",
",",
"}",
"\n",
"}"
] | // finalize returns a copy of the Entry with Fields merged. | [
"finalize",
"returns",
"a",
"copy",
"of",
"the",
"Entry",
"with",
"Fields",
"merged",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/entry.go#L164-L172 |
152,377 | apex/log | levels.go | ParseLevel | func ParseLevel(s string) (Level, error) {
l, ok := levelStrings[strings.ToLower(s)]
if !ok {
return InvalidLevel, ErrInvalidLevel
}
return l, nil
} | go | func ParseLevel(s string) (Level, error) {
l, ok := levelStrings[strings.ToLower(s)]
if !ok {
return InvalidLevel, ErrInvalidLevel
}
return l, nil
} | [
"func",
"ParseLevel",
"(",
"s",
"string",
")",
"(",
"Level",
",",
"error",
")",
"{",
"l",
",",
"ok",
":=",
"levelStrings",
"[",
"strings",
".",
"ToLower",
"(",
"s",
")",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"InvalidLevel",
",",
"ErrInvalidLevel",
"\n",
"}",
"\n\n",
"return",
"l",
",",
"nil",
"\n",
"}"
] | // ParseLevel parses level string. | [
"ParseLevel",
"parses",
"level",
"string",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/levels.go#L64-L71 |
152,378 | apex/log | levels.go | MustParseLevel | func MustParseLevel(s string) Level {
l, err := ParseLevel(s)
if err != nil {
panic("invalid log level")
}
return l
} | go | func MustParseLevel(s string) Level {
l, err := ParseLevel(s)
if err != nil {
panic("invalid log level")
}
return l
} | [
"func",
"MustParseLevel",
"(",
"s",
"string",
")",
"Level",
"{",
"l",
",",
"err",
":=",
"ParseLevel",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"l",
"\n",
"}"
] | // MustParseLevel parses level string or panics. | [
"MustParseLevel",
"parses",
"level",
"string",
"or",
"panics",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/levels.go#L74-L81 |
152,379 | apex/log | handlers/delta/delta.go | Close | func (h *Handler) Close() error {
h.done <- struct{}{}
close(h.done)
close(h.entries)
return nil
} | go | func (h *Handler) Close() error {
h.done <- struct{}{}
close(h.done)
close(h.entries)
return nil
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"Close",
"(",
")",
"error",
"{",
"h",
".",
"done",
"<-",
"struct",
"{",
"}",
"{",
"}",
"\n",
"close",
"(",
"h",
".",
"done",
")",
"\n",
"close",
"(",
"h",
".",
"entries",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close the handler. | [
"Close",
"the",
"handler",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/handlers/delta/delta.go#L99-L104 |
152,380 | apex/log | handlers/delta/delta.go | loop | func (h *Handler) loop() {
ticker := time.NewTicker(100 * time.Millisecond)
for {
select {
case e := <-h.entries:
if h.prev != nil {
h.render(h.prev, true)
}
h.render(e, false)
h.prev = e
case <-ticker.C:
if h.prev != nil {
h.render(h.prev, false)
}
h.spin.Next()
case <-h.done:
ticker.Stop()
if h.prev != nil {
h.render(h.prev, true)
}
return
}
}
} | go | func (h *Handler) loop() {
ticker := time.NewTicker(100 * time.Millisecond)
for {
select {
case e := <-h.entries:
if h.prev != nil {
h.render(h.prev, true)
}
h.render(e, false)
h.prev = e
case <-ticker.C:
if h.prev != nil {
h.render(h.prev, false)
}
h.spin.Next()
case <-h.done:
ticker.Stop()
if h.prev != nil {
h.render(h.prev, true)
}
return
}
}
} | [
"func",
"(",
"h",
"*",
"Handler",
")",
"loop",
"(",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"e",
":=",
"<-",
"h",
".",
"entries",
":",
"if",
"h",
".",
"prev",
"!=",
"nil",
"{",
"h",
".",
"render",
"(",
"h",
".",
"prev",
",",
"true",
")",
"\n",
"}",
"\n",
"h",
".",
"render",
"(",
"e",
",",
"false",
")",
"\n",
"h",
".",
"prev",
"=",
"e",
"\n",
"case",
"<-",
"ticker",
".",
"C",
":",
"if",
"h",
".",
"prev",
"!=",
"nil",
"{",
"h",
".",
"render",
"(",
"h",
".",
"prev",
",",
"false",
")",
"\n",
"}",
"\n",
"h",
".",
"spin",
".",
"Next",
"(",
")",
"\n",
"case",
"<-",
"h",
".",
"done",
":",
"ticker",
".",
"Stop",
"(",
")",
"\n",
"if",
"h",
".",
"prev",
"!=",
"nil",
"{",
"h",
".",
"render",
"(",
"h",
".",
"prev",
",",
"true",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // loop for rendering. | [
"loop",
"for",
"rendering",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/handlers/delta/delta.go#L107-L131 |
152,381 | apex/log | logger.go | Names | func (f Fields) Names() (v []string) {
for k := range f {
v = append(v, k)
}
sort.Strings(v)
return
} | go | func (f Fields) Names() (v []string) {
for k := range f {
v = append(v, k)
}
sort.Strings(v)
return
} | [
"func",
"(",
"f",
"Fields",
")",
"Names",
"(",
")",
"(",
"v",
"[",
"]",
"string",
")",
"{",
"for",
"k",
":=",
"range",
"f",
"{",
"v",
"=",
"append",
"(",
"v",
",",
"k",
")",
"\n",
"}",
"\n\n",
"sort",
".",
"Strings",
"(",
"v",
")",
"\n",
"return",
"\n",
"}"
] | // Names returns field names sorted. | [
"Names",
"returns",
"field",
"names",
"sorted",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/logger.go#L30-L37 |
152,382 | apex/log | logger.go | WithField | func (l *Logger) WithField(key string, value interface{}) *Entry {
return NewEntry(l).WithField(key, value)
} | go | func (l *Logger) WithField(key string, value interface{}) *Entry {
return NewEntry(l).WithField(key, value)
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"WithField",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"*",
"Entry",
"{",
"return",
"NewEntry",
"(",
"l",
")",
".",
"WithField",
"(",
"key",
",",
"value",
")",
"\n",
"}"
] | // WithField returns a new entry with the `key` and `value` set.
//
// Note that the `key` should not have spaces in it - use camel
// case or underscores | [
"WithField",
"returns",
"a",
"new",
"entry",
"with",
"the",
"key",
"and",
"value",
"set",
".",
"Note",
"that",
"the",
"key",
"should",
"not",
"have",
"spaces",
"in",
"it",
"-",
"use",
"camel",
"case",
"or",
"underscores"
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/logger.go#L73-L75 |
152,383 | apex/log | logger.go | WithError | func (l *Logger) WithError(err error) *Entry {
return NewEntry(l).WithError(err)
} | go | func (l *Logger) WithError(err error) *Entry {
return NewEntry(l).WithError(err)
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"WithError",
"(",
"err",
"error",
")",
"*",
"Entry",
"{",
"return",
"NewEntry",
"(",
"l",
")",
".",
"WithError",
"(",
"err",
")",
"\n",
"}"
] | // WithError returns a new entry with the "error" set to `err`. | [
"WithError",
"returns",
"a",
"new",
"entry",
"with",
"the",
"error",
"set",
"to",
"err",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/logger.go#L78-L80 |
152,384 | apex/log | logger.go | log | func (l *Logger) log(level Level, e *Entry, msg string) {
if level < l.Level {
return
}
if err := l.Handler.HandleLog(e.finalize(level, msg)); err != nil {
stdlog.Printf("error logging: %s", err)
}
} | go | func (l *Logger) log(level Level, e *Entry, msg string) {
if level < l.Level {
return
}
if err := l.Handler.HandleLog(e.finalize(level, msg)); err != nil {
stdlog.Printf("error logging: %s", err)
}
} | [
"func",
"(",
"l",
"*",
"Logger",
")",
"log",
"(",
"level",
"Level",
",",
"e",
"*",
"Entry",
",",
"msg",
"string",
")",
"{",
"if",
"level",
"<",
"l",
".",
"Level",
"{",
"return",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"l",
".",
"Handler",
".",
"HandleLog",
"(",
"e",
".",
"finalize",
"(",
"level",
",",
"msg",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"stdlog",
".",
"Printf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // log the message, invoking the handler. We clone the entry here
// to bypass the overhead in Entry methods when the level is not
// met. | [
"log",
"the",
"message",
"invoking",
"the",
"handler",
".",
"We",
"clone",
"the",
"entry",
"here",
"to",
"bypass",
"the",
"overhead",
"in",
"Entry",
"methods",
"when",
"the",
"level",
"is",
"not",
"met",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/logger.go#L141-L149 |
152,385 | apex/log | handlers/kinesis/kinesis.go | New | func New(stream string) *Handler {
return NewConfig(k.Config{
StreamName: stream,
Client: kinesis.New(session.New(aws.NewConfig())),
})
} | go | func New(stream string) *Handler {
return NewConfig(k.Config{
StreamName: stream,
Client: kinesis.New(session.New(aws.NewConfig())),
})
} | [
"func",
"New",
"(",
"stream",
"string",
")",
"*",
"Handler",
"{",
"return",
"NewConfig",
"(",
"k",
".",
"Config",
"{",
"StreamName",
":",
"stream",
",",
"Client",
":",
"kinesis",
".",
"New",
"(",
"session",
".",
"New",
"(",
"aws",
".",
"NewConfig",
"(",
")",
")",
")",
",",
"}",
")",
"\n",
"}"
] | // New handler sending logs to Kinesis. To configure producer options or pass your
// own AWS Kinesis client use NewConfig instead. | [
"New",
"handler",
"sending",
"logs",
"to",
"Kinesis",
".",
"To",
"configure",
"producer",
"options",
"or",
"pass",
"your",
"own",
"AWS",
"Kinesis",
"client",
"use",
"NewConfig",
"instead",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/handlers/kinesis/kinesis.go#L24-L29 |
152,386 | apex/log | handlers/kinesis/kinesis.go | NewConfig | func NewConfig(config k.Config) *Handler {
producer := k.New(config)
producer.Start()
return &Handler{
producer: producer,
gen: fastuuid.MustNewGenerator(),
}
} | go | func NewConfig(config k.Config) *Handler {
producer := k.New(config)
producer.Start()
return &Handler{
producer: producer,
gen: fastuuid.MustNewGenerator(),
}
} | [
"func",
"NewConfig",
"(",
"config",
"k",
".",
"Config",
")",
"*",
"Handler",
"{",
"producer",
":=",
"k",
".",
"New",
"(",
"config",
")",
"\n",
"producer",
".",
"Start",
"(",
")",
"\n",
"return",
"&",
"Handler",
"{",
"producer",
":",
"producer",
",",
"gen",
":",
"fastuuid",
".",
"MustNewGenerator",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewConfig handler sending logs to Kinesis. The `config` given is passed to the batch
// Kinesis producer, and a random value is used as the partition key for even distribution. | [
"NewConfig",
"handler",
"sending",
"logs",
"to",
"Kinesis",
".",
"The",
"config",
"given",
"is",
"passed",
"to",
"the",
"batch",
"Kinesis",
"producer",
"and",
"a",
"random",
"value",
"is",
"used",
"as",
"the",
"partition",
"key",
"for",
"even",
"distribution",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/handlers/kinesis/kinesis.go#L33-L40 |
152,387 | apex/log | pkg.go | SetHandler | func SetHandler(h Handler) {
if logger, ok := Log.(*Logger); ok {
logger.Handler = h
}
} | go | func SetHandler(h Handler) {
if logger, ok := Log.(*Logger); ok {
logger.Handler = h
}
} | [
"func",
"SetHandler",
"(",
"h",
"Handler",
")",
"{",
"if",
"logger",
",",
"ok",
":=",
"Log",
".",
"(",
"*",
"Logger",
")",
";",
"ok",
"{",
"logger",
".",
"Handler",
"=",
"h",
"\n",
"}",
"\n",
"}"
] | // SetHandler sets the handler. This is not thread-safe.
// The default handler outputs to the stdlib log. | [
"SetHandler",
"sets",
"the",
"handler",
".",
"This",
"is",
"not",
"thread",
"-",
"safe",
".",
"The",
"default",
"handler",
"outputs",
"to",
"the",
"stdlib",
"log",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/pkg.go#L11-L15 |
152,388 | apex/log | pkg.go | SetLevel | func SetLevel(l Level) {
if logger, ok := Log.(*Logger); ok {
logger.Level = l
}
} | go | func SetLevel(l Level) {
if logger, ok := Log.(*Logger); ok {
logger.Level = l
}
} | [
"func",
"SetLevel",
"(",
"l",
"Level",
")",
"{",
"if",
"logger",
",",
"ok",
":=",
"Log",
".",
"(",
"*",
"Logger",
")",
";",
"ok",
"{",
"logger",
".",
"Level",
"=",
"l",
"\n",
"}",
"\n",
"}"
] | // SetLevel sets the log level. This is not thread-safe. | [
"SetLevel",
"sets",
"the",
"log",
"level",
".",
"This",
"is",
"not",
"thread",
"-",
"safe",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/pkg.go#L18-L22 |
152,389 | apex/log | pkg.go | SetLevelFromString | func SetLevelFromString(s string) {
if logger, ok := Log.(*Logger); ok {
logger.Level = MustParseLevel(s)
}
} | go | func SetLevelFromString(s string) {
if logger, ok := Log.(*Logger); ok {
logger.Level = MustParseLevel(s)
}
} | [
"func",
"SetLevelFromString",
"(",
"s",
"string",
")",
"{",
"if",
"logger",
",",
"ok",
":=",
"Log",
".",
"(",
"*",
"Logger",
")",
";",
"ok",
"{",
"logger",
".",
"Level",
"=",
"MustParseLevel",
"(",
"s",
")",
"\n",
"}",
"\n",
"}"
] | // SetLevelFromString sets the log level from a string, panicing when invalid. This is not thread-safe. | [
"SetLevelFromString",
"sets",
"the",
"log",
"level",
"from",
"a",
"string",
"panicing",
"when",
"invalid",
".",
"This",
"is",
"not",
"thread",
"-",
"safe",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/pkg.go#L25-L29 |
152,390 | apex/log | _examples/stack/stack.go | upload | func upload(name string, b []byte) error {
err := put("/images/"+name, b)
if err != nil {
return errors.Wrap(err, "uploading to s3")
}
return nil
} | go | func upload(name string, b []byte) error {
err := put("/images/"+name, b)
if err != nil {
return errors.Wrap(err, "uploading to s3")
}
return nil
} | [
"func",
"upload",
"(",
"name",
"string",
",",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"put",
"(",
"\"",
"\"",
"+",
"name",
",",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // Faux upload. | [
"Faux",
"upload",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/_examples/stack/stack.go#L27-L34 |
152,391 | cdipaolo/goml | cluster/knn.go | insertSorted | func insertSorted(u nn, v []nn, K int) []nn {
low := 0
high := len(v) - 1
for low <= high {
mid := (low + high) / 2
if u.Distance < v[mid].Distance {
high = mid - 1
} else if u.Distance >= v[mid].Distance {
low = mid + 1
}
}
if low >= len(v) && len(v) >= K {
return v
}
sorted := append(v[:low], append([]nn{u}, v[low:]...)...)
if len(v) < K {
return sorted
}
return sorted[:len(v)]
} | go | func insertSorted(u nn, v []nn, K int) []nn {
low := 0
high := len(v) - 1
for low <= high {
mid := (low + high) / 2
if u.Distance < v[mid].Distance {
high = mid - 1
} else if u.Distance >= v[mid].Distance {
low = mid + 1
}
}
if low >= len(v) && len(v) >= K {
return v
}
sorted := append(v[:low], append([]nn{u}, v[low:]...)...)
if len(v) < K {
return sorted
}
return sorted[:len(v)]
} | [
"func",
"insertSorted",
"(",
"u",
"nn",
",",
"v",
"[",
"]",
"nn",
",",
"K",
"int",
")",
"[",
"]",
"nn",
"{",
"low",
":=",
"0",
"\n",
"high",
":=",
"len",
"(",
"v",
")",
"-",
"1",
"\n",
"for",
"low",
"<=",
"high",
"{",
"mid",
":=",
"(",
"low",
"+",
"high",
")",
"/",
"2",
"\n",
"if",
"u",
".",
"Distance",
"<",
"v",
"[",
"mid",
"]",
".",
"Distance",
"{",
"high",
"=",
"mid",
"-",
"1",
"\n",
"}",
"else",
"if",
"u",
".",
"Distance",
">=",
"v",
"[",
"mid",
"]",
".",
"Distance",
"{",
"low",
"=",
"mid",
"+",
"1",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"low",
">=",
"len",
"(",
"v",
")",
"&&",
"len",
"(",
"v",
")",
">=",
"K",
"{",
"return",
"v",
"\n",
"}",
"\n\n",
"sorted",
":=",
"append",
"(",
"v",
"[",
":",
"low",
"]",
",",
"append",
"(",
"[",
"]",
"nn",
"{",
"u",
"}",
",",
"v",
"[",
"low",
":",
"]",
"...",
")",
"...",
")",
"\n\n",
"if",
"len",
"(",
"v",
")",
"<",
"K",
"{",
"return",
"sorted",
"\n",
"}",
"\n",
"return",
"sorted",
"[",
":",
"len",
"(",
"v",
")",
"]",
"\n",
"}"
] | // insertSorted takes a array v, and inserts u into
// the list in the position such that the list is
// sorted inversely. The function will not change the length
// of v, though, such that if u would appear last
// in the combined sorted list it would just be omitted.
//
// if the length of V is less than K, then u is inserted
// without deleting the last element
//
// Assumes v has been sorted. Uses binary search. | [
"insertSorted",
"takes",
"a",
"array",
"v",
"and",
"inserts",
"u",
"into",
"the",
"list",
"in",
"the",
"position",
"such",
"that",
"the",
"list",
"is",
"sorted",
"inversely",
".",
"The",
"function",
"will",
"not",
"change",
"the",
"length",
"of",
"v",
"though",
"such",
"that",
"if",
"u",
"would",
"appear",
"last",
"in",
"the",
"combined",
"sorted",
"list",
"it",
"would",
"just",
"be",
"omitted",
".",
"if",
"the",
"length",
"of",
"V",
"is",
"less",
"than",
"K",
"then",
"u",
"is",
"inserted",
"without",
"deleting",
"the",
"last",
"element",
"Assumes",
"v",
"has",
"been",
"sorted",
".",
"Uses",
"binary",
"search",
"."
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/cluster/knn.go#L136-L158 |
152,392 | cdipaolo/goml | cluster/knn.go | round | func round(a float64) float64 {
if a < 0 {
return math.Ceil(a - 0.5)
}
return math.Floor(a + 0.5)
} | go | func round(a float64) float64 {
if a < 0 {
return math.Ceil(a - 0.5)
}
return math.Floor(a + 0.5)
} | [
"func",
"round",
"(",
"a",
"float64",
")",
"float64",
"{",
"if",
"a",
"<",
"0",
"{",
"return",
"math",
".",
"Ceil",
"(",
"a",
"-",
"0.5",
")",
"\n",
"}",
"\n",
"return",
"math",
".",
"Floor",
"(",
"a",
"+",
"0.5",
")",
"\n",
"}"
] | // round rounds a float64 | [
"round",
"rounds",
"a",
"float64"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/cluster/knn.go#L161-L166 |
152,393 | cdipaolo/goml | base/sanitize.go | OnlyAsciiWordsAndNumbers | func OnlyAsciiWordsAndNumbers(r rune) bool {
switch {
case r >= 'A' && r <= 'Z':
return false
case r >= 'a' && r <= 'z':
return false
case r >= '0' && r <= '9':
return false
case r == ' ':
return false
default:
return true
}
} | go | func OnlyAsciiWordsAndNumbers(r rune) bool {
switch {
case r >= 'A' && r <= 'Z':
return false
case r >= 'a' && r <= 'z':
return false
case r >= '0' && r <= '9':
return false
case r == ' ':
return false
default:
return true
}
} | [
"func",
"OnlyAsciiWordsAndNumbers",
"(",
"r",
"rune",
")",
"bool",
"{",
"switch",
"{",
"case",
"r",
">=",
"'A'",
"&&",
"r",
"<=",
"'Z'",
":",
"return",
"false",
"\n",
"case",
"r",
">=",
"'a'",
"&&",
"r",
"<=",
"'z'",
":",
"return",
"false",
"\n",
"case",
"r",
">=",
"'0'",
"&&",
"r",
"<=",
"'9'",
":",
"return",
"false",
"\n",
"case",
"r",
"==",
"' '",
":",
"return",
"false",
"\n",
"default",
":",
"return",
"true",
"\n",
"}",
"\n",
"}"
] | // OnlyAsciiWordsAndNumbers is a transform
// function that will only let 0-9a-zA-Z,
// and spaces through | [
"OnlyAsciiWordsAndNumbers",
"is",
"a",
"transform",
"function",
"that",
"will",
"only",
"let",
"0",
"-",
"9a",
"-",
"zA",
"-",
"Z",
"and",
"spaces",
"through"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/base/sanitize.go#L10-L23 |
152,394 | cdipaolo/goml | base/sanitize.go | OnlyWordsAndNumbers | func OnlyWordsAndNumbers(r rune) bool {
return !(r == ' ' || unicode.IsLetter(r) || unicode.IsDigit(r))
} | go | func OnlyWordsAndNumbers(r rune) bool {
return !(r == ' ' || unicode.IsLetter(r) || unicode.IsDigit(r))
} | [
"func",
"OnlyWordsAndNumbers",
"(",
"r",
"rune",
")",
"bool",
"{",
"return",
"!",
"(",
"r",
"==",
"' '",
"||",
"unicode",
".",
"IsLetter",
"(",
"r",
")",
"||",
"unicode",
".",
"IsDigit",
"(",
"r",
")",
")",
"\n",
"}"
] | // OnlyWordsAndNumbers is a transform
// function that lets any unicode letter
// or digit through as well as spaces | [
"OnlyWordsAndNumbers",
"is",
"a",
"transform",
"function",
"that",
"lets",
"any",
"unicode",
"letter",
"or",
"digit",
"through",
"as",
"well",
"as",
"spaces"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/base/sanitize.go#L28-L30 |
152,395 | cdipaolo/goml | base/sanitize.go | OnlyAsciiWords | func OnlyAsciiWords(r rune) bool {
switch {
case r >= 'A' && r <= 'Z':
return false
case r >= 'a' && r <= 'z':
return false
case r == ' ':
return false
default:
return true
}
} | go | func OnlyAsciiWords(r rune) bool {
switch {
case r >= 'A' && r <= 'Z':
return false
case r >= 'a' && r <= 'z':
return false
case r == ' ':
return false
default:
return true
}
} | [
"func",
"OnlyAsciiWords",
"(",
"r",
"rune",
")",
"bool",
"{",
"switch",
"{",
"case",
"r",
">=",
"'A'",
"&&",
"r",
"<=",
"'Z'",
":",
"return",
"false",
"\n",
"case",
"r",
">=",
"'a'",
"&&",
"r",
"<=",
"'z'",
":",
"return",
"false",
"\n",
"case",
"r",
"==",
"' '",
":",
"return",
"false",
"\n",
"default",
":",
"return",
"true",
"\n",
"}",
"\n",
"}"
] | // OnlyAsciiWords is a transform function
// that will only let a-zA-Z, and
// spaces through | [
"OnlyAsciiWords",
"is",
"a",
"transform",
"function",
"that",
"will",
"only",
"let",
"a",
"-",
"zA",
"-",
"Z",
"and",
"spaces",
"through"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/base/sanitize.go#L35-L46 |
152,396 | cdipaolo/goml | base/sanitize.go | OnlyAsciiLetters | func OnlyAsciiLetters(r rune) bool {
switch {
case r >= 'A' && r <= 'Z':
return false
case r >= 'a' && r <= 'z':
return false
default:
return true
}
} | go | func OnlyAsciiLetters(r rune) bool {
switch {
case r >= 'A' && r <= 'Z':
return false
case r >= 'a' && r <= 'z':
return false
default:
return true
}
} | [
"func",
"OnlyAsciiLetters",
"(",
"r",
"rune",
")",
"bool",
"{",
"switch",
"{",
"case",
"r",
">=",
"'A'",
"&&",
"r",
"<=",
"'Z'",
":",
"return",
"false",
"\n",
"case",
"r",
">=",
"'a'",
"&&",
"r",
"<=",
"'z'",
":",
"return",
"false",
"\n",
"default",
":",
"return",
"true",
"\n",
"}",
"\n",
"}"
] | // OnlyAsciiLetters is a transform function
// that will only let a-zA-Z through | [
"OnlyAsciiLetters",
"is",
"a",
"transform",
"function",
"that",
"will",
"only",
"let",
"a",
"-",
"zA",
"-",
"Z",
"through"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/base/sanitize.go#L57-L66 |
152,397 | cdipaolo/goml | linear/softmax.go | Learn | func (s *Softmax) Learn() error {
if s.trainingSet == nil || s.expectedResults == nil {
err := fmt.Errorf("ERROR: Attempting to learn with no training examples!\n")
fmt.Fprintf(s.Output, err.Error())
return err
}
examples := len(s.trainingSet)
if examples == 0 || len(s.trainingSet[0]) == 0 {
err := fmt.Errorf("ERROR: Attempting to learn with no training examples!\n")
fmt.Fprintf(s.Output, err.Error())
return err
}
if len(s.expectedResults) == 0 {
err := fmt.Errorf("ERROR: Attempting to learn with no expected results! This isn't an unsupervised model!! You'll need to include data before you learn :)\n")
fmt.Fprintf(s.Output, err.Error())
return err
}
fmt.Fprintf(s.Output, "Training:\n\tModel: Softmax Classification\n\tOptimization Method: %v\n\tTraining Examples: %v\n\t Classification Dimensions: %v\n\tFeatures: %v\n\tLearning Rate α: %v\n\tRegularization Parameter λ: %v\n...\n\n", s.method, examples, s.k, len(s.trainingSet[0]), s.alpha, s.regularization)
var err error
if s.method == base.BatchGA {
err = func() error {
// if the iterations given is 0, set it to be
// 5000 (seems reasonable base value)
if s.maxIterations == 0 {
s.maxIterations = 5000
}
iter := 0
// Stop iterating if the number of iterations exceeds
// the limit
for ; iter < s.maxIterations; iter++ {
// go over each parameter vector for each
// classification value
newTheta := make([][]float64, len(s.Parameters))
for k, theta := range s.Parameters {
newTheta[k] = make([]float64, len(theta))
dj, err := s.Dj(k)
if err != nil {
return err
}
for j := range theta {
newTheta[k][j] = theta[j] + s.alpha*dj[j]
if math.IsInf(newTheta[k][j], 0) || math.IsNaN(newTheta[k][j]) {
return fmt.Errorf("Sorry dude! Learning diverged. Some value of the parameter vector theta is ±Inf or NaN")
}
}
}
s.Parameters = newTheta
}
fmt.Fprintf(s.Output, "Went through %v iterations.\n", iter)
return nil
}()
} else if s.method == base.StochasticGA {
err = func() error {
// if the iterations given is 0, set it to be
// 5000 (seems reasonable base value)
if s.maxIterations == 0 {
s.maxIterations = 5000
}
iter := 0
// Stop iterating if the number of iterations exceeds
// the limit
for ; iter < s.maxIterations; iter++ {
for j := range s.trainingSet {
newTheta := make([][]float64, len(s.Parameters))
// go over each parameter vector for each
// classification value
for k, theta := range s.Parameters {
newTheta[k] = make([]float64, len(theta))
dj, err := s.Dij(j, k)
if err != nil {
return err
}
// now simultaneously update theta
for j := range theta {
newTheta[k][j] = theta[j] + s.alpha*dj[j]
if math.IsInf(newTheta[k][j], 0) || math.IsNaN(newTheta[k][j]) {
return fmt.Errorf("Sorry dude! Learning diverged. Some value of the parameter vector theta is ±Inf or NaN")
}
}
}
s.Parameters = newTheta
}
}
fmt.Fprintf(s.Output, "Went through %v iterations.\n", iter)
return nil
}()
} else {
err = fmt.Errorf("Chose a training method not implemented for Softmax regression")
}
if err != nil {
fmt.Fprintf(s.Output, "\nERROR: Error while learning –\n\t%v\n\n", err)
return err
}
fmt.Fprintf(s.Output, "Training Completed.\n%v\n\n", s)
return nil
} | go | func (s *Softmax) Learn() error {
if s.trainingSet == nil || s.expectedResults == nil {
err := fmt.Errorf("ERROR: Attempting to learn with no training examples!\n")
fmt.Fprintf(s.Output, err.Error())
return err
}
examples := len(s.trainingSet)
if examples == 0 || len(s.trainingSet[0]) == 0 {
err := fmt.Errorf("ERROR: Attempting to learn with no training examples!\n")
fmt.Fprintf(s.Output, err.Error())
return err
}
if len(s.expectedResults) == 0 {
err := fmt.Errorf("ERROR: Attempting to learn with no expected results! This isn't an unsupervised model!! You'll need to include data before you learn :)\n")
fmt.Fprintf(s.Output, err.Error())
return err
}
fmt.Fprintf(s.Output, "Training:\n\tModel: Softmax Classification\n\tOptimization Method: %v\n\tTraining Examples: %v\n\t Classification Dimensions: %v\n\tFeatures: %v\n\tLearning Rate α: %v\n\tRegularization Parameter λ: %v\n...\n\n", s.method, examples, s.k, len(s.trainingSet[0]), s.alpha, s.regularization)
var err error
if s.method == base.BatchGA {
err = func() error {
// if the iterations given is 0, set it to be
// 5000 (seems reasonable base value)
if s.maxIterations == 0 {
s.maxIterations = 5000
}
iter := 0
// Stop iterating if the number of iterations exceeds
// the limit
for ; iter < s.maxIterations; iter++ {
// go over each parameter vector for each
// classification value
newTheta := make([][]float64, len(s.Parameters))
for k, theta := range s.Parameters {
newTheta[k] = make([]float64, len(theta))
dj, err := s.Dj(k)
if err != nil {
return err
}
for j := range theta {
newTheta[k][j] = theta[j] + s.alpha*dj[j]
if math.IsInf(newTheta[k][j], 0) || math.IsNaN(newTheta[k][j]) {
return fmt.Errorf("Sorry dude! Learning diverged. Some value of the parameter vector theta is ±Inf or NaN")
}
}
}
s.Parameters = newTheta
}
fmt.Fprintf(s.Output, "Went through %v iterations.\n", iter)
return nil
}()
} else if s.method == base.StochasticGA {
err = func() error {
// if the iterations given is 0, set it to be
// 5000 (seems reasonable base value)
if s.maxIterations == 0 {
s.maxIterations = 5000
}
iter := 0
// Stop iterating if the number of iterations exceeds
// the limit
for ; iter < s.maxIterations; iter++ {
for j := range s.trainingSet {
newTheta := make([][]float64, len(s.Parameters))
// go over each parameter vector for each
// classification value
for k, theta := range s.Parameters {
newTheta[k] = make([]float64, len(theta))
dj, err := s.Dij(j, k)
if err != nil {
return err
}
// now simultaneously update theta
for j := range theta {
newTheta[k][j] = theta[j] + s.alpha*dj[j]
if math.IsInf(newTheta[k][j], 0) || math.IsNaN(newTheta[k][j]) {
return fmt.Errorf("Sorry dude! Learning diverged. Some value of the parameter vector theta is ±Inf or NaN")
}
}
}
s.Parameters = newTheta
}
}
fmt.Fprintf(s.Output, "Went through %v iterations.\n", iter)
return nil
}()
} else {
err = fmt.Errorf("Chose a training method not implemented for Softmax regression")
}
if err != nil {
fmt.Fprintf(s.Output, "\nERROR: Error while learning –\n\t%v\n\n", err)
return err
}
fmt.Fprintf(s.Output, "Training Completed.\n%v\n\n", s)
return nil
} | [
"func",
"(",
"s",
"*",
"Softmax",
")",
"Learn",
"(",
")",
"error",
"{",
"if",
"s",
".",
"trainingSet",
"==",
"nil",
"||",
"s",
".",
"expectedResults",
"==",
"nil",
"{",
"err",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"examples",
":=",
"len",
"(",
"s",
".",
"trainingSet",
")",
"\n",
"if",
"examples",
"==",
"0",
"||",
"len",
"(",
"s",
".",
"trainingSet",
"[",
"0",
"]",
")",
"==",
"0",
"{",
"err",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n",
"if",
"len",
"(",
"s",
".",
"expectedResults",
")",
"==",
"0",
"{",
"err",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"err",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"\"",
"\\n",
"\\t",
"\\n",
"\\t",
"\\n",
"\\t",
"\\n",
"\\t",
"\\n",
"\\t",
"\\n",
"\\t",
"n\\",
"tR",
"..",
"\\n",
"\",",
" ",
"s",
"m",
"e",
"thod, ",
"e",
"amples, ",
"s",
"k",
",",
" ",
"l",
"n(s",
".",
"t",
"r",
"ainingSet[0",
"]",
")",
",",
" ",
"s",
"a",
"l",
"pha, ",
"s",
"r",
"e",
"gularization)",
"",
"\n\n",
"var",
"err",
"error",
"\n",
"if",
"s",
".",
"method",
"==",
"base",
".",
"BatchGA",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"// if the iterations given is 0, set it to be",
"// 5000 (seems reasonable base value)",
"if",
"s",
".",
"maxIterations",
"==",
"0",
"{",
"s",
".",
"maxIterations",
"=",
"5000",
"\n",
"}",
"\n\n",
"iter",
":=",
"0",
"\n\n",
"// Stop iterating if the number of iterations exceeds",
"// the limit",
"for",
";",
"iter",
"<",
"s",
".",
"maxIterations",
";",
"iter",
"++",
"{",
"// go over each parameter vector for each",
"// classification value",
"newTheta",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"float64",
",",
"len",
"(",
"s",
".",
"Parameters",
")",
")",
"\n",
"for",
"k",
",",
"theta",
":=",
"range",
"s",
".",
"Parameters",
"{",
"newTheta",
"[",
"k",
"]",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"theta",
")",
")",
"\n\n",
"dj",
",",
"err",
":=",
"s",
".",
"Dj",
"(",
"k",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
"j",
":=",
"range",
"theta",
"{",
"newTheta",
"[",
"k",
"]",
"[",
"j",
"]",
"=",
"theta",
"[",
"j",
"]",
"+",
"s",
".",
"alpha",
"*",
"dj",
"[",
"j",
"]",
"\n",
"if",
"math",
".",
"IsInf",
"(",
"newTheta",
"[",
"k",
"]",
"[",
"j",
"]",
",",
"0",
")",
"||",
"math",
".",
"IsNaN",
"(",
"newTheta",
"[",
"k",
"]",
"[",
"j",
"]",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
")",
"",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"s",
".",
"Parameters",
"=",
"newTheta",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"\"",
"\\n",
"\"",
",",
"iter",
")",
"\n\n",
"return",
"nil",
"\n",
"}",
"(",
")",
"\n",
"}",
"else",
"if",
"s",
".",
"method",
"==",
"base",
".",
"StochasticGA",
"{",
"err",
"=",
"func",
"(",
")",
"error",
"{",
"// if the iterations given is 0, set it to be",
"// 5000 (seems reasonable base value)",
"if",
"s",
".",
"maxIterations",
"==",
"0",
"{",
"s",
".",
"maxIterations",
"=",
"5000",
"\n",
"}",
"\n\n",
"iter",
":=",
"0",
"\n\n",
"// Stop iterating if the number of iterations exceeds",
"// the limit",
"for",
";",
"iter",
"<",
"s",
".",
"maxIterations",
";",
"iter",
"++",
"{",
"for",
"j",
":=",
"range",
"s",
".",
"trainingSet",
"{",
"newTheta",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"float64",
",",
"len",
"(",
"s",
".",
"Parameters",
")",
")",
"\n",
"// go over each parameter vector for each",
"// classification value",
"for",
"k",
",",
"theta",
":=",
"range",
"s",
".",
"Parameters",
"{",
"newTheta",
"[",
"k",
"]",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"theta",
")",
")",
"\n",
"dj",
",",
"err",
":=",
"s",
".",
"Dij",
"(",
"j",
",",
"k",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"// now simultaneously update theta",
"for",
"j",
":=",
"range",
"theta",
"{",
"newTheta",
"[",
"k",
"]",
"[",
"j",
"]",
"=",
"theta",
"[",
"j",
"]",
"+",
"s",
".",
"alpha",
"*",
"dj",
"[",
"j",
"]",
"\n",
"if",
"math",
".",
"IsInf",
"(",
"newTheta",
"[",
"k",
"]",
"[",
"j",
"]",
",",
"0",
")",
"||",
"math",
".",
"IsNaN",
"(",
"newTheta",
"[",
"k",
"]",
"[",
"j",
"]",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
")",
"",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"s",
".",
"Parameters",
"=",
"newTheta",
"\n",
"}",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"\"",
"\\n",
"\"",
",",
"iter",
")",
"\n\n",
"return",
"nil",
"\n",
"}",
"(",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"\"",
"\\n",
"\\t",
"%v",
"\\n",
"\",",
" ",
"e",
"r)",
"",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintf",
"(",
"s",
".",
"Output",
",",
"\"",
"\\n",
"\\n",
"\\n",
"\"",
",",
"s",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Learn takes the struct's dataset and expected results and runs
// gradient descent on them, optimizing theta so you can
// predict accurately based on those results | [
"Learn",
"takes",
"the",
"struct",
"s",
"dataset",
"and",
"expected",
"results",
"and",
"runs",
"gradient",
"descent",
"on",
"them",
"optimizing",
"theta",
"so",
"you",
"can",
"predict",
"accurately",
"based",
"on",
"those",
"results"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/linear/softmax.go#L198-L312 |
152,398 | cdipaolo/goml | text/tfidf.go | Less | func (f Frequencies) Less(i, j int) bool {
return f[i].TFIDF < f[j].TFIDF
} | go | func (f Frequencies) Less(i, j int) bool {
return f[i].TFIDF < f[j].TFIDF
} | [
"func",
"(",
"f",
"Frequencies",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"f",
"[",
"i",
"]",
".",
"TFIDF",
"<",
"f",
"[",
"j",
"]",
".",
"TFIDF",
"\n",
"}"
] | // Less gives whether the ith element
// of a frequency list has is lesser
// than the jth element by comparing
// their TFIDF values | [
"Less",
"gives",
"whether",
"the",
"ith",
"element",
"of",
"a",
"frequency",
"list",
"has",
"is",
"lesser",
"than",
"the",
"jth",
"element",
"by",
"comparing",
"their",
"TFIDF",
"values"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L64-L66 |
152,399 | cdipaolo/goml | text/tfidf.go | Swap | func (f Frequencies) Swap(i, j int) {
f[i], f[j] = f[j], f[i]
} | go | func (f Frequencies) Swap(i, j int) {
f[i], f[j] = f[j], f[i]
} | [
"func",
"(",
"f",
"Frequencies",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"f",
"[",
"i",
"]",
",",
"f",
"[",
"j",
"]",
"=",
"f",
"[",
"j",
"]",
",",
"f",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps two indexed values in
// a frequency slice | [
"Swap",
"swaps",
"two",
"indexed",
"values",
"in",
"a",
"frequency",
"slice"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L70-L72 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.