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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,300 | 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 |
30,301 | rethinkdb/rethinkdb-go | query_join.go | OuterJoin | func (t Term) OuterJoin(args ...interface{}) Term {
return constructMethodTerm(t, "OuterJoin", p.Term_OUTER_JOIN, args, map[string]interface{}{})
} | go | func (t Term) OuterJoin(args ...interface{}) Term {
return constructMethodTerm(t, "OuterJoin", p.Term_OUTER_JOIN, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"OuterJoin",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_OUTER_JOIN",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // OuterJoin computes a left outer join by retaining each row in the left table even
// if no match was found in the right table. | [
"OuterJoin",
"computes",
"a",
"left",
"outer",
"join",
"by",
"retaining",
"each",
"row",
"in",
"the",
"left",
"table",
"even",
"if",
"no",
"match",
"was",
"found",
"in",
"the",
"right",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_join.go#L18-L20 |
30,302 | rethinkdb/rethinkdb-go | query_join.go | Zip | func (t Term) Zip(args ...interface{}) Term {
return constructMethodTerm(t, "Zip", p.Term_ZIP, args, map[string]interface{}{})
} | go | func (t Term) Zip(args ...interface{}) Term {
return constructMethodTerm(t, "Zip", p.Term_ZIP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Zip",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_ZIP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Zip is used to 'zip' up the result of a join by merging the 'right' fields into 'left'
// fields of each member of the sequence. | [
"Zip",
"is",
"used",
"to",
"zip",
"up",
"the",
"result",
"of",
"a",
"join",
"by",
"merging",
"the",
"right",
"fields",
"into",
"left",
"fields",
"of",
"each",
"member",
"of",
"the",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_join.go#L45-L47 |
30,303 | rethinkdb/rethinkdb-go | query_math.go | Add | func (t Term) Add(args ...interface{}) Term {
return constructMethodTerm(t, "Add", p.Term_ADD, args, map[string]interface{}{})
} | go | func (t Term) Add(args ...interface{}) Term {
return constructMethodTerm(t, "Add", p.Term_ADD, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Add",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_ADD",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Add sums two numbers or concatenates two arrays. | [
"Add",
"sums",
"two",
"numbers",
"or",
"concatenates",
"two",
"arrays",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L15-L17 |
30,304 | rethinkdb/rethinkdb-go | query_math.go | Mod | func (t Term) Mod(args ...interface{}) Term {
return constructMethodTerm(t, "Mod", p.Term_MOD, args, map[string]interface{}{})
} | go | func (t Term) Mod(args ...interface{}) Term {
return constructMethodTerm(t, "Mod", p.Term_MOD, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Mod",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MOD",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Mod divides two numbers and returns the remainder. | [
"Mod",
"divides",
"two",
"numbers",
"and",
"returns",
"the",
"remainder",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L55-L57 |
30,305 | rethinkdb/rethinkdb-go | query_math.go | And | func (t Term) And(args ...interface{}) Term {
return constructMethodTerm(t, "And", p.Term_AND, args, map[string]interface{}{})
} | go | func (t Term) And(args ...interface{}) Term {
return constructMethodTerm(t, "And", p.Term_AND, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"And",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_AND",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // And performs a logical and on two values. | [
"And",
"performs",
"a",
"logical",
"and",
"on",
"two",
"values",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L65-L67 |
30,306 | rethinkdb/rethinkdb-go | query_math.go | Or | func (t Term) Or(args ...interface{}) Term {
return constructMethodTerm(t, "Or", p.Term_OR, args, map[string]interface{}{})
} | go | func (t Term) Or(args ...interface{}) Term {
return constructMethodTerm(t, "Or", p.Term_OR, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Or",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_OR",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Or performs a logical or on two values. | [
"Or",
"performs",
"a",
"logical",
"or",
"on",
"two",
"values",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L75-L77 |
30,307 | rethinkdb/rethinkdb-go | query_math.go | Eq | func (t Term) Eq(args ...interface{}) Term {
return constructMethodTerm(t, "Eq", p.Term_EQ, args, map[string]interface{}{})
} | go | func (t Term) Eq(args ...interface{}) Term {
return constructMethodTerm(t, "Eq", p.Term_EQ, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Eq",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_EQ",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Eq returns true if two values are equal. | [
"Eq",
"returns",
"true",
"if",
"two",
"values",
"are",
"equal",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L85-L87 |
30,308 | rethinkdb/rethinkdb-go | query_math.go | Ne | func (t Term) Ne(args ...interface{}) Term {
return constructMethodTerm(t, "Ne", p.Term_NE, args, map[string]interface{}{})
} | go | func (t Term) Ne(args ...interface{}) Term {
return constructMethodTerm(t, "Ne", p.Term_NE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Ne",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_NE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Ne returns true if two values are not equal. | [
"Ne",
"returns",
"true",
"if",
"two",
"values",
"are",
"not",
"equal",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L95-L97 |
30,309 | rethinkdb/rethinkdb-go | query_math.go | Gt | func (t Term) Gt(args ...interface{}) Term {
return constructMethodTerm(t, "Gt", p.Term_GT, args, map[string]interface{}{})
} | go | func (t Term) Gt(args ...interface{}) Term {
return constructMethodTerm(t, "Gt", p.Term_GT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Gt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Gt returns true if the first value is greater than the second. | [
"Gt",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"greater",
"than",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L105-L107 |
30,310 | rethinkdb/rethinkdb-go | query_math.go | Ge | func (t Term) Ge(args ...interface{}) Term {
return constructMethodTerm(t, "Ge", p.Term_GE, args, map[string]interface{}{})
} | go | func (t Term) Ge(args ...interface{}) Term {
return constructMethodTerm(t, "Ge", p.Term_GE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Ge",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Ge returns true if the first value is greater than or equal to the second. | [
"Ge",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"greater",
"than",
"or",
"equal",
"to",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L115-L117 |
30,311 | rethinkdb/rethinkdb-go | query_math.go | Lt | func (t Term) Lt(args ...interface{}) Term {
return constructMethodTerm(t, "Lt", p.Term_LT, args, map[string]interface{}{})
} | go | func (t Term) Lt(args ...interface{}) Term {
return constructMethodTerm(t, "Lt", p.Term_LT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Lt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_LT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Lt returns true if the first value is less than the second. | [
"Lt",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"less",
"than",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L125-L127 |
30,312 | rethinkdb/rethinkdb-go | query_math.go | Le | func (t Term) Le(args ...interface{}) Term {
return constructMethodTerm(t, "Le", p.Term_LE, args, map[string]interface{}{})
} | go | func (t Term) Le(args ...interface{}) Term {
return constructMethodTerm(t, "Le", p.Term_LE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Le",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_LE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Le returns true if the first value is less than or equal to the second. | [
"Le",
"returns",
"true",
"if",
"the",
"first",
"value",
"is",
"less",
"than",
"or",
"equal",
"to",
"the",
"second",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L135-L137 |
30,313 | rethinkdb/rethinkdb-go | query_math.go | Not | func (t Term) Not(args ...interface{}) Term {
return constructMethodTerm(t, "Not", p.Term_NOT, args, map[string]interface{}{})
} | go | func (t Term) Not(args ...interface{}) Term {
return constructMethodTerm(t, "Not", p.Term_NOT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Not",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_NOT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Not performs a logical not on a value. | [
"Not",
"performs",
"a",
"logical",
"not",
"on",
"a",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L145-L147 |
30,314 | rethinkdb/rethinkdb-go | query_math.go | Round | func (t Term) Round(args ...interface{}) Term {
return constructMethodTerm(t, "Round", p.Term_ROUND, args, map[string]interface{}{})
} | go | func (t Term) Round(args ...interface{}) Term {
return constructMethodTerm(t, "Round", p.Term_ROUND, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Round",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_ROUND",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Round causes the input number to be rounded the given value to the nearest whole integer. | [
"Round",
"causes",
"the",
"input",
"number",
"to",
"be",
"rounded",
"the",
"given",
"value",
"to",
"the",
"nearest",
"whole",
"integer",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_math.go#L198-L200 |
30,315 | rethinkdb/rethinkdb-go | query_table.go | TableDrop | func (t Term) TableDrop(args ...interface{}) Term {
return constructMethodTerm(t, "TableDrop", p.Term_TABLE_DROP, args, map[string]interface{}{})
} | go | func (t Term) TableDrop(args ...interface{}) Term {
return constructMethodTerm(t, "TableDrop", p.Term_TABLE_DROP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TableDrop",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TABLE_DROP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // TableDrop deletes a table. The table and all its data will be deleted. | [
"TableDrop",
"deletes",
"a",
"table",
".",
"The",
"table",
"and",
"all",
"its",
"data",
"will",
"be",
"deleted",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L51-L53 |
30,316 | rethinkdb/rethinkdb-go | query_table.go | TableList | func (t Term) TableList(args ...interface{}) Term {
return constructMethodTerm(t, "TableList", p.Term_TABLE_LIST, args, map[string]interface{}{})
} | go | func (t Term) TableList(args ...interface{}) Term {
return constructMethodTerm(t, "TableList", p.Term_TABLE_LIST, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TableList",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TABLE_LIST",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // TableList lists all table names in a database. | [
"TableList",
"lists",
"all",
"table",
"names",
"in",
"a",
"database",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L61-L63 |
30,317 | rethinkdb/rethinkdb-go | query_table.go | IndexCreate | func (t Term) IndexCreate(name interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name}, opts)
} | go | func (t Term) IndexCreate(name interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"IndexCreate",
"(",
"name",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"IndexCreateOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",... | // IndexCreate creates a new secondary index on a table. Secondary indexes
// improve the speed of many read queries at the slight cost of increased
// storage space and decreased write performance.
//
// IndexCreate supports the creation of the following types of indexes, to create
// indexes using arbitrary expressio... | [
"IndexCreate",
"creates",
"a",
"new",
"secondary",
"index",
"on",
"a",
"table",
".",
"Secondary",
"indexes",
"improve",
"the",
"speed",
"of",
"many",
"read",
"queries",
"at",
"the",
"slight",
"cost",
"of",
"increased",
"storage",
"space",
"and",
"decreased",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L84-L90 |
30,318 | rethinkdb/rethinkdb-go | query_table.go | IndexCreateFunc | func (t Term) IndexCreateFunc(name, indexFunction interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name, funcWrap(indexFunction)}, opts)
} | go | func (t Term) IndexCreateFunc(name, indexFunction interface{}, optArgs ...IndexCreateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexCreate", p.Term_INDEX_CREATE, []interface{}{name, funcWrap(indexFunction)}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"IndexCreateFunc",
"(",
"name",
",",
"indexFunction",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"IndexCreateOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if"... | // IndexCreateFunc creates a new secondary index on a table. Secondary indexes
// improve the speed of many read queries at the slight cost of increased
// storage space and decreased write performance. The function takes a index
// name and RQL term as the index value , the term can be an anonymous function
// or a bi... | [
"IndexCreateFunc",
"creates",
"a",
"new",
"secondary",
"index",
"on",
"a",
"table",
".",
"Secondary",
"indexes",
"improve",
"the",
"speed",
"of",
"many",
"read",
"queries",
"at",
"the",
"slight",
"cost",
"of",
"increased",
"storage",
"space",
"and",
"decreased... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L103-L109 |
30,319 | rethinkdb/rethinkdb-go | query_table.go | IndexDrop | func (t Term) IndexDrop(args ...interface{}) Term {
return constructMethodTerm(t, "IndexDrop", p.Term_INDEX_DROP, args, map[string]interface{}{})
} | go | func (t Term) IndexDrop(args ...interface{}) Term {
return constructMethodTerm(t, "IndexDrop", p.Term_INDEX_DROP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexDrop",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_DROP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // IndexDrop deletes a previously created secondary index of a table. | [
"IndexDrop",
"deletes",
"a",
"previously",
"created",
"secondary",
"index",
"of",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L112-L114 |
30,320 | rethinkdb/rethinkdb-go | query_table.go | IndexList | func (t Term) IndexList(args ...interface{}) Term {
return constructMethodTerm(t, "IndexList", p.Term_INDEX_LIST, args, map[string]interface{}{})
} | go | func (t Term) IndexList(args ...interface{}) Term {
return constructMethodTerm(t, "IndexList", p.Term_INDEX_LIST, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexList",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_LIST",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // IndexList lists all the secondary indexes of a table. | [
"IndexList",
"lists",
"all",
"the",
"secondary",
"indexes",
"of",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L117-L119 |
30,321 | rethinkdb/rethinkdb-go | query_table.go | IndexRename | func (t Term) IndexRename(oldName, newName interface{}, optArgs ...IndexRenameOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexRename", p.Term_INDEX_RENAME, []interface{}{oldName, newName}, opts)
} | go | func (t Term) IndexRename(oldName, newName interface{}, optArgs ...IndexRenameOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "IndexRename", p.Term_INDEX_RENAME, []interface{}{oldName, newName}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"IndexRename",
"(",
"oldName",
",",
"newName",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"IndexRenameOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"le... | // IndexRename renames an existing secondary index on a table. | [
"IndexRename",
"renames",
"an",
"existing",
"secondary",
"index",
"on",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L131-L137 |
30,322 | rethinkdb/rethinkdb-go | query_table.go | IndexStatus | func (t Term) IndexStatus(args ...interface{}) Term {
return constructMethodTerm(t, "IndexStatus", p.Term_INDEX_STATUS, args, map[string]interface{}{})
} | go | func (t Term) IndexStatus(args ...interface{}) Term {
return constructMethodTerm(t, "IndexStatus", p.Term_INDEX_STATUS, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexStatus",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_STATUS",
",",
"args",
",",
"map",
"[",
"string",
"]",
"i... | // IndexStatus gets the status of the specified indexes on this table, or the
// status of all indexes on this table if no indexes are specified. | [
"IndexStatus",
"gets",
"the",
"status",
"of",
"the",
"specified",
"indexes",
"on",
"this",
"table",
"or",
"the",
"status",
"of",
"all",
"indexes",
"on",
"this",
"table",
"if",
"no",
"indexes",
"are",
"specified",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L141-L143 |
30,323 | rethinkdb/rethinkdb-go | query_table.go | IndexWait | func (t Term) IndexWait(args ...interface{}) Term {
return constructMethodTerm(t, "IndexWait", p.Term_INDEX_WAIT, args, map[string]interface{}{})
} | go | func (t Term) IndexWait(args ...interface{}) Term {
return constructMethodTerm(t, "IndexWait", p.Term_INDEX_WAIT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IndexWait",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INDEX_WAIT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // IndexWait waits for the specified indexes on this table to be ready, or for
// all indexes on this table to be ready if no indexes are specified. | [
"IndexWait",
"waits",
"for",
"the",
"specified",
"indexes",
"on",
"this",
"table",
"to",
"be",
"ready",
"or",
"for",
"all",
"indexes",
"on",
"this",
"table",
"to",
"be",
"ready",
"if",
"no",
"indexes",
"are",
"specified",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L147-L149 |
30,324 | rethinkdb/rethinkdb-go | query_table.go | Changes | func (t Term) Changes(optArgs ...ChangesOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Changes", p.Term_CHANGES, []interface{}{}, opts)
} | go | func (t Term) Changes(optArgs ...ChangesOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Changes", p.Term_CHANGES, []interface{}{}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Changes",
"(",
"optArgs",
"...",
"ChangesOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
"optA... | // Changes returns an infinite stream of objects representing changes to a query. | [
"Changes",
"returns",
"an",
"infinite",
"stream",
"of",
"objects",
"representing",
"changes",
"to",
"a",
"query",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_table.go#L167-L173 |
30,325 | rethinkdb/rethinkdb-go | query_transformation.go | ConcatMap | func (t Term) ConcatMap(args ...interface{}) Term {
return constructMethodTerm(t, "ConcatMap", p.Term_CONCAT_MAP, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) ConcatMap(args ...interface{}) Term {
return constructMethodTerm(t, "ConcatMap", p.Term_CONCAT_MAP, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ConcatMap",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_CONCAT_MAP",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
... | // ConcatMap concatenates one or more elements into a single sequence using a
// mapping function. ConcatMap works in a similar fashion to Map, applying the
// given function to each element in a sequence, but it will always return a
// single sequence. | [
"ConcatMap",
"concatenates",
"one",
"or",
"more",
"elements",
"into",
"a",
"single",
"sequence",
"using",
"a",
"mapping",
"function",
".",
"ConcatMap",
"works",
"in",
"a",
"similar",
"fashion",
"to",
"Map",
"applying",
"the",
"given",
"function",
"to",
"each",... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L50-L52 |
30,326 | rethinkdb/rethinkdb-go | query_transformation.go | Skip | func (t Term) Skip(args ...interface{}) Term {
return constructMethodTerm(t, "Skip", p.Term_SKIP, args, map[string]interface{}{})
} | go | func (t Term) Skip(args ...interface{}) Term {
return constructMethodTerm(t, "Skip", p.Term_SKIP, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Skip",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SKIP",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Skip skips a number of elements from the head of the sequence. | [
"Skip",
"skips",
"a",
"number",
"of",
"elements",
"from",
"the",
"head",
"of",
"the",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L103-L105 |
30,327 | rethinkdb/rethinkdb-go | query_transformation.go | Limit | func (t Term) Limit(args ...interface{}) Term {
return constructMethodTerm(t, "Limit", p.Term_LIMIT, args, map[string]interface{}{})
} | go | func (t Term) Limit(args ...interface{}) Term {
return constructMethodTerm(t, "Limit", p.Term_LIMIT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Limit",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_LIMIT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Limit ends the sequence after the given number of elements. | [
"Limit",
"ends",
"the",
"sequence",
"after",
"the",
"given",
"number",
"of",
"elements",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L108-L110 |
30,328 | 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, ... | 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, ... | [
"func",
"(",
"t",
"Term",
")",
"Slice",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"var",
"opts",
"=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n\n",
"// Look for options map",
"if",
"len",
"(",
"args",
")",
"... | // Slice trims the sequence to within the bounds provided. | [
"Slice",
"trims",
"the",
"sequence",
"to",
"within",
"the",
"bounds",
"provided",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L123-L135 |
30,329 | rethinkdb/rethinkdb-go | query_transformation.go | AtIndex | func (t Term) AtIndex(args ...interface{}) Term {
return constructMethodTerm(t, "AtIndex", p.Term_BRACKET, args, map[string]interface{}{})
} | go | func (t Term) AtIndex(args ...interface{}) Term {
return constructMethodTerm(t, "AtIndex", p.Term_BRACKET, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"AtIndex",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_BRACKET",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // AtIndex gets a single field from an object or the nth element from a sequence. | [
"AtIndex",
"gets",
"a",
"single",
"field",
"from",
"an",
"object",
"or",
"the",
"nth",
"element",
"from",
"a",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L138-L140 |
30,330 | rethinkdb/rethinkdb-go | query_transformation.go | Nth | func (t Term) Nth(args ...interface{}) Term {
return constructMethodTerm(t, "Nth", p.Term_NTH, args, map[string]interface{}{})
} | go | func (t Term) Nth(args ...interface{}) Term {
return constructMethodTerm(t, "Nth", p.Term_NTH, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Nth",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_NTH",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Nth gets the nth element from a sequence. | [
"Nth",
"gets",
"the",
"nth",
"element",
"from",
"a",
"sequence",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L143-L145 |
30,331 | rethinkdb/rethinkdb-go | query_transformation.go | OffsetsOf | func (t Term) OffsetsOf(args ...interface{}) Term {
return constructMethodTerm(t, "OffsetsOf", p.Term_OFFSETS_OF, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) OffsetsOf(args ...interface{}) Term {
return constructMethodTerm(t, "OffsetsOf", p.Term_OFFSETS_OF, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"OffsetsOf",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_OFFSETS_OF",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
... | // OffsetsOf gets the indexes of an element in a sequence. If the argument is a
// predicate, get the indexes of all elements matching it. | [
"OffsetsOf",
"gets",
"the",
"indexes",
"of",
"an",
"element",
"in",
"a",
"sequence",
".",
"If",
"the",
"argument",
"is",
"a",
"predicate",
"get",
"the",
"indexes",
"of",
"all",
"elements",
"matching",
"it",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L149-L151 |
30,332 | rethinkdb/rethinkdb-go | query_transformation.go | IsEmpty | func (t Term) IsEmpty(args ...interface{}) Term {
return constructMethodTerm(t, "IsEmpty", p.Term_IS_EMPTY, args, map[string]interface{}{})
} | go | func (t Term) IsEmpty(args ...interface{}) Term {
return constructMethodTerm(t, "IsEmpty", p.Term_IS_EMPTY, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"IsEmpty",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_IS_EMPTY",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface... | // IsEmpty tests if a sequence is empty. | [
"IsEmpty",
"tests",
"if",
"a",
"sequence",
"is",
"empty",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L154-L156 |
30,333 | rethinkdb/rethinkdb-go | query_transformation.go | Union | func (t Term) Union(args ...interface{}) Term {
return constructMethodTerm(t, "Union", p.Term_UNION, args, map[string]interface{}{})
} | go | func (t Term) Union(args ...interface{}) Term {
return constructMethodTerm(t, "Union", p.Term_UNION, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Union",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_UNION",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Union concatenates two sequences. | [
"Union",
"concatenates",
"two",
"sequences",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L173-L175 |
30,334 | rethinkdb/rethinkdb-go | query_transformation.go | Sample | func (t Term) Sample(args ...interface{}) Term {
return constructMethodTerm(t, "Sample", p.Term_SAMPLE, args, map[string]interface{}{})
} | go | func (t Term) Sample(args ...interface{}) Term {
return constructMethodTerm(t, "Sample", p.Term_SAMPLE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Sample",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SAMPLE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Sample selects a given number of elements from a sequence with uniform random
// distribution. Selection is done without replacement. | [
"Sample",
"selects",
"a",
"given",
"number",
"of",
"elements",
"from",
"a",
"sequence",
"with",
"uniform",
"random",
"distribution",
".",
"Selection",
"is",
"done",
"without",
"replacement",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_transformation.go#L191-L193 |
30,335 | rethinkdb/rethinkdb-go | query_admin.go | Reconfigure | func (t Term) Reconfigure(optArgs ...ReconfigureOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts)
} | go | func (t Term) Reconfigure(optArgs ...ReconfigureOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Reconfigure",
"(",
"optArgs",
"...",
"ReconfigureOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",... | // Reconfigure a table's sharding and replication. | [
"Reconfigure",
"a",
"table",
"s",
"sharding",
"and",
"replication",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_admin.go#L34-L40 |
30,336 | rethinkdb/rethinkdb-go | query_admin.go | Grant | func (t Term) Grant(args ...interface{}) Term {
return constructMethodTerm(t, "Grant", p.Term_GRANT, args, map[string]interface{}{})
} | go | func (t Term) Grant(args ...interface{}) Term {
return constructMethodTerm(t, "Grant", p.Term_GRANT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Grant",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GRANT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Grant modifies access permissions for a user account, globally or on a
// per-database or per-table basis. | [
"Grant",
"modifies",
"access",
"permissions",
"for",
"a",
"user",
"account",
"globally",
"or",
"on",
"a",
"per",
"-",
"database",
"or",
"per",
"-",
"table",
"basis",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_admin.go#L83-L85 |
30,337 | 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.... | 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.... | [
"func",
"timePseudoTypeEncoder",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"t",
":=",
"v",
".",
"Interface",
"(",
")",
".",
"(",
"time",
".",
"Time",
")",
"\n\n",
"timeVal",
":=",
"float64",
"(",
"t... | // Pseudo-type encoders
// Encode a time.Time value to the TIME RQL type | [
"Pseudo",
"-",
"type",
"encoders",
"Encode",
"a",
"time",
".",
"Time",
"value",
"to",
"the",
"TIME",
"RQL",
"type"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoder_types.go#L377-L393 |
30,338 | rethinkdb/rethinkdb-go | encoding/encoder_types.go | encodeByteSlice | func encodeByteSlice(v reflect.Value) (interface{}, error) {
var b []byte
if !v.IsNil() {
b = v.Bytes()
}
dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
base64.StdEncoding.Encode(dst, b)
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": string(dst),
}, nil
} | go | func encodeByteSlice(v reflect.Value) (interface{}, error) {
var b []byte
if !v.IsNil() {
b = v.Bytes()
}
dst := make([]byte, base64.StdEncoding.EncodedLen(len(b)))
base64.StdEncoding.Encode(dst, b)
return map[string]interface{}{
"$reql_type$": "BINARY",
"data": string(dst),
}, nil
} | [
"func",
"encodeByteSlice",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"if",
"!",
"v",
".",
"IsNil",
"(",
")",
"{",
"b",
"=",
"v",
".",
"Bytes",
"(",
")",
"\n... | // Encode a byte slice to the BINARY RQL type | [
"Encode",
"a",
"byte",
"slice",
"to",
"the",
"BINARY",
"RQL",
"type"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoder_types.go#L396-L409 |
30,339 | 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",
... | 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",
... | [
"func",
"encodeByteArray",
"(",
"v",
"reflect",
".",
"Value",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"v",
".",
"Len",
"(",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
... | // Encode a byte array to the BINARY RQL type | [
"Encode",
"a",
"byte",
"array",
"to",
"the",
"BINARY",
"RQL",
"type"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/encoder_types.go#L412-L425 |
30,340 | 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 |
30,341 | rethinkdb/rethinkdb-go | query_string.go | Upcase | func (t Term) Upcase(args ...interface{}) Term {
return constructMethodTerm(t, "Upcase", p.Term_UPCASE, args, map[string]interface{}{})
} | go | func (t Term) Upcase(args ...interface{}) Term {
return constructMethodTerm(t, "Upcase", p.Term_UPCASE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Upcase",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_UPCASE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Upcase upper-cases a string. | [
"Upcase",
"upper",
"-",
"cases",
"a",
"string",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_string.go#L37-L39 |
30,342 | rethinkdb/rethinkdb-go | query_string.go | Downcase | func (t Term) Downcase(args ...interface{}) Term {
return constructMethodTerm(t, "Downcase", p.Term_DOWNCASE, args, map[string]interface{}{})
} | go | func (t Term) Downcase(args ...interface{}) Term {
return constructMethodTerm(t, "Downcase", p.Term_DOWNCASE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Downcase",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_DOWNCASE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfac... | // Downcase lower-cases a string. | [
"Downcase",
"lower",
"-",
"cases",
"a",
"string",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_string.go#L42-L44 |
30,343 | rethinkdb/rethinkdb-go | query_control.go | JS | func JS(jssrc interface{}, optArgs ...JSOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Js", p.Term_JAVASCRIPT, []interface{}{jssrc}, opts)
} | go | func JS(jssrc interface{}, optArgs ...JSOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Js", p.Term_JAVASCRIPT, []interface{}{jssrc}, opts)
} | [
"func",
"JS",
"(",
"jssrc",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"JSOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
... | // JS creates a JavaScript expression which is evaluated by the database when
// running the query. | [
"JS",
"creates",
"a",
"JavaScript",
"expression",
"which",
"is",
"evaluated",
"by",
"the",
"database",
"when",
"running",
"the",
"query",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L171-L177 |
30,344 | rethinkdb/rethinkdb-go | query_control.go | HTTP | func HTTP(url interface{}, optArgs ...HTTPOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Http", p.Term_HTTP, []interface{}{url}, opts)
} | go | func HTTP(url interface{}, optArgs ...HTTPOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Http", p.Term_HTTP, []interface{}{url}, opts)
} | [
"func",
"HTTP",
"(",
"url",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"HTTPOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",... | // HTTP retrieves data from the specified URL over HTTP. The return type depends
// on the resultFormat option, which checks the Content-Type of the response by
// default. | [
"HTTP",
"retrieves",
"data",
"from",
"the",
"specified",
"URL",
"over",
"HTTP",
".",
"The",
"return",
"type",
"depends",
"on",
"the",
"resultFormat",
"option",
"which",
"checks",
"the",
"Content",
"-",
"Type",
"of",
"the",
"response",
"by",
"default",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L207-L213 |
30,345 | rethinkdb/rethinkdb-go | query_control.go | Do | func Do(args ...interface{}) Term {
newArgs := []interface{}{}
newArgs = append(newArgs, funcWrap(args[len(args)-1]))
newArgs = append(newArgs, args[:len(args)-1]...)
return constructRootTerm("Do", p.Term_FUNCALL, newArgs, map[string]interface{}{})
} | go | func Do(args ...interface{}) Term {
newArgs := []interface{}{}
newArgs = append(newArgs, funcWrap(args[len(args)-1]))
newArgs = append(newArgs, args[:len(args)-1]...)
return constructRootTerm("Do", p.Term_FUNCALL, newArgs, map[string]interface{}{})
} | [
"func",
"Do",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"newArgs",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"newArgs",
"=",
"append",
"(",
"newArgs",
",",
"funcWrap",
"(",
"args",
"[",
"len",
"(",
"args",
")",
"-"... | // Do evaluates the expr in the context of one or more value bindings. The type of
// the result is the type of the value returned from expr. | [
"Do",
"evaluates",
"the",
"expr",
"in",
"the",
"context",
"of",
"one",
"or",
"more",
"value",
"bindings",
".",
"The",
"type",
"of",
"the",
"result",
"is",
"the",
"type",
"of",
"the",
"value",
"returned",
"from",
"expr",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L290-L296 |
30,346 | rethinkdb/rethinkdb-go | query_control.go | Branch | func (t Term) Branch(args ...interface{}) Term {
return constructMethodTerm(t, "Branch", p.Term_BRANCH, args, map[string]interface{}{})
} | go | func (t Term) Branch(args ...interface{}) Term {
return constructMethodTerm(t, "Branch", p.Term_BRANCH, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Branch",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_BRANCH",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Branch evaluates one of two control paths based on the value of an expression.
// branch is effectively an if renamed due to language constraints.
//
// The type of the result is determined by the type of the branch that gets executed. | [
"Branch",
"evaluates",
"one",
"of",
"two",
"control",
"paths",
"based",
"on",
"the",
"value",
"of",
"an",
"expression",
".",
"branch",
"is",
"effectively",
"an",
"if",
"renamed",
"due",
"to",
"language",
"constraints",
".",
"The",
"type",
"of",
"the",
"res... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L310-L312 |
30,347 | rethinkdb/rethinkdb-go | query_control.go | TypeOf | func (t Term) TypeOf(args ...interface{}) Term {
return constructMethodTerm(t, "TypeOf", p.Term_TYPE_OF, args, map[string]interface{}{})
} | go | func (t Term) TypeOf(args ...interface{}) Term {
return constructMethodTerm(t, "TypeOf", p.Term_TYPE_OF, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TypeOf",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TYPE_OF",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",... | // TypeOf gets the type of a value. | [
"TypeOf",
"gets",
"the",
"type",
"of",
"a",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L355-L357 |
30,348 | rethinkdb/rethinkdb-go | query_control.go | Info | func (t Term) Info(args ...interface{}) Term {
return constructMethodTerm(t, "Info", p.Term_INFO, args, map[string]interface{}{})
} | go | func (t Term) Info(args ...interface{}) Term {
return constructMethodTerm(t, "Info", p.Term_INFO, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Info",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INFO",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Info gets information about a RQL value. | [
"Info",
"gets",
"information",
"about",
"a",
"RQL",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L365-L367 |
30,349 | rethinkdb/rethinkdb-go | query_control.go | RawQuery | func RawQuery(q []byte) Term {
data := json.RawMessage(q)
return Term{
name: "RawQuery",
rootTerm: true,
rawQuery: true,
data: &data,
args: []Term{
Term{
termType: p.Term_DATUM,
data: string(q),
},
},
}
} | go | func RawQuery(q []byte) Term {
data := json.RawMessage(q)
return Term{
name: "RawQuery",
rootTerm: true,
rawQuery: true,
data: &data,
args: []Term{
Term{
termType: p.Term_DATUM,
data: string(q),
},
},
}
} | [
"func",
"RawQuery",
"(",
"q",
"[",
"]",
"byte",
")",
"Term",
"{",
"data",
":=",
"json",
".",
"RawMessage",
"(",
"q",
")",
"\n",
"return",
"Term",
"{",
"name",
":",
"\"",
"\"",
",",
"rootTerm",
":",
"true",
",",
"rawQuery",
":",
"true",
",",
"data... | // RawQuery creates a new query from a JSON string, this bypasses any encoding
// done by RethinkDB-go. The query should not contain the query type or any options
// as this should be handled using the normal driver API.
//
// THis query will only work if this is the only term in the query. | [
"RawQuery",
"creates",
"a",
"new",
"query",
"from",
"a",
"JSON",
"string",
"this",
"bypasses",
"any",
"encoding",
"done",
"by",
"RethinkDB",
"-",
"go",
".",
"The",
"query",
"should",
"not",
"contain",
"the",
"query",
"type",
"or",
"any",
"options",
"as",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_control.go#L381-L395 |
30,350 | 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.Ne... | 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.Ne... | [
"func",
"NewCountingConn",
"(",
"conn",
"net",
".",
"Conn",
")",
"net",
".",
"Conn",
"{",
"c",
":=",
"&",
"connCounting",
"{",
"Conn",
":",
"conn",
",",
"closed",
":",
"false",
",",
"}",
"\n",
"runtime",
".",
"SetFinalizer",
"(",
"c",
",",
"func",
... | // Socket leak debug net.Conn wrapper | [
"Socket",
"leak",
"debug",
"net",
".",
"Conn",
"wrapper"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/internal/utils/conn_counter.go#L30-L74 |
30,351 | 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... | 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... | [
"func",
"handleStdLog",
"(",
"e",
"*",
"Entry",
")",
"error",
"{",
"level",
":=",
"levelNames",
"[",
"e",
".",
"Level",
"]",
"\n\n",
"var",
"fields",
"[",
"]",
"field",
"\n\n",
"for",
"k",
",",
"v",
":=",
"range",
"e",
".",
"Fields",
"{",
"fields",... | // handleStdLog outpouts to the stlib log. | [
"handleStdLog",
"outpouts",
"to",
"the",
"stlib",
"log",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/default.go#L24-L45 |
30,352 | 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 |
30,353 | 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 |
30,354 | 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 |
30,355 | 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 |
30,356 | 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 |
30,357 | 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 |
30,358 | 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",
")",
"... | // 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 |
30,359 | 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",
"["... | // 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 |
30,360 | 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",
"(",
")",
",",
"Le... | // 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 |
30,361 | 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... | // ParseLevel parses level string. | [
"ParseLevel",
"parses",
"level",
"string",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/levels.go#L64-L71 |
30,362 | 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 |
30,363 | 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 |
30,364 | 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:
... | 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:
... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"loop",
"(",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"e",
":=",
"<-",
"h",
".",
"entries",
":",
"if",
... | // loop for rendering. | [
"loop",
"for",
"rendering",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/handlers/delta/delta.go#L107-L131 |
30,365 | 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",
... | // Names returns field names sorted. | [
"Names",
"returns",
"field",
"names",
"sorted",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/logger.go#L30-L37 |
30,366 | 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 |
30,367 | 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 |
30,368 | 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",
".",
... | // 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 |
30,369 | 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",
"... | // 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 |
30,370 | 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",
",",
... | // 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 |
30,371 | 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 |
30,372 | 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 |
30,373 | 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 |
30,374 | 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",
",",
"\... | // Faux upload. | [
"Faux",
"upload",
"."
] | d6c5facec1f2ae23a97782ab0ee18af58734346f | https://github.com/apex/log/blob/d6c5facec1f2ae23a97782ab0ee18af58734346f/_examples/stack/stack.go#L27-L34 |
30,375 | 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],... | 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],... | [
"func",
"insertSorted",
"(",
"u",
"nn",
",",
"v",
"[",
"]",
"nn",
",",
"K",
"int",
")",
"[",
"]",
"nn",
"{",
"low",
":=",
"0",
"\n",
"high",
":=",
"len",
"(",
"v",
")",
"-",
"1",
"\n",
"for",
"low",
"<=",
"high",
"{",
"mid",
":=",
"(",
"l... | // 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... | [
"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",
"t... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/cluster/knn.go#L136-L158 |
30,376 | 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 |
30,377 | 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",
"... | // 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 |
30,378 | 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 |
30,379 | 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",
"... | // 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 |
30,380 | 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"... | // 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 |
30,381 | 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.Err... | 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.Err... | [
"func",
"(",
"s",
"*",
"Softmax",
")",
"Learn",
"(",
")",
"error",
"{",
"if",
"s",
".",
"trainingSet",
"==",
"nil",
"||",
"s",
".",
"expectedResults",
"==",
"nil",
"{",
"err",
":=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"fmt",
... | // 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 |
30,382 | 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 |
30,383 | 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 |
30,384 | cdipaolo/goml | text/tfidf.go | TFIDF | func (t *TFIDF) TFIDF(word string, sentence string) float64 {
sentence, _, _ = transform.String(t.sanitize, sentence)
document := t.Tokenizer.Tokenize(sentence)
return t.TermFrequency(word, document) * t.InverseDocumentFrequency(word)
} | go | func (t *TFIDF) TFIDF(word string, sentence string) float64 {
sentence, _, _ = transform.String(t.sanitize, sentence)
document := t.Tokenizer.Tokenize(sentence)
return t.TermFrequency(word, document) * t.InverseDocumentFrequency(word)
} | [
"func",
"(",
"t",
"*",
"TFIDF",
")",
"TFIDF",
"(",
"word",
"string",
",",
"sentence",
"string",
")",
"float64",
"{",
"sentence",
",",
"_",
",",
"_",
"=",
"transform",
".",
"String",
"(",
"t",
".",
"sanitize",
",",
"sentence",
")",
"\n",
"document",
... | // TFIDF returns the TermFrequency-
// InverseDocumentFrequency of a word
// within a corpus given by the trained
// NaiveBayes model
//
// Look at the TFIDF docs to see more about how
// this is calculated | [
"TFIDF",
"returns",
"the",
"TermFrequency",
"-",
"InverseDocumentFrequency",
"of",
"a",
"word",
"within",
"a",
"corpus",
"given",
"by",
"the",
"trained",
"NaiveBayes",
"model",
"Look",
"at",
"the",
"TFIDF",
"docs",
"to",
"see",
"more",
"about",
"how",
"this",
... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L81-L86 |
30,385 | cdipaolo/goml | text/tfidf.go | MostImportantWords | func (t *TFIDF) MostImportantWords(sentence string, n int) Frequencies {
sentence, _, _ = transform.String(t.sanitize, sentence)
document := t.Tokenizer.Tokenize(sentence)
freq := TermFrequencies(document)
for i := range freq {
freq[i].TFIDF = freq[i].Frequency * t.InverseDocumentFrequency(freq[i].Word)
freq[i... | go | func (t *TFIDF) MostImportantWords(sentence string, n int) Frequencies {
sentence, _, _ = transform.String(t.sanitize, sentence)
document := t.Tokenizer.Tokenize(sentence)
freq := TermFrequencies(document)
for i := range freq {
freq[i].TFIDF = freq[i].Frequency * t.InverseDocumentFrequency(freq[i].Word)
freq[i... | [
"func",
"(",
"t",
"*",
"TFIDF",
")",
"MostImportantWords",
"(",
"sentence",
"string",
",",
"n",
"int",
")",
"Frequencies",
"{",
"sentence",
",",
"_",
",",
"_",
"=",
"transform",
".",
"String",
"(",
"t",
".",
"sanitize",
",",
"sentence",
")",
"\n",
"d... | // MostImportantWords runs TFIDF on a
// whole document, returning the n most
// important words in the document. If
// n is greater than the number of words
// then all words will be returned.
//
// The returned keyword slice is sorted
// by importance | [
"MostImportantWords",
"runs",
"TFIDF",
"on",
"a",
"whole",
"document",
"returning",
"the",
"n",
"most",
"important",
"words",
"in",
"the",
"document",
".",
"If",
"n",
"is",
"greater",
"than",
"the",
"number",
"of",
"words",
"then",
"all",
"words",
"will",
... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L96-L114 |
30,386 | cdipaolo/goml | text/tfidf.go | TermFrequency | func (t *TFIDF) TermFrequency(word string, document []string) float64 {
words := make(map[string]int)
for i := range document {
words[document[i]]++
}
// find max word frequency
var maxFreq int
for i := range words {
if words[i] > maxFreq {
maxFreq = words[i]
}
}
return 0.5 * (1 + float64(words[word]... | go | func (t *TFIDF) TermFrequency(word string, document []string) float64 {
words := make(map[string]int)
for i := range document {
words[document[i]]++
}
// find max word frequency
var maxFreq int
for i := range words {
if words[i] > maxFreq {
maxFreq = words[i]
}
}
return 0.5 * (1 + float64(words[word]... | [
"func",
"(",
"t",
"*",
"TFIDF",
")",
"TermFrequency",
"(",
"word",
"string",
",",
"document",
"[",
"]",
"string",
")",
"float64",
"{",
"words",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n",
"for",
"i",
":=",
"range",
"document",
"... | // TermFrequency returns the term frequency
// of a word within a corpus defined by the
// trained NaiveBayes model
//
// Look at the TFIDF docs to see more about how
// this is calculated | [
"TermFrequency",
"returns",
"the",
"term",
"frequency",
"of",
"a",
"word",
"within",
"a",
"corpus",
"defined",
"by",
"the",
"trained",
"NaiveBayes",
"model",
"Look",
"at",
"the",
"TFIDF",
"docs",
"to",
"see",
"more",
"about",
"how",
"this",
"is",
"calculated... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L122-L137 |
30,387 | cdipaolo/goml | text/tfidf.go | TermFrequencies | func TermFrequencies(document []string) Frequencies {
words := make(map[string]int)
for i := range document {
words[document[i]]++
}
var maxFreq int
for i := range words {
if words[i] > maxFreq {
maxFreq = words[i]
}
}
// make frequency map
frequencies := Frequencies{}
for i := range words {
frequ... | go | func TermFrequencies(document []string) Frequencies {
words := make(map[string]int)
for i := range document {
words[document[i]]++
}
var maxFreq int
for i := range words {
if words[i] > maxFreq {
maxFreq = words[i]
}
}
// make frequency map
frequencies := Frequencies{}
for i := range words {
frequ... | [
"func",
"TermFrequencies",
"(",
"document",
"[",
"]",
"string",
")",
"Frequencies",
"{",
"words",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
")",
"\n",
"for",
"i",
":=",
"range",
"document",
"{",
"words",
"[",
"document",
"[",
"i",
"]",
"]"... | // TermFrequencies gives the TermFrequency of
// all words in a document, and is more efficient
// at doing so than calling that function multiple
// times | [
"TermFrequencies",
"gives",
"the",
"TermFrequency",
"of",
"all",
"words",
"in",
"a",
"document",
"and",
"is",
"more",
"efficient",
"at",
"doing",
"so",
"than",
"calling",
"that",
"function",
"multiple",
"times"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L143-L166 |
30,388 | cdipaolo/goml | text/tfidf.go | InverseDocumentFrequency | func (t *TFIDF) InverseDocumentFrequency(word string) float64 {
w, _ := t.Words.Get(word)
return math.Log(float64(t.DocumentCount)) - math.Log(float64(w.DocsSeen)+1)
} | go | func (t *TFIDF) InverseDocumentFrequency(word string) float64 {
w, _ := t.Words.Get(word)
return math.Log(float64(t.DocumentCount)) - math.Log(float64(w.DocsSeen)+1)
} | [
"func",
"(",
"t",
"*",
"TFIDF",
")",
"InverseDocumentFrequency",
"(",
"word",
"string",
")",
"float64",
"{",
"w",
",",
"_",
":=",
"t",
".",
"Words",
".",
"Get",
"(",
"word",
")",
"\n",
"return",
"math",
".",
"Log",
"(",
"float64",
"(",
"t",
".",
... | // InverseDocumentFrequency returns the 'uniqueness'
// of a word within the corpus defined within a
// trained NaiveBayes model.
//
// Look at the TFIDF docs to see more about how
// this is calculated | [
"InverseDocumentFrequency",
"returns",
"the",
"uniqueness",
"of",
"a",
"word",
"within",
"the",
"corpus",
"defined",
"within",
"a",
"trained",
"NaiveBayes",
"model",
".",
"Look",
"at",
"the",
"TFIDF",
"docs",
"to",
"see",
"more",
"about",
"how",
"this",
"is",
... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/tfidf.go#L174-L177 |
30,389 | cdipaolo/goml | base/munge.go | NormalizePoint | func NormalizePoint(x []float64) {
var sum float64
for i := range x {
sum += x[i] * x[i]
}
mag := math.Sqrt(sum)
for i := range x {
if math.IsInf(x[i]/mag, 0) || math.IsNaN(x[i]/mag) {
// fallback to zero when dividing by 0
x[i] = 0
continue
}
x[i] /= mag
}
} | go | func NormalizePoint(x []float64) {
var sum float64
for i := range x {
sum += x[i] * x[i]
}
mag := math.Sqrt(sum)
for i := range x {
if math.IsInf(x[i]/mag, 0) || math.IsNaN(x[i]/mag) {
// fallback to zero when dividing by 0
x[i] = 0
continue
}
x[i] /= mag
}
} | [
"func",
"NormalizePoint",
"(",
"x",
"[",
"]",
"float64",
")",
"{",
"var",
"sum",
"float64",
"\n",
"for",
"i",
":=",
"range",
"x",
"{",
"sum",
"+=",
"x",
"[",
"i",
"]",
"*",
"x",
"[",
"i",
"]",
"\n",
"}",
"\n\n",
"mag",
":=",
"math",
".",
"Sqr... | // NormalizePoint is the same as Normalize,
// but it only operates on one singular datapoint,
// normalizing it's value to unit length. | [
"NormalizePoint",
"is",
"the",
"same",
"as",
"Normalize",
"but",
"it",
"only",
"operates",
"on",
"one",
"singular",
"datapoint",
"normalizing",
"it",
"s",
"value",
"to",
"unit",
"length",
"."
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/base/munge.go#L23-L41 |
30,390 | cdipaolo/goml | text/bayes.go | Tokenize | func (t *SimpleTokenizer) Tokenize(sentence string) []string {
// is the tokenizer really the best place to be making
// everything lowercase? is this really a sanitizaion func?
return strings.Split(strings.ToLower(sentence), t.SplitOn)
} | go | func (t *SimpleTokenizer) Tokenize(sentence string) []string {
// is the tokenizer really the best place to be making
// everything lowercase? is this really a sanitizaion func?
return strings.Split(strings.ToLower(sentence), t.SplitOn)
} | [
"func",
"(",
"t",
"*",
"SimpleTokenizer",
")",
"Tokenize",
"(",
"sentence",
"string",
")",
"[",
"]",
"string",
"{",
"// is the tokenizer really the best place to be making",
"// everything lowercase? is this really a sanitizaion func?",
"return",
"strings",
".",
"Split",
"(... | // Tokenize splits input sentences into a lowecase slice
// of strings. The tokenizer's SlitOn string is used as a
// delimiter and it | [
"Tokenize",
"splits",
"input",
"sentences",
"into",
"a",
"lowecase",
"slice",
"of",
"strings",
".",
"The",
"tokenizer",
"s",
"SlitOn",
"string",
"is",
"used",
"as",
"a",
"delimiter",
"and",
"it"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L186-L190 |
30,391 | cdipaolo/goml | text/bayes.go | Get | func (m *concurrentMap) Get(w string) (Word, bool) {
m.RLock()
result, ok := m.words[w]
m.RUnlock()
return result, ok
} | go | func (m *concurrentMap) Get(w string) (Word, bool) {
m.RLock()
result, ok := m.words[w]
m.RUnlock()
return result, ok
} | [
"func",
"(",
"m",
"*",
"concurrentMap",
")",
"Get",
"(",
"w",
"string",
")",
"(",
"Word",
",",
"bool",
")",
"{",
"m",
".",
"RLock",
"(",
")",
"\n",
"result",
",",
"ok",
":=",
"m",
".",
"words",
"[",
"w",
"]",
"\n",
"m",
".",
"RUnlock",
"(",
... | // Get looks up a word from h's Word map and should be used
// in place of a direct map lookup. The only caveat is that
// it will always return the 'success' boolean | [
"Get",
"looks",
"up",
"a",
"word",
"from",
"h",
"s",
"Word",
"map",
"and",
"should",
"be",
"used",
"in",
"place",
"of",
"a",
"direct",
"map",
"lookup",
".",
"The",
"only",
"caveat",
"is",
"that",
"it",
"will",
"always",
"return",
"the",
"success",
"b... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L215-L220 |
30,392 | cdipaolo/goml | text/bayes.go | Set | func (m *concurrentMap) Set(k string, v Word) {
m.Lock()
m.words[k] = v
m.Unlock()
} | go | func (m *concurrentMap) Set(k string, v Word) {
m.Lock()
m.words[k] = v
m.Unlock()
} | [
"func",
"(",
"m",
"*",
"concurrentMap",
")",
"Set",
"(",
"k",
"string",
",",
"v",
"Word",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"words",
"[",
"k",
"]",
"=",
"v",
"\n",
"m",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Set sets word k's value to v in h's Word map | [
"Set",
"sets",
"word",
"k",
"s",
"value",
"to",
"v",
"in",
"h",
"s",
"Word",
"map"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L223-L227 |
30,393 | cdipaolo/goml | text/bayes.go | NewNaiveBayes | func NewNaiveBayes(stream <-chan base.TextDatapoint, classes uint8, sanitize func(rune) bool) *NaiveBayes {
return &NaiveBayes{
Words: concurrentMap{sync.RWMutex{}, make(map[string]Word)},
Count: make([]uint64, classes),
Probabilities: make([]float64, classes),
sanitize: transform.RemoveFunc(... | go | func NewNaiveBayes(stream <-chan base.TextDatapoint, classes uint8, sanitize func(rune) bool) *NaiveBayes {
return &NaiveBayes{
Words: concurrentMap{sync.RWMutex{}, make(map[string]Word)},
Count: make([]uint64, classes),
Probabilities: make([]float64, classes),
sanitize: transform.RemoveFunc(... | [
"func",
"NewNaiveBayes",
"(",
"stream",
"<-",
"chan",
"base",
".",
"TextDatapoint",
",",
"classes",
"uint8",
",",
"sanitize",
"func",
"(",
"rune",
")",
"bool",
")",
"*",
"NaiveBayes",
"{",
"return",
"&",
"NaiveBayes",
"{",
"Words",
":",
"concurrentMap",
"{... | // NewNaiveBayes returns a NaiveBayes model the
// given number of classes instantiated, ready
// to learn off the given data stream. The sanitization
// function is set to the given function. It must
// comply with the transform.RemoveFunc interface | [
"NewNaiveBayes",
"returns",
"a",
"NaiveBayes",
"model",
"the",
"given",
"number",
"of",
"classes",
"instantiated",
"ready",
"to",
"learn",
"off",
"the",
"given",
"data",
"stream",
".",
"The",
"sanitization",
"function",
"is",
"set",
"to",
"the",
"given",
"func... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L259-L271 |
30,394 | cdipaolo/goml | text/bayes.go | Predict | func (b *NaiveBayes) Predict(sentence string) uint8 {
sums := make([]float64, len(b.Count))
sentence, _, _ = transform.String(b.sanitize, sentence)
words := b.Tokenizer.Tokenize(sentence)
for _, word := range words {
w, ok := b.Words.Get(word)
if !ok {
continue
}
for i := range sums {
sums[i] += mat... | go | func (b *NaiveBayes) Predict(sentence string) uint8 {
sums := make([]float64, len(b.Count))
sentence, _, _ = transform.String(b.sanitize, sentence)
words := b.Tokenizer.Tokenize(sentence)
for _, word := range words {
w, ok := b.Words.Get(word)
if !ok {
continue
}
for i := range sums {
sums[i] += mat... | [
"func",
"(",
"b",
"*",
"NaiveBayes",
")",
"Predict",
"(",
"sentence",
"string",
")",
"uint8",
"{",
"sums",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"b",
".",
"Count",
")",
")",
"\n\n",
"sentence",
",",
"_",
",",
"_",
"=",
"transfo... | // Predict takes in a document, predicts the
// class of the document based on the training
// data passed so far, and returns the class
// estimated for the document. | [
"Predict",
"takes",
"in",
"a",
"document",
"predicts",
"the",
"class",
"of",
"the",
"document",
"based",
"on",
"the",
"training",
"data",
"passed",
"so",
"far",
"and",
"returns",
"the",
"class",
"estimated",
"for",
"the",
"document",
"."
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L277-L306 |
30,395 | cdipaolo/goml | text/bayes.go | OnlineLearn | func (b *NaiveBayes) OnlineLearn(errors chan<- error) {
if errors == nil {
errors = make(chan error)
}
if b.stream == nil {
errors <- fmt.Errorf("ERROR: attempting to learn with nil data stream!\n")
close(errors)
return
}
fmt.Fprintf(b.Output, "Training:\n\tModel: Multinomial Naïve Bayes\n\tClasses: %v\n"... | go | func (b *NaiveBayes) OnlineLearn(errors chan<- error) {
if errors == nil {
errors = make(chan error)
}
if b.stream == nil {
errors <- fmt.Errorf("ERROR: attempting to learn with nil data stream!\n")
close(errors)
return
}
fmt.Fprintf(b.Output, "Training:\n\tModel: Multinomial Naïve Bayes\n\tClasses: %v\n"... | [
"func",
"(",
"b",
"*",
"NaiveBayes",
")",
"OnlineLearn",
"(",
"errors",
"chan",
"<-",
"error",
")",
"{",
"if",
"errors",
"==",
"nil",
"{",
"errors",
"=",
"make",
"(",
"chan",
"error",
")",
"\n",
"}",
"\n",
"if",
"b",
".",
"stream",
"==",
"nil",
"... | // OnlineLearn lets the NaiveBayes model learn
// from the datastream, waiting for new data to
// come into the stream from a separate goroutine | [
"OnlineLearn",
"lets",
"the",
"NaiveBayes",
"model",
"learn",
"from",
"the",
"datastream",
"waiting",
"for",
"new",
"data",
"to",
"come",
"into",
"the",
"stream",
"from",
"a",
"separate",
"goroutine"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L364-L441 |
30,396 | cdipaolo/goml | text/bayes.go | UpdateSanitize | func (b *NaiveBayes) UpdateSanitize(sanitize func(rune) bool) {
b.sanitize = transform.RemoveFunc(sanitize)
} | go | func (b *NaiveBayes) UpdateSanitize(sanitize func(rune) bool) {
b.sanitize = transform.RemoveFunc(sanitize)
} | [
"func",
"(",
"b",
"*",
"NaiveBayes",
")",
"UpdateSanitize",
"(",
"sanitize",
"func",
"(",
"rune",
")",
"bool",
")",
"{",
"b",
".",
"sanitize",
"=",
"transform",
".",
"RemoveFunc",
"(",
"sanitize",
")",
"\n",
"}"
] | // UpdateSanitize updates the NaiveBayes model's
// text sanitization transformation function | [
"UpdateSanitize",
"updates",
"the",
"NaiveBayes",
"model",
"s",
"text",
"sanitization",
"transformation",
"function"
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L451-L453 |
30,397 | cdipaolo/goml | text/bayes.go | RestoreWithFuncs | func (b *NaiveBayes) RestoreWithFuncs(data io.Reader, sanitizer func(rune) bool, tokenizer Tokenizer) error {
if b == nil {
return errors.New("Cannot restore a model to a nil pointer")
}
err := json.NewDecoder(data).Decode(b)
if err != nil {
return err
}
b.sanitize = transform.RemoveFunc(sanitizer)
b.Tokeniz... | go | func (b *NaiveBayes) RestoreWithFuncs(data io.Reader, sanitizer func(rune) bool, tokenizer Tokenizer) error {
if b == nil {
return errors.New("Cannot restore a model to a nil pointer")
}
err := json.NewDecoder(data).Decode(b)
if err != nil {
return err
}
b.sanitize = transform.RemoveFunc(sanitizer)
b.Tokeniz... | [
"func",
"(",
"b",
"*",
"NaiveBayes",
")",
"RestoreWithFuncs",
"(",
"data",
"io",
".",
"Reader",
",",
"sanitizer",
"func",
"(",
"rune",
")",
"bool",
",",
"tokenizer",
"Tokenizer",
")",
"error",
"{",
"if",
"b",
"==",
"nil",
"{",
"return",
"errors",
".",
... | // RestoreWithFuncs takes raw JSON data of a model and
// restores a model from it. The tokenizer and sanitizer
// passed in will be assigned to the restored model. | [
"RestoreWithFuncs",
"takes",
"raw",
"JSON",
"data",
"of",
"a",
"model",
"and",
"restores",
"a",
"model",
"from",
"it",
".",
"The",
"tokenizer",
"and",
"sanitizer",
"passed",
"in",
"will",
"be",
"assigned",
"to",
"the",
"restored",
"model",
"."
] | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/text/bayes.go#L513-L524 |
30,398 | cdipaolo/goml | cluster/triangle_kmeans.go | NewTriangleKMeans | func NewTriangleKMeans(k, maxIterations int, trainingSet [][]float64) *TriangleKMeans {
var features int
if len(trainingSet) != 0 {
features = len(trainingSet[0])
}
// start all guesses with the zero vector.
// they will be changed during learning
var guesses []int
var info []pointInfo
guesses = make([]int, ... | go | func NewTriangleKMeans(k, maxIterations int, trainingSet [][]float64) *TriangleKMeans {
var features int
if len(trainingSet) != 0 {
features = len(trainingSet[0])
}
// start all guesses with the zero vector.
// they will be changed during learning
var guesses []int
var info []pointInfo
guesses = make([]int, ... | [
"func",
"NewTriangleKMeans",
"(",
"k",
",",
"maxIterations",
"int",
",",
"trainingSet",
"[",
"]",
"[",
"]",
"float64",
")",
"*",
"TriangleKMeans",
"{",
"var",
"features",
"int",
"\n",
"if",
"len",
"(",
"trainingSet",
")",
"!=",
"0",
"{",
"features",
"=",... | // NewTriangleKMeans returns a pointer to the k-means
// model, which clusters given inputs in an
// unsupervised manner. The differences between
// this algorithm and the standard k-means++
// algorithm implemented in NewKMeans are discribed
// in the struct comments and in the paper URL
// found within those. | [
"NewTriangleKMeans",
"returns",
"a",
"pointer",
"to",
"the",
"k",
"-",
"means",
"model",
"which",
"clusters",
"given",
"inputs",
"in",
"an",
"unsupervised",
"manner",
".",
"The",
"differences",
"between",
"this",
"algorithm",
"and",
"the",
"standard",
"k",
"-"... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/cluster/triangle_kmeans.go#L183-L225 |
30,399 | cdipaolo/goml | cluster/triangle_kmeans.go | recalculateCentroids | func (k *TriangleKMeans) recalculateCentroids() [][]float64 {
classTotal := make([][]float64, len(k.Centroids))
classCount := make([]int64, len(k.Centroids))
for j := range k.Centroids {
classTotal[j] = make([]float64, len(k.trainingSet[0]))
}
for i, x := range k.trainingSet {
classCount[k.guesses[i]]++
fo... | go | func (k *TriangleKMeans) recalculateCentroids() [][]float64 {
classTotal := make([][]float64, len(k.Centroids))
classCount := make([]int64, len(k.Centroids))
for j := range k.Centroids {
classTotal[j] = make([]float64, len(k.trainingSet[0]))
}
for i, x := range k.trainingSet {
classCount[k.guesses[i]]++
fo... | [
"func",
"(",
"k",
"*",
"TriangleKMeans",
")",
"recalculateCentroids",
"(",
")",
"[",
"]",
"[",
"]",
"float64",
"{",
"classTotal",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"float64",
",",
"len",
"(",
"k",
".",
"Centroids",
")",
")",
"\n",
"classCount",
... | // recalculateCentroids assigns each centroid to
// the mean of all points assigned to it. This
// method is abstracted within the Triangle
// accelerated KMeans variant because you are
// skipping a lot of distance calculations within
// the actual algorithm, so finding the mean of
// assigned points is harder to embe... | [
"recalculateCentroids",
"assigns",
"each",
"centroid",
"to",
"the",
"mean",
"of",
"all",
"points",
"assigned",
"to",
"it",
".",
"This",
"method",
"is",
"abstracted",
"within",
"the",
"Triangle",
"accelerated",
"KMeans",
"variant",
"because",
"you",
"are",
"skipp... | e1f51f7135988cf33ef5feafa6d1558e4f28d981 | https://github.com/cdipaolo/goml/blob/e1f51f7135988cf33ef5feafa6d1558e4f28d981/cluster/triangle_kmeans.go#L341-L373 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.