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,200 | rethinkdb/rethinkdb-go | cursor.go | All | func (c *Cursor) All(result interface{}) error {
if c == nil {
return errNilCursor
}
resultv := reflect.ValueOf(result)
if resultv.Kind() != reflect.Ptr || resultv.Elem().Kind() != reflect.Slice {
panic("result argument must be a slice address")
}
slicev := resultv.Elem()
slicev = slicev.Slice(0, slicev.Cap... | go | func (c *Cursor) All(result interface{}) error {
if c == nil {
return errNilCursor
}
resultv := reflect.ValueOf(result)
if resultv.Kind() != reflect.Ptr || resultv.Elem().Kind() != reflect.Slice {
panic("result argument must be a slice address")
}
slicev := resultv.Elem()
slicev = slicev.Slice(0, slicev.Cap... | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"All",
"(",
"result",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"errNilCursor",
"\n",
"}",
"\n\n",
"resultv",
":=",
"reflect",
".",
"ValueOf",
"(",
"result",
")",
"\n",
"i... | // All retrieves all documents from the result set into the provided slice
// and closes the cursor.
//
// The result argument must necessarily be the address for a slice. The slice
// may be nil or previously allocated.
//
// Also note that you are able to reuse the same variable multiple times as
// `All` zeroes the ... | [
"All",
"retrieves",
"all",
"documents",
"from",
"the",
"result",
"set",
"into",
"the",
"provided",
"slice",
"and",
"closes",
"the",
"cursor",
".",
"The",
"result",
"argument",
"must",
"necessarily",
"be",
"the",
"address",
"for",
"a",
"slice",
".",
"The",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L359-L399 |
30,201 | rethinkdb/rethinkdb-go | cursor.go | One | func (c *Cursor) One(result interface{}) error {
if c == nil {
return errNilCursor
}
if c.IsNil() {
c.Close()
return ErrEmptyResult
}
hasResult := c.Next(result)
if err := c.Err(); err != nil {
c.Close()
return err
}
if err := c.Close(); err != nil {
return err
}
if !hasResult {
return ErrE... | go | func (c *Cursor) One(result interface{}) error {
if c == nil {
return errNilCursor
}
if c.IsNil() {
c.Close()
return ErrEmptyResult
}
hasResult := c.Next(result)
if err := c.Err(); err != nil {
c.Close()
return err
}
if err := c.Close(); err != nil {
return err
}
if !hasResult {
return ErrE... | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"One",
"(",
"result",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"errNilCursor",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"IsNil",
"(",
")",
"{",
"c",
".",
"Close",
"(",
")",... | // One retrieves a single document from the result set into the provided
// slice and closes the cursor.
//
// Also note that you are able to reuse the same variable multiple times as
// `One` zeroes the value before scanning in the result. | [
"One",
"retrieves",
"a",
"single",
"document",
"from",
"the",
"result",
"set",
"into",
"the",
"provided",
"slice",
"and",
"closes",
"the",
"cursor",
".",
"Also",
"note",
"that",
"you",
"are",
"able",
"to",
"reuse",
"the",
"same",
"variable",
"multiple",
"t... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L406-L432 |
30,202 | rethinkdb/rethinkdb-go | cursor.go | IsNil | func (c *Cursor) IsNil() bool {
if c == nil {
return true
}
c.mu.RLock()
defer c.mu.RUnlock()
if len(c.buffer) > 0 {
return c.buffer[0] == nil
}
if len(c.responses) > 0 {
response := c.responses[0]
if response == nil {
return true
}
if string(response) == "null" {
return true
}
return ... | go | func (c *Cursor) IsNil() bool {
if c == nil {
return true
}
c.mu.RLock()
defer c.mu.RUnlock()
if len(c.buffer) > 0 {
return c.buffer[0] == nil
}
if len(c.responses) > 0 {
response := c.responses[0]
if response == nil {
return true
}
if string(response) == "null" {
return true
}
return ... | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"IsNil",
"(",
")",
"bool",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
... | // IsNil tests if the current row is nil. | [
"IsNil",
"tests",
"if",
"the",
"current",
"row",
"is",
"nil",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L507-L533 |
30,203 | rethinkdb/rethinkdb-go | cursor.go | fetchMore | func (c *Cursor) fetchMore() error {
var err error
if !c.fetching {
c.fetching = true
if c.closed {
return errCursorClosed
}
q := Query{
Type: p.Query_CONTINUE,
Token: c.token,
}
c.mu.Unlock()
_, _, err = c.conn.Query(c.ctx, q)
c.mu.Lock()
}
return err
} | go | func (c *Cursor) fetchMore() error {
var err error
if !c.fetching {
c.fetching = true
if c.closed {
return errCursorClosed
}
q := Query{
Type: p.Query_CONTINUE,
Token: c.token,
}
c.mu.Unlock()
_, _, err = c.conn.Query(c.ctx, q)
c.mu.Lock()
}
return err
} | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"fetchMore",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"if",
"!",
"c",
".",
"fetching",
"{",
"c",
".",
"fetching",
"=",
"true",
"\n\n",
"if",
"c",
".",
"closed",
"{",
"return",
"errCursorClosed",
"... | // fetchMore fetches more rows from the database.
//
// If wait is true then it will wait for the database to reply otherwise it
// will return after sending the continue query. | [
"fetchMore",
"fetches",
"more",
"rows",
"from",
"the",
"database",
".",
"If",
"wait",
"is",
"true",
"then",
"it",
"will",
"wait",
"for",
"the",
"database",
"to",
"reply",
"otherwise",
"it",
"will",
"return",
"after",
"sending",
"the",
"continue",
"query",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L539-L560 |
30,204 | rethinkdb/rethinkdb-go | cursor.go | handleError | func (c *Cursor) handleError(err error) error {
c.mu.Lock()
defer c.mu.Unlock()
return c.handleErrorLocked(err)
} | go | func (c *Cursor) handleError(err error) error {
c.mu.Lock()
defer c.mu.Unlock()
return c.handleErrorLocked(err)
} | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"handleError",
"(",
"err",
"error",
")",
"error",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"c",
".",
"handleErrorLocked",
"(",
"err... | // handleError sets the value of lastErr to err if lastErr is not yet set. | [
"handleError",
"sets",
"the",
"value",
"of",
"lastErr",
"to",
"err",
"if",
"lastErr",
"is",
"not",
"yet",
"set",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L563-L568 |
30,205 | rethinkdb/rethinkdb-go | cursor.go | extend | func (c *Cursor) extend(response *Response) {
c.mu.Lock()
defer c.mu.Unlock()
c.extendLocked(response)
} | go | func (c *Cursor) extend(response *Response) {
c.mu.Lock()
defer c.mu.Unlock()
c.extendLocked(response)
} | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"extend",
"(",
"response",
"*",
"Response",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
".",
"extendLocked",
"(",
"response",
")",
"... | // extend adds the result of a continue query to the cursor. | [
"extend",
"adds",
"the",
"result",
"of",
"a",
"continue",
"query",
"to",
"the",
"cursor",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L579-L584 |
30,206 | rethinkdb/rethinkdb-go | cursor.go | seekCursor | func (c *Cursor) seekCursor(bufferResponse bool) error {
if c.lastErr != nil {
return c.lastErr
}
if len(c.buffer) == 0 && len(c.responses) == 0 && c.closed {
return errCursorClosed
}
// Loop over loading data, applying skips as necessary and loading more data as needed
// until either the cursor is closed ... | go | func (c *Cursor) seekCursor(bufferResponse bool) error {
if c.lastErr != nil {
return c.lastErr
}
if len(c.buffer) == 0 && len(c.responses) == 0 && c.closed {
return errCursorClosed
}
// Loop over loading data, applying skips as necessary and loading more data as needed
// until either the cursor is closed ... | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"seekCursor",
"(",
"bufferResponse",
"bool",
")",
"error",
"{",
"if",
"c",
".",
"lastErr",
"!=",
"nil",
"{",
"return",
"c",
".",
"lastErr",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"c",
".",
"buffer",
")",
"==",
... | // seekCursor takes care of loading more data if needed and applying pending skips
//
// bufferResponse determines whether the response will be parsed into the buffer | [
"seekCursor",
"takes",
"care",
"of",
"loading",
"more",
"data",
"if",
"needed",
"and",
"applying",
"pending",
"skips",
"bufferResponse",
"determines",
"whether",
"the",
"response",
"will",
"be",
"parsed",
"into",
"the",
"buffer"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L596-L628 |
30,207 | rethinkdb/rethinkdb-go | cursor.go | applyPendingSkips | func (c *Cursor) applyPendingSkips(drainFromBuffer bool) (stillPending bool) {
if c.pendingSkips == 0 {
return false
}
if drainFromBuffer {
if len(c.buffer) > c.pendingSkips {
c.buffer = c.buffer[c.pendingSkips:]
c.pendingSkips = 0
return false
}
c.pendingSkips -= len(c.buffer)
c.buffer = c.buff... | go | func (c *Cursor) applyPendingSkips(drainFromBuffer bool) (stillPending bool) {
if c.pendingSkips == 0 {
return false
}
if drainFromBuffer {
if len(c.buffer) > c.pendingSkips {
c.buffer = c.buffer[c.pendingSkips:]
c.pendingSkips = 0
return false
}
c.pendingSkips -= len(c.buffer)
c.buffer = c.buff... | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"applyPendingSkips",
"(",
"drainFromBuffer",
"bool",
")",
"(",
"stillPending",
"bool",
")",
"{",
"if",
"c",
".",
"pendingSkips",
"==",
"0",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"drainFromBuffer",
"{",
"if... | // applyPendingSkips applies all pending skips to the buffer and
// returns whether there are more pending skips to be applied
//
// if drainFromBuffer is true, we will drain from the buffer, otherwise
// we drain from the responses | [
"applyPendingSkips",
"applies",
"all",
"pending",
"skips",
"to",
"the",
"buffer",
"and",
"returns",
"whether",
"there",
"are",
"more",
"pending",
"skips",
"to",
"be",
"applied",
"if",
"drainFromBuffer",
"is",
"true",
"we",
"will",
"drain",
"from",
"the",
"buff... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L635-L661 |
30,208 | rethinkdb/rethinkdb-go | cursor.go | bufferNextResponse | func (c *Cursor) bufferNextResponse() error {
if c.closed {
return errCursorClosed
}
// If there are no responses, nothing to do
if len(c.responses) == 0 {
return nil
}
response := c.responses[0]
c.responses = c.responses[1:]
var value interface{}
decoder := json.NewDecoder(bytes.NewBuffer(response))
if... | go | func (c *Cursor) bufferNextResponse() error {
if c.closed {
return errCursorClosed
}
// If there are no responses, nothing to do
if len(c.responses) == 0 {
return nil
}
response := c.responses[0]
c.responses = c.responses[1:]
var value interface{}
decoder := json.NewDecoder(bytes.NewBuffer(response))
if... | [
"func",
"(",
"c",
"*",
"Cursor",
")",
"bufferNextResponse",
"(",
")",
"error",
"{",
"if",
"c",
".",
"closed",
"{",
"return",
"errCursorClosed",
"\n",
"}",
"\n",
"// If there are no responses, nothing to do",
"if",
"len",
"(",
"c",
".",
"responses",
")",
"=="... | // bufferResponse reads a single response and stores the result into the buffer
// if the response is from an atomic response, it will check if the
// response contains multiple records and store them all into the buffer | [
"bufferResponse",
"reads",
"a",
"single",
"response",
"and",
"stores",
"the",
"result",
"into",
"the",
"buffer",
"if",
"the",
"response",
"is",
"from",
"an",
"atomic",
"response",
"it",
"will",
"check",
"if",
"the",
"response",
"contains",
"multiple",
"records... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cursor.go#L666-L708 |
30,209 | rethinkdb/rethinkdb-go | query_manipulation.go | Field | func (t Term) Field(args ...interface{}) Term {
return constructMethodTerm(t, "Field", p.Term_GET_FIELD, args, map[string]interface{}{})
} | go | func (t Term) Field(args ...interface{}) Term {
return constructMethodTerm(t, "Field", p.Term_GET_FIELD, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Field",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GET_FIELD",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // Field gets a single field from an object. If called on a sequence, gets that field
// from every object in the sequence, skipping objects that lack it. | [
"Field",
"gets",
"a",
"single",
"field",
"from",
"an",
"object",
".",
"If",
"called",
"on",
"a",
"sequence",
"gets",
"that",
"field",
"from",
"every",
"object",
"in",
"the",
"sequence",
"skipping",
"objects",
"that",
"lack",
"it",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L22-L24 |
30,210 | rethinkdb/rethinkdb-go | query_manipulation.go | Without | func (t Term) Without(args ...interface{}) Term {
return constructMethodTerm(t, "Without", p.Term_WITHOUT, args, map[string]interface{}{})
} | go | func (t Term) Without(args ...interface{}) Term {
return constructMethodTerm(t, "Without", p.Term_WITHOUT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Without",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_WITHOUT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // Without is the opposite of pluck; takes an object or a sequence of objects, and returns
// them with the specified paths removed. | [
"Without",
"is",
"the",
"opposite",
"of",
"pluck",
";",
"takes",
"an",
"object",
"or",
"a",
"sequence",
"of",
"objects",
"and",
"returns",
"them",
"with",
"the",
"specified",
"paths",
"removed",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L41-L43 |
30,211 | rethinkdb/rethinkdb-go | query_manipulation.go | Merge | func (t Term) Merge(args ...interface{}) Term {
return constructMethodTerm(t, "Merge", p.Term_MERGE, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Merge(args ...interface{}) Term {
return constructMethodTerm(t, "Merge", p.Term_MERGE, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Merge",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MERGE",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"s... | // Merge merges two objects together to construct a new object with properties from both.
// Gives preference to attributes from other when there is a conflict. | [
"Merge",
"merges",
"two",
"objects",
"together",
"to",
"construct",
"a",
"new",
"object",
"with",
"properties",
"from",
"both",
".",
"Gives",
"preference",
"to",
"attributes",
"from",
"other",
"when",
"there",
"is",
"a",
"conflict",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L47-L49 |
30,212 | rethinkdb/rethinkdb-go | query_manipulation.go | Append | func (t Term) Append(args ...interface{}) Term {
return constructMethodTerm(t, "Append", p.Term_APPEND, args, map[string]interface{}{})
} | go | func (t Term) Append(args ...interface{}) Term {
return constructMethodTerm(t, "Append", p.Term_APPEND, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Append",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_APPEND",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Append appends a value to an array. | [
"Append",
"appends",
"a",
"value",
"to",
"an",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L52-L54 |
30,213 | rethinkdb/rethinkdb-go | query_manipulation.go | Prepend | func (t Term) Prepend(args ...interface{}) Term {
return constructMethodTerm(t, "Prepend", p.Term_PREPEND, args, map[string]interface{}{})
} | go | func (t Term) Prepend(args ...interface{}) Term {
return constructMethodTerm(t, "Prepend", p.Term_PREPEND, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Prepend",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_PREPEND",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // Prepend prepends a value to an array. | [
"Prepend",
"prepends",
"a",
"value",
"to",
"an",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L57-L59 |
30,214 | rethinkdb/rethinkdb-go | query_manipulation.go | Difference | func (t Term) Difference(args ...interface{}) Term {
return constructMethodTerm(t, "Difference", p.Term_DIFFERENCE, args, map[string]interface{}{})
} | go | func (t Term) Difference(args ...interface{}) Term {
return constructMethodTerm(t, "Difference", p.Term_DIFFERENCE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Difference",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_DIFFERENCE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inte... | // Difference removes the elements of one array from another array. | [
"Difference",
"removes",
"the",
"elements",
"of",
"one",
"array",
"from",
"another",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L62-L64 |
30,215 | rethinkdb/rethinkdb-go | query_manipulation.go | InsertAt | func (t Term) InsertAt(args ...interface{}) Term {
return constructMethodTerm(t, "InsertAt", p.Term_INSERT_AT, args, map[string]interface{}{})
} | go | func (t Term) InsertAt(args ...interface{}) Term {
return constructMethodTerm(t, "InsertAt", p.Term_INSERT_AT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"InsertAt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INSERT_AT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfa... | // InsertAt inserts a value in to an array at a given index. Returns the modified array. | [
"InsertAt",
"inserts",
"a",
"value",
"in",
"to",
"an",
"array",
"at",
"a",
"given",
"index",
".",
"Returns",
"the",
"modified",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L90-L92 |
30,216 | rethinkdb/rethinkdb-go | query_manipulation.go | SpliceAt | func (t Term) SpliceAt(args ...interface{}) Term {
return constructMethodTerm(t, "SpliceAt", p.Term_SPLICE_AT, args, map[string]interface{}{})
} | go | func (t Term) SpliceAt(args ...interface{}) Term {
return constructMethodTerm(t, "SpliceAt", p.Term_SPLICE_AT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"SpliceAt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SPLICE_AT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfa... | // SpliceAt inserts several values in to an array at a given index. Returns the modified array. | [
"SpliceAt",
"inserts",
"several",
"values",
"in",
"to",
"an",
"array",
"at",
"a",
"given",
"index",
".",
"Returns",
"the",
"modified",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L95-L97 |
30,217 | rethinkdb/rethinkdb-go | query_manipulation.go | DeleteAt | func (t Term) DeleteAt(args ...interface{}) Term {
return constructMethodTerm(t, "DeleteAt", p.Term_DELETE_AT, args, map[string]interface{}{})
} | go | func (t Term) DeleteAt(args ...interface{}) Term {
return constructMethodTerm(t, "DeleteAt", p.Term_DELETE_AT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"DeleteAt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_DELETE_AT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfa... | // DeleteAt removes an element from an array at a given index. Returns the modified array. | [
"DeleteAt",
"removes",
"an",
"element",
"from",
"an",
"array",
"at",
"a",
"given",
"index",
".",
"Returns",
"the",
"modified",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L100-L102 |
30,218 | rethinkdb/rethinkdb-go | query_manipulation.go | ChangeAt | func (t Term) ChangeAt(args ...interface{}) Term {
return constructMethodTerm(t, "ChangeAt", p.Term_CHANGE_AT, args, map[string]interface{}{})
} | go | func (t Term) ChangeAt(args ...interface{}) Term {
return constructMethodTerm(t, "ChangeAt", p.Term_CHANGE_AT, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ChangeAt",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_CHANGE_AT",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfa... | // ChangeAt changes a value in an array at a given index. Returns the modified array. | [
"ChangeAt",
"changes",
"a",
"value",
"in",
"an",
"array",
"at",
"a",
"given",
"index",
".",
"Returns",
"the",
"modified",
"array",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L105-L107 |
30,219 | rethinkdb/rethinkdb-go | query_manipulation.go | Keys | func (t Term) Keys(args ...interface{}) Term {
return constructMethodTerm(t, "Keys", p.Term_KEYS, args, map[string]interface{}{})
} | go | func (t Term) Keys(args ...interface{}) Term {
return constructMethodTerm(t, "Keys", p.Term_KEYS, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Keys",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_KEYS",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Keys returns an array containing all of the object's keys. | [
"Keys",
"returns",
"an",
"array",
"containing",
"all",
"of",
"the",
"object",
"s",
"keys",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_manipulation.go#L110-L112 |
30,220 | rethinkdb/rethinkdb-go | pseudotypes.go | reqlTimeToNativeTime | func reqlTimeToNativeTime(timestamp float64, timezone string) (time.Time, error) {
sec, ms := math.Modf(timestamp)
// Convert to native time rounding to milliseconds
t := time.Unix(int64(sec), int64(math.Floor(ms*1000+0.5))*1000*1000)
// Caclulate the timezone
if timezone != "" {
hours, err := strconv.Atoi(tim... | go | func reqlTimeToNativeTime(timestamp float64, timezone string) (time.Time, error) {
sec, ms := math.Modf(timestamp)
// Convert to native time rounding to milliseconds
t := time.Unix(int64(sec), int64(math.Floor(ms*1000+0.5))*1000*1000)
// Caclulate the timezone
if timezone != "" {
hours, err := strconv.Atoi(tim... | [
"func",
"reqlTimeToNativeTime",
"(",
"timestamp",
"float64",
",",
"timezone",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"sec",
",",
"ms",
":=",
"math",
".",
"Modf",
"(",
"timestamp",
")",
"\n\n",
"// Convert to native time rounding to mi... | // Pseudo-type helper functions | [
"Pseudo",
"-",
"type",
"helper",
"functions"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/pseudotypes.go#L128-L153 |
30,221 | rethinkdb/rethinkdb-go | query_write.go | Insert | func (t Term) Insert(arg interface{}, optArgs ...InsertOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Insert", p.Term_INSERT, []interface{}{Expr(arg)}, opts)
} | go | func (t Term) Insert(arg interface{}, optArgs ...InsertOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Insert", p.Term_INSERT, []interface{}{Expr(arg)}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Insert",
"(",
"arg",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"InsertOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
"... | // Insert documents into a table. Accepts a single document or an array
// of documents. | [
"Insert",
"documents",
"into",
"a",
"table",
".",
"Accepts",
"a",
"single",
"document",
"or",
"an",
"array",
"of",
"documents",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_write.go#L20-L26 |
30,222 | rethinkdb/rethinkdb-go | query_write.go | Update | func (t Term) Update(arg interface{}, optArgs ...UpdateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Update", p.Term_UPDATE, []interface{}{funcWrap(arg)}, opts)
} | go | func (t Term) Update(arg interface{}, optArgs ...UpdateOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Update", p.Term_UPDATE, []interface{}{funcWrap(arg)}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Update",
"(",
"arg",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"UpdateOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
"... | // Update JSON documents in a table. Accepts a JSON document, a ReQL expression,
// or a combination of the two. You can pass options like returnChanges that will
// return the old and new values of the row you have modified. | [
"Update",
"JSON",
"documents",
"in",
"a",
"table",
".",
"Accepts",
"a",
"JSON",
"document",
"a",
"ReQL",
"expression",
"or",
"a",
"combination",
"of",
"the",
"two",
".",
"You",
"can",
"pass",
"options",
"like",
"returnChanges",
"that",
"will",
"return",
"t... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_write.go#L43-L49 |
30,223 | rethinkdb/rethinkdb-go | query_write.go | Replace | func (t Term) Replace(arg interface{}, optArgs ...ReplaceOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Replace", p.Term_REPLACE, []interface{}{funcWrap(arg)}, opts)
} | go | func (t Term) Replace(arg interface{}, optArgs ...ReplaceOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Replace", p.Term_REPLACE, []interface{}{funcWrap(arg)}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Replace",
"(",
"arg",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"ReplaceOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
... | // Replace documents in a table. Accepts a JSON document or a ReQL expression,
// and replaces the original document with the new one. The new document must
// have the same primary key as the original document. | [
"Replace",
"documents",
"in",
"a",
"table",
".",
"Accepts",
"a",
"JSON",
"document",
"or",
"a",
"ReQL",
"expression",
"and",
"replaces",
"the",
"original",
"document",
"with",
"the",
"new",
"one",
".",
"The",
"new",
"document",
"must",
"have",
"the",
"same... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_write.go#L65-L71 |
30,224 | rethinkdb/rethinkdb-go | query_write.go | Delete | func (t Term) Delete(optArgs ...DeleteOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Delete", p.Term_DELETE, []interface{}{}, opts)
} | go | func (t Term) Delete(optArgs ...DeleteOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Delete", p.Term_DELETE, []interface{}{}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"Delete",
"(",
"optArgs",
"...",
"DeleteOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",
"=",
"optArg... | // Delete one or more documents from a table. | [
"Delete",
"one",
"or",
"more",
"documents",
"from",
"a",
"table",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_write.go#L84-L90 |
30,225 | rethinkdb/rethinkdb-go | query_write.go | Sync | func (t Term) Sync(args ...interface{}) Term {
return constructMethodTerm(t, "Sync", p.Term_SYNC, args, map[string]interface{}{})
} | go | func (t Term) Sync(args ...interface{}) Term {
return constructMethodTerm(t, "Sync", p.Term_SYNC, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Sync",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SYNC",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Sync ensures that writes on a given table are written to permanent storage.
// Queries that specify soft durability do not give such guarantees, so Sync
// can be used to ensure the state of these queries. A call to Sync does not
// return until all previous writes to the table are persisted. | [
"Sync",
"ensures",
"that",
"writes",
"on",
"a",
"given",
"table",
"are",
"written",
"to",
"permanent",
"storage",
".",
"Queries",
"that",
"specify",
"soft",
"durability",
"do",
"not",
"give",
"such",
"guarantees",
"so",
"Sync",
"can",
"be",
"used",
"to",
"... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_write.go#L96-L98 |
30,226 | rethinkdb/rethinkdb-go | connection.go | NewConnection | func NewConnection(address string, opts *ConnectOpts) (*Connection, error) {
keepAlivePeriod := defaultKeepAlivePeriod
if opts.KeepAlivePeriod > 0 {
keepAlivePeriod = opts.KeepAlivePeriod
}
// Connect to Server
var err error
var conn net.Conn
nd := net.Dialer{Timeout: opts.Timeout, KeepAlive: keepAlivePeriod}... | go | func NewConnection(address string, opts *ConnectOpts) (*Connection, error) {
keepAlivePeriod := defaultKeepAlivePeriod
if opts.KeepAlivePeriod > 0 {
keepAlivePeriod = opts.KeepAlivePeriod
}
// Connect to Server
var err error
var conn net.Conn
nd := net.Dialer{Timeout: opts.Timeout, KeepAlive: keepAlivePeriod}... | [
"func",
"NewConnection",
"(",
"address",
"string",
",",
"opts",
"*",
"ConnectOpts",
")",
"(",
"*",
"Connection",
",",
"error",
")",
"{",
"keepAlivePeriod",
":=",
"defaultKeepAlivePeriod",
"\n",
"if",
"opts",
".",
"KeepAlivePeriod",
">",
"0",
"{",
"keepAlivePer... | // NewConnection creates a new connection to the database server | [
"NewConnection",
"creates",
"a",
"new",
"connection",
"to",
"the",
"database",
"server"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection.go#L82-L116 |
30,227 | rethinkdb/rethinkdb-go | connection.go | Close | func (c *Connection) Close() error {
var err error
c.mu.Lock()
defer c.mu.Unlock()
if !c.isClosed() {
c.setClosed()
close(c.stopReadChan)
err = c.Conn.Close()
}
return err
} | go | func (c *Connection) Close() error {
var err error
c.mu.Lock()
defer c.mu.Unlock()
if !c.isClosed() {
c.setClosed()
close(c.stopReadChan)
err = c.Conn.Close()
}
return err
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Close",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"c",
".",
"isClosed",
... | // Close closes the underlying net.Conn | [
"Close",
"closes",
"the",
"underlying",
"net",
".",
"Conn"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection.go#L139-L152 |
30,228 | rethinkdb/rethinkdb-go | connection.go | Query | func (c *Connection) Query(ctx context.Context, q Query) (*Response, *Cursor, error) {
if c == nil {
return nil, nil, ErrConnectionClosed
}
if c.Conn == nil || c.isClosed() {
c.setBad()
return nil, nil, ErrConnectionClosed
}
if ctx == nil {
ctx = c.contextFromConnectionOpts()
}
// Add token if query is ... | go | func (c *Connection) Query(ctx context.Context, q Query) (*Response, *Cursor, error) {
if c == nil {
return nil, nil, ErrConnectionClosed
}
if c.Conn == nil || c.isClosed() {
c.setBad()
return nil, nil, ErrConnectionClosed
}
if ctx == nil {
ctx = c.contextFromConnectionOpts()
}
// Add token if query is ... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"*",
"Response",
",",
"*",
"Cursor",
",",
"error",
")",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
",",
"... | // Query sends a Query to the database, returning both the raw Response and a
// Cursor which should be used to view the query's response.
//
// This function is used internally by Run which should be used for most queries. | [
"Query",
"sends",
"a",
"Query",
"to",
"the",
"database",
"returning",
"both",
"the",
"raw",
"Response",
"and",
"a",
"Cursor",
"which",
"should",
"be",
"used",
"to",
"view",
"the",
"query",
"s",
"response",
".",
"This",
"function",
"is",
"used",
"internally... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection.go#L158-L228 |
30,229 | rethinkdb/rethinkdb-go | connection.go | sendQuery | func (c *Connection) sendQuery(q Query) error {
buf := &bytes.Buffer{}
buf.Grow(respHeaderLen)
buf.Write(buf.Bytes()[:respHeaderLen]) // reserve for header
enc := json.NewEncoder(buf)
// Build query
err := enc.Encode(q.Build())
if err != nil {
return RQLDriverError{rqlError(fmt.Sprintf("Error building query: ... | go | func (c *Connection) sendQuery(q Query) error {
buf := &bytes.Buffer{}
buf.Grow(respHeaderLen)
buf.Write(buf.Bytes()[:respHeaderLen]) // reserve for header
enc := json.NewEncoder(buf)
// Build query
err := enc.Encode(q.Build())
if err != nil {
return RQLDriverError{rqlError(fmt.Sprintf("Error building query: ... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"sendQuery",
"(",
"q",
"Query",
")",
"error",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"buf",
".",
"Grow",
"(",
"respHeaderLen",
")",
"\n",
"buf",
".",
"Write",
"(",
"buf",
".",
"Byt... | // sendQuery marshals the Query and sends the JSON to the server. | [
"sendQuery",
"marshals",
"the",
"Query",
"and",
"sends",
"the",
"JSON",
"to",
"the",
"server",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection.go#L363-L393 |
30,230 | rethinkdb/rethinkdb-go | connection.go | readResponse | func (c *Connection) readResponse() (*Response, error) {
// Set timeout
if c.opts.ReadTimeout != 0 {
c.Conn.SetReadDeadline(time.Now().Add(c.opts.ReadTimeout))
}
// Read response header (token+length)
headerBuf := [respHeaderLen]byte{}
if _, err := c.read(headerBuf[:]); err != nil {
c.setBad()
return nil, ... | go | func (c *Connection) readResponse() (*Response, error) {
// Set timeout
if c.opts.ReadTimeout != 0 {
c.Conn.SetReadDeadline(time.Now().Add(c.opts.ReadTimeout))
}
// Read response header (token+length)
headerBuf := [respHeaderLen]byte{}
if _, err := c.read(headerBuf[:]); err != nil {
c.setBad()
return nil, ... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"readResponse",
"(",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"// Set timeout",
"if",
"c",
".",
"opts",
".",
"ReadTimeout",
"!=",
"0",
"{",
"c",
".",
"Conn",
".",
"SetReadDeadline",
"(",
"time",
"."... | // readResponse attempts to read a Response from the server, if no response
// could be read then an error is returned. | [
"readResponse",
"attempts",
"to",
"read",
"a",
"Response",
"from",
"the",
"server",
"if",
"no",
"response",
"could",
"be",
"read",
"then",
"an",
"error",
"is",
"returned",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection.go#L404-L437 |
30,231 | rethinkdb/rethinkdb-go | connection.go | processResponse | func (c *Connection) processResponse(ctx context.Context, q Query, response *Response, span opentracing.Span) (r *Response, cur *Cursor, err error) {
if span != nil {
defer func() {
if err != nil {
ext.Error.Set(span, true)
span.LogFields(log.Error(err))
}
span.Finish()
}()
}
switch response.Ty... | go | func (c *Connection) processResponse(ctx context.Context, q Query, response *Response, span opentracing.Span) (r *Response, cur *Cursor, err error) {
if span != nil {
defer func() {
if err != nil {
ext.Error.Set(span, true)
span.LogFields(log.Error(err))
}
span.Finish()
}()
}
switch response.Ty... | [
"func",
"(",
"c",
"*",
"Connection",
")",
"processResponse",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
",",
"response",
"*",
"Response",
",",
"span",
"opentracing",
".",
"Span",
")",
"(",
"r",
"*",
"Response",
",",
"cur",
"*",
"Cursor",... | // Called to fill response for the query | [
"Called",
"to",
"fill",
"response",
"for",
"the",
"query"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/connection.go#L440-L469 |
30,232 | rethinkdb/rethinkdb-go | query_geospatial.go | ToGeoJSON | func (t Term) ToGeoJSON(args ...interface{}) Term {
return constructMethodTerm(t, "ToGeoJSON", p.Term_TO_GEOJSON, args, map[string]interface{}{})
} | go | func (t Term) ToGeoJSON(args ...interface{}) Term {
return constructMethodTerm(t, "ToGeoJSON", p.Term_TO_GEOJSON, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ToGeoJSON",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TO_GEOJSON",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // ToGeoJSON converts a ReQL geometry object to a GeoJSON object. | [
"ToGeoJSON",
"converts",
"a",
"ReQL",
"geometry",
"object",
"to",
"a",
"GeoJSON",
"object",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_geospatial.go#L76-L78 |
30,233 | rethinkdb/rethinkdb-go | query_geospatial.go | GetIntersecting | func (t Term) GetIntersecting(args interface{}, optArgs ...GetIntersectingOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "GetIntersecting", p.Term_GET_INTERSECTING, []interface{}{args}, opts)
} | go | func (t Term) GetIntersecting(args interface{}, optArgs ...GetIntersectingOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "GetIntersecting", p.Term_GET_INTERSECTING, []interface{}{args}, opts)
} | [
"func",
"(",
"t",
"Term",
")",
"GetIntersecting",
"(",
"args",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"GetIntersectingOpts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"o... | // GetIntersecting gets all documents where the given geometry object intersects
// the geometry object of the requested geospatial index. | [
"GetIntersecting",
"gets",
"all",
"documents",
"where",
"the",
"given",
"geometry",
"object",
"intersects",
"the",
"geometry",
"object",
"of",
"the",
"requested",
"geospatial",
"index",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_geospatial.go#L91-L98 |
30,234 | rethinkdb/rethinkdb-go | query_geospatial.go | Includes | func (t Term) Includes(args ...interface{}) Term {
return constructMethodTerm(t, "Includes", p.Term_INCLUDES, args, map[string]interface{}{})
} | go | func (t Term) Includes(args ...interface{}) Term {
return constructMethodTerm(t, "Includes", p.Term_INCLUDES, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Includes",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INCLUDES",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfac... | // Includes tests whether a geometry object is completely contained within another.
// When applied to a sequence of geometry objects, includes acts as a filter,
// returning a sequence of objects from the sequence that include the argument. | [
"Includes",
"tests",
"whether",
"a",
"geometry",
"object",
"is",
"completely",
"contained",
"within",
"another",
".",
"When",
"applied",
"to",
"a",
"sequence",
"of",
"geometry",
"objects",
"includes",
"acts",
"as",
"a",
"filter",
"returning",
"a",
"sequence",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_geospatial.go#L127-L129 |
30,235 | rethinkdb/rethinkdb-go | query_geospatial.go | Intersects | func (t Term) Intersects(args ...interface{}) Term {
return constructMethodTerm(t, "Intersects", p.Term_INTERSECTS, args, map[string]interface{}{})
} | go | func (t Term) Intersects(args ...interface{}) Term {
return constructMethodTerm(t, "Intersects", p.Term_INTERSECTS, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Intersects",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_INTERSECTS",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inte... | // Intersects tests whether two geometry objects intersect with one another.
// When applied to a sequence of geometry objects, intersects acts as a filter,
// returning a sequence of objects from the sequence that intersect with the
// argument. | [
"Intersects",
"tests",
"whether",
"two",
"geometry",
"objects",
"intersect",
"with",
"one",
"another",
".",
"When",
"applied",
"to",
"a",
"sequence",
"of",
"geometry",
"objects",
"intersects",
"acts",
"as",
"a",
"filter",
"returning",
"a",
"sequence",
"of",
"o... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_geospatial.go#L135-L137 |
30,236 | rethinkdb/rethinkdb-go | query_select.go | Get | func (t Term) Get(args ...interface{}) Term {
return constructMethodTerm(t, "Get", p.Term_GET, args, map[string]interface{}{})
} | go | func (t Term) Get(args ...interface{}) Term {
return constructMethodTerm(t, "Get", p.Term_GET, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Get",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GET",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Get gets a document by primary key. If nothing was found, RethinkDB will return a nil value. | [
"Get",
"gets",
"a",
"document",
"by",
"primary",
"key",
".",
"If",
"nothing",
"was",
"found",
"RethinkDB",
"will",
"return",
"a",
"nil",
"value",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_select.go#L60-L62 |
30,237 | rethinkdb/rethinkdb-go | query_select.go | GetAll | func (t Term) GetAll(keys ...interface{}) Term {
return constructMethodTerm(t, "GetAll", p.Term_GET_ALL, keys, map[string]interface{}{})
} | go | func (t Term) GetAll(keys ...interface{}) Term {
return constructMethodTerm(t, "GetAll", p.Term_GET_ALL, keys, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"GetAll",
"(",
"keys",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GET_ALL",
",",
"keys",
",",
"map",
"[",
"string",
"]",
"interface",... | // GetAll gets all documents where the given value matches the value of the primary
// index. Multiple values can be passed this function if you want to select multiple
// documents. If the documents you are fetching have composite keys then each
// argument should be a slice. For more information see the examples. | [
"GetAll",
"gets",
"all",
"documents",
"where",
"the",
"given",
"value",
"matches",
"the",
"value",
"of",
"the",
"primary",
"index",
".",
"Multiple",
"values",
"can",
"be",
"passed",
"this",
"function",
"if",
"you",
"want",
"to",
"select",
"multiple",
"docume... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_select.go#L77-L79 |
30,238 | rethinkdb/rethinkdb-go | query_select.go | GetAllByIndex | func (t Term) GetAllByIndex(index interface{}, keys ...interface{}) Term {
return constructMethodTerm(t, "GetAll", p.Term_GET_ALL, keys, map[string]interface{}{"index": index})
} | go | func (t Term) GetAllByIndex(index interface{}, keys ...interface{}) Term {
return constructMethodTerm(t, "GetAll", p.Term_GET_ALL, keys, map[string]interface{}{"index": index})
} | [
"func",
"(",
"t",
"Term",
")",
"GetAllByIndex",
"(",
"index",
"interface",
"{",
"}",
",",
"keys",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GET_ALL",
",",
"keys",
... | // GetAllByIndex gets all documents where the given value matches the value of
// the requested index. | [
"GetAllByIndex",
"gets",
"all",
"documents",
"where",
"the",
"given",
"value",
"matches",
"the",
"value",
"of",
"the",
"requested",
"index",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_select.go#L83-L85 |
30,239 | rethinkdb/rethinkdb-go | cluster.go | NewCluster | func NewCluster(hosts []Host, opts *ConnectOpts) (*Cluster, error) {
c := &Cluster{
hp: hostpool.NewEpsilonGreedy([]string{}, opts.HostDecayDuration, &hostpool.LinearEpsilonValueCalculator{}),
seeds: hosts,
opts: opts,
}
// Attempt to connect to each host and discover any additional hosts if host
// disc... | go | func NewCluster(hosts []Host, opts *ConnectOpts) (*Cluster, error) {
c := &Cluster{
hp: hostpool.NewEpsilonGreedy([]string{}, opts.HostDecayDuration, &hostpool.LinearEpsilonValueCalculator{}),
seeds: hosts,
opts: opts,
}
// Attempt to connect to each host and discover any additional hosts if host
// disc... | [
"func",
"NewCluster",
"(",
"hosts",
"[",
"]",
"Host",
",",
"opts",
"*",
"ConnectOpts",
")",
"(",
"*",
"Cluster",
",",
"error",
")",
"{",
"c",
":=",
"&",
"Cluster",
"{",
"hp",
":",
"hostpool",
".",
"NewEpsilonGreedy",
"(",
"[",
"]",
"string",
"{",
"... | // NewCluster creates a new cluster by connecting to the given hosts. | [
"NewCluster",
"creates",
"a",
"new",
"cluster",
"by",
"connecting",
"to",
"the",
"given",
"hosts",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L36-L58 |
30,240 | rethinkdb/rethinkdb-go | cluster.go | Query | func (c *Cluster) Query(ctx context.Context, q Query) (cursor *Cursor, err error) {
for i := 0; i < c.numRetries(); i++ {
var node *Node
var hpr hostpool.HostPoolResponse
node, hpr, err = c.GetNextNode()
if err != nil {
return nil, err
}
cursor, err = node.Query(ctx, q)
hpr.Mark(err)
if !shouldRe... | go | func (c *Cluster) Query(ctx context.Context, q Query) (cursor *Cursor, err error) {
for i := 0; i < c.numRetries(); i++ {
var node *Node
var hpr hostpool.HostPoolResponse
node, hpr, err = c.GetNextNode()
if err != nil {
return nil, err
}
cursor, err = node.Query(ctx, q)
hpr.Mark(err)
if !shouldRe... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"cursor",
"*",
"Cursor",
",",
"err",
"error",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"c",
".",
"numRetries",
"(",
")",
... | // Query executes a ReQL query using the cluster to connect to the database | [
"Query",
"executes",
"a",
"ReQL",
"query",
"using",
"the",
"cluster",
"to",
"connect",
"to",
"the",
"database"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L61-L80 |
30,241 | rethinkdb/rethinkdb-go | cluster.go | Close | func (c *Cluster) Close(optArgs ...CloseOpts) error {
if c.closed {
return nil
}
for _, node := range c.GetNodes() {
err := node.Close(optArgs...)
if err != nil {
return err
}
}
c.hp.Close()
c.closed = true
return nil
} | go | func (c *Cluster) Close(optArgs ...CloseOpts) error {
if c.closed {
return nil
}
for _, node := range c.GetNodes() {
err := node.Close(optArgs...)
if err != nil {
return err
}
}
c.hp.Close()
c.closed = true
return nil
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"Close",
"(",
"optArgs",
"...",
"CloseOpts",
")",
"error",
"{",
"if",
"c",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"node",
":=",
"range",
"c",
".",
"GetNodes",
"(",
")",
"{",... | // Close closes the cluster | [
"Close",
"closes",
"the",
"cluster"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L150-L166 |
30,242 | rethinkdb/rethinkdb-go | cluster.go | discover | func (c *Cluster) discover() {
// Keep retrying with exponential backoff.
b := backoff.NewExponentialBackOff()
// Never finish retrying (max interval is still 60s)
b.MaxElapsedTime = 0
// Keep trying to discover new nodes
for {
backoff.RetryNotify(func() error {
// If no hosts try seeding nodes
if len(c.... | go | func (c *Cluster) discover() {
// Keep retrying with exponential backoff.
b := backoff.NewExponentialBackOff()
// Never finish retrying (max interval is still 60s)
b.MaxElapsedTime = 0
// Keep trying to discover new nodes
for {
backoff.RetryNotify(func() error {
// If no hosts try seeding nodes
if len(c.... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"discover",
"(",
")",
"{",
"// Keep retrying with exponential backoff.",
"b",
":=",
"backoff",
".",
"NewExponentialBackOff",
"(",
")",
"\n",
"// Never finish retrying (max interval is still 60s)",
"b",
".",
"MaxElapsedTime",
"=",
... | // discover attempts to find new nodes in the cluster using the current nodes | [
"discover",
"attempts",
"to",
"find",
"new",
"nodes",
"in",
"the",
"cluster",
"using",
"the",
"current",
"nodes"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L169-L188 |
30,243 | rethinkdb/rethinkdb-go | cluster.go | listenForNodeChanges | func (c *Cluster) listenForNodeChanges() error {
// Start listening to changes from a random active node
node, hpr, err := c.GetNextNode()
if err != nil {
return err
}
q, err := newQuery(
DB("rethinkdb").Table("server_status").Changes(),
map[string]interface{}{},
c.opts,
)
if err != nil {
return fmt.E... | go | func (c *Cluster) listenForNodeChanges() error {
// Start listening to changes from a random active node
node, hpr, err := c.GetNextNode()
if err != nil {
return err
}
q, err := newQuery(
DB("rethinkdb").Table("server_status").Changes(),
map[string]interface{}{},
c.opts,
)
if err != nil {
return fmt.E... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"listenForNodeChanges",
"(",
")",
"error",
"{",
"// Start listening to changes from a random active node",
"node",
",",
"hpr",
",",
"err",
":=",
"c",
".",
"GetNextNode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // listenForNodeChanges listens for changes to node status using change feeds.
// This function will block until the query fails | [
"listenForNodeChanges",
"listens",
"for",
"changes",
"to",
"node",
"status",
"using",
"change",
"feeds",
".",
"This",
"function",
"will",
"block",
"until",
"the",
"query",
"fails"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L192-L251 |
30,244 | rethinkdb/rethinkdb-go | cluster.go | AddSeeds | func (c *Cluster) AddSeeds(hosts []Host) {
c.mu.Lock()
c.seeds = append(c.seeds, hosts...)
c.mu.Unlock()
} | go | func (c *Cluster) AddSeeds(hosts []Host) {
c.mu.Lock()
c.seeds = append(c.seeds, hosts...)
c.mu.Unlock()
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"AddSeeds",
"(",
"hosts",
"[",
"]",
"Host",
")",
"{",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"c",
".",
"seeds",
"=",
"append",
"(",
"c",
".",
"seeds",
",",
"hosts",
"...",
")",
"\n",
"c",
".",
"m... | // AddSeeds adds new seed hosts to the cluster. | [
"AddSeeds",
"adds",
"new",
"seed",
"hosts",
"to",
"the",
"cluster",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L403-L407 |
30,245 | rethinkdb/rethinkdb-go | cluster.go | GetNextNode | func (c *Cluster) GetNextNode() (*Node, hostpool.HostPoolResponse, error) {
if !c.IsConnected() {
return nil, nil, ErrNoConnections
}
c.mu.RLock()
defer c.mu.RUnlock()
nodes := c.nodes
hpr := c.hp.Get()
if n, ok := nodes[hpr.Host()]; ok {
if !n.Closed() {
return n, hpr, nil
}
}
return nil, nil, ErrN... | go | func (c *Cluster) GetNextNode() (*Node, hostpool.HostPoolResponse, error) {
if !c.IsConnected() {
return nil, nil, ErrNoConnections
}
c.mu.RLock()
defer c.mu.RUnlock()
nodes := c.nodes
hpr := c.hp.Get()
if n, ok := nodes[hpr.Host()]; ok {
if !n.Closed() {
return n, hpr, nil
}
}
return nil, nil, ErrN... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"GetNextNode",
"(",
")",
"(",
"*",
"Node",
",",
"hostpool",
".",
"HostPoolResponse",
",",
"error",
")",
"{",
"if",
"!",
"c",
".",
"IsConnected",
"(",
")",
"{",
"return",
"nil",
",",
"nil",
",",
"ErrNoConnections... | // GetNextNode returns a random node on the cluster | [
"GetNextNode",
"returns",
"a",
"random",
"node",
"on",
"the",
"cluster"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L418-L434 |
30,246 | rethinkdb/rethinkdb-go | cluster.go | GetNodes | func (c *Cluster) GetNodes() []*Node {
c.mu.RLock()
nodes := make([]*Node, 0, len(c.nodes))
for _, n := range c.nodes {
nodes = append(nodes, n)
}
c.mu.RUnlock()
return nodes
} | go | func (c *Cluster) GetNodes() []*Node {
c.mu.RLock()
nodes := make([]*Node, 0, len(c.nodes))
for _, n := range c.nodes {
nodes = append(nodes, n)
}
c.mu.RUnlock()
return nodes
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"GetNodes",
"(",
")",
"[",
"]",
"*",
"Node",
"{",
"c",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"nodes",
":=",
"make",
"(",
"[",
"]",
"*",
"Node",
",",
"0",
",",
"len",
"(",
"c",
".",
"nodes",
")",
"... | // GetNodes returns a list of all nodes in the cluster | [
"GetNodes",
"returns",
"a",
"list",
"of",
"all",
"nodes",
"in",
"the",
"cluster"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/cluster.go#L437-L446 |
30,247 | rethinkdb/rethinkdb-go | session.go | IsConnected | func (s *Session) IsConnected() bool {
s.mu.RLock()
defer s.mu.RUnlock()
if s.cluster == nil || s.closed {
return false
}
return s.cluster.IsConnected()
} | go | func (s *Session) IsConnected() bool {
s.mu.RLock()
defer s.mu.RUnlock()
if s.cluster == nil || s.closed {
return false
}
return s.cluster.IsConnected()
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"IsConnected",
"(",
")",
"bool",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"cluster",
"==",
"nil",
"||",
"s",
".",
"clo... | // IsConnected returns true if session has a valid connection. | [
"IsConnected",
"returns",
"true",
"if",
"session",
"has",
"a",
"valid",
"connection",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/session.go#L178-L186 |
30,248 | rethinkdb/rethinkdb-go | session.go | Reconnect | func (s *Session) Reconnect(optArgs ...CloseOpts) error {
var err error
if err = s.Close(optArgs...); err != nil {
return err
}
s.mu.Lock()
s.cluster, err = NewCluster(s.hosts, s.opts)
if err != nil {
s.mu.Unlock()
return err
}
s.closed = false
s.mu.Unlock()
return nil
} | go | func (s *Session) Reconnect(optArgs ...CloseOpts) error {
var err error
if err = s.Close(optArgs...); err != nil {
return err
}
s.mu.Lock()
s.cluster, err = NewCluster(s.hosts, s.opts)
if err != nil {
s.mu.Unlock()
return err
}
s.closed = false
s.mu.Unlock()
return nil
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Reconnect",
"(",
"optArgs",
"...",
"CloseOpts",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"if",
"err",
"=",
"s",
".",
"Close",
"(",
"optArgs",
"...",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err"... | // Reconnect closes and re-opens a session. | [
"Reconnect",
"closes",
"and",
"re",
"-",
"opens",
"a",
"session",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/session.go#L189-L207 |
30,249 | rethinkdb/rethinkdb-go | session.go | Use | func (s *Session) Use(database string) {
s.mu.Lock()
defer s.mu.Unlock()
s.opts.Database = database
} | go | func (s *Session) Use(database string) {
s.mu.Lock()
defer s.mu.Unlock()
s.opts.Database = database
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Use",
"(",
"database",
"string",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"opts",
".",
"Database",
"=",
"database",
"\n",
... | // Use changes the default database used | [
"Use",
"changes",
"the",
"default",
"database",
"used"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/session.go#L280-L285 |
30,250 | rethinkdb/rethinkdb-go | session.go | Database | func (s *Session) Database() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.opts.Database
} | go | func (s *Session) Database() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.opts.Database
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Database",
"(",
")",
"string",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"opts",
".",
"Database",
"\n",
"}"
] | // Database returns the selected database set by Use | [
"Database",
"returns",
"the",
"selected",
"database",
"set",
"by",
"Use"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/session.go#L288-L293 |
30,251 | rethinkdb/rethinkdb-go | session.go | Query | func (s *Session) Query(ctx context.Context, q Query) (*Cursor, error) {
s.mu.RLock()
defer s.mu.RUnlock()
if s.closed {
return nil, ErrConnectionClosed
}
return s.cluster.Query(ctx, q)
} | go | func (s *Session) Query(ctx context.Context, q Query) (*Cursor, error) {
s.mu.RLock()
defer s.mu.RUnlock()
if s.closed {
return nil, ErrConnectionClosed
}
return s.cluster.Query(ctx, q)
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"*",
"Cursor",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
... | // Query executes a ReQL query using the session to connect to the database | [
"Query",
"executes",
"a",
"ReQL",
"query",
"using",
"the",
"session",
"to",
"connect",
"to",
"the",
"database"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/session.go#L296-L305 |
30,252 | rethinkdb/rethinkdb-go | session.go | SetHosts | func (s *Session) SetHosts(hosts []Host) {
s.mu.Lock()
defer s.mu.Unlock()
s.hosts = hosts
} | go | func (s *Session) SetHosts(hosts []Host) {
s.mu.Lock()
defer s.mu.Unlock()
s.hosts = hosts
} | [
"func",
"(",
"s",
"*",
"Session",
")",
"SetHosts",
"(",
"hosts",
"[",
"]",
"Host",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"hosts",
"=",
"hosts",
"\n",
"}"
] | // SetHosts resets the hosts used when connecting to the RethinkDB cluster | [
"SetHosts",
"resets",
"the",
"hosts",
"used",
"when",
"connecting",
"to",
"the",
"RethinkDB",
"cluster"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/session.go#L325-L330 |
30,253 | rethinkdb/rethinkdb-go | pool.go | NewPool | func NewPool(host Host, opts *ConnectOpts) (*Pool, error) {
initialCap := opts.InitialCap
if initialCap <= 0 {
// Fallback to MaxIdle if InitialCap is zero, this should be removed
// when MaxIdle is removed
initialCap = opts.MaxIdle
}
maxOpen := opts.MaxOpen
if maxOpen <= 0 {
maxOpen = 2
}
p, err := po... | go | func NewPool(host Host, opts *ConnectOpts) (*Pool, error) {
initialCap := opts.InitialCap
if initialCap <= 0 {
// Fallback to MaxIdle if InitialCap is zero, this should be removed
// when MaxIdle is removed
initialCap = opts.MaxIdle
}
maxOpen := opts.MaxOpen
if maxOpen <= 0 {
maxOpen = 2
}
p, err := po... | [
"func",
"NewPool",
"(",
"host",
"Host",
",",
"opts",
"*",
"ConnectOpts",
")",
"(",
"*",
"Pool",
",",
"error",
")",
"{",
"initialCap",
":=",
"opts",
".",
"InitialCap",
"\n",
"if",
"initialCap",
"<=",
"0",
"{",
"// Fallback to MaxIdle if InitialCap is zero, this... | // NewPool creates a new connection pool for the given host | [
"NewPool",
"creates",
"a",
"new",
"connection",
"pool",
"for",
"the",
"given",
"host"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/pool.go#L29-L59 |
30,254 | rethinkdb/rethinkdb-go | pool.go | Close | func (p *Pool) Close() error {
p.mu.RLock()
defer p.mu.RUnlock()
if p.closed {
return nil
}
p.pool.Close()
return nil
} | go | func (p *Pool) Close() error {
p.mu.RLock()
defer p.mu.RUnlock()
if p.closed {
return nil
}
p.pool.Close()
return nil
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Close",
"(",
")",
"error",
"{",
"p",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"p",
".",
"closed",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"... | // Close closes the database, releasing any open resources.
//
// It is rare to Close a Pool, as the Pool handle is meant to be
// long-lived and shared between many goroutines. | [
"Close",
"closes",
"the",
"database",
"releasing",
"any",
"open",
"resources",
".",
"It",
"is",
"rare",
"to",
"Close",
"a",
"Pool",
"as",
"the",
"Pool",
"handle",
"is",
"meant",
"to",
"be",
"long",
"-",
"lived",
"and",
"shared",
"between",
"many",
"gorou... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/pool.go#L75-L85 |
30,255 | rethinkdb/rethinkdb-go | pool.go | Exec | func (p *Pool) Exec(ctx context.Context, q Query) error {
c, pc, err := p.conn()
if err != nil {
return err
}
defer pc.Close()
_, _, err = c.Query(ctx, q)
if c.isBad() {
pc.MarkUnusable()
}
return err
} | go | func (p *Pool) Exec(ctx context.Context, q Query) error {
c, pc, err := p.conn()
if err != nil {
return err
}
defer pc.Close()
_, _, err = c.Query(ctx, q)
if c.isBad() {
pc.MarkUnusable()
}
return err
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"error",
"{",
"c",
",",
"pc",
",",
"err",
":=",
"p",
".",
"conn",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",... | // Query execution functions
// Exec executes a query without waiting for any response. | [
"Query",
"execution",
"functions",
"Exec",
"executes",
"a",
"query",
"without",
"waiting",
"for",
"any",
"response",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/pool.go#L140-L154 |
30,256 | rethinkdb/rethinkdb-go | pool.go | Query | func (p *Pool) Query(ctx context.Context, q Query) (*Cursor, error) {
c, pc, err := p.conn()
if err != nil {
return nil, err
}
_, cursor, err := c.Query(ctx, q)
if err == nil {
cursor.releaseConn = releaseConn(c, pc)
} else {
if c.isBad() {
pc.MarkUnusable()
}
pc.Close()
}
return cursor, err
} | go | func (p *Pool) Query(ctx context.Context, q Query) (*Cursor, error) {
c, pc, err := p.conn()
if err != nil {
return nil, err
}
_, cursor, err := c.Query(ctx, q)
if err == nil {
cursor.releaseConn = releaseConn(c, pc)
} else {
if c.isBad() {
pc.MarkUnusable()
}
pc.Close()
}
return cursor, err
} | [
"func",
"(",
"p",
"*",
"Pool",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"*",
"Cursor",
",",
"error",
")",
"{",
"c",
",",
"pc",
",",
"err",
":=",
"p",
".",
"conn",
"(",
")",
"\n",
"if",
"err",
"!=",
"... | // Query executes a query and waits for the response | [
"Query",
"executes",
"a",
"query",
"and",
"waits",
"for",
"the",
"response"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/pool.go#L157-L175 |
30,257 | rethinkdb/rethinkdb-go | rethinkdb.go | SetVerbose | func SetVerbose(verbose bool) {
if verbose {
Log.Level = logrus.DebugLevel
return
}
Log.Level = logrus.InfoLevel
} | go | func SetVerbose(verbose bool) {
if verbose {
Log.Level = logrus.DebugLevel
return
}
Log.Level = logrus.InfoLevel
} | [
"func",
"SetVerbose",
"(",
"verbose",
"bool",
")",
"{",
"if",
"verbose",
"{",
"Log",
".",
"Level",
"=",
"logrus",
".",
"DebugLevel",
"\n",
"return",
"\n",
"}",
"\n\n",
"Log",
".",
"Level",
"=",
"logrus",
".",
"InfoLevel",
"\n",
"}"
] | // SetVerbose allows the driver logging level to be set. If true is passed then
// the log level is set to Debug otherwise it defaults to Info. | [
"SetVerbose",
"allows",
"the",
"driver",
"logging",
"level",
"to",
"be",
"set",
".",
"If",
"true",
"is",
"passed",
"then",
"the",
"log",
"level",
"is",
"set",
"to",
"Debug",
"otherwise",
"it",
"defaults",
"to",
"Info",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/rethinkdb.go#L43-L50 |
30,258 | rethinkdb/rethinkdb-go | query.go | Build | func (t Term) Build() (interface{}, error) {
var err error
if t.lastErr != nil {
return nil, t.lastErr
}
if t.rawQuery {
return t.data, nil
}
switch t.termType {
case p.Term_DATUM:
return t.data, nil
case p.Term_MAKE_OBJ:
res := map[string]interface{}{}
for k, v := range t.optArgs {
res[k], err ... | go | func (t Term) Build() (interface{}, error) {
var err error
if t.lastErr != nil {
return nil, t.lastErr
}
if t.rawQuery {
return t.data, nil
}
switch t.termType {
case p.Term_DATUM:
return t.data, nil
case p.Term_MAKE_OBJ:
res := map[string]interface{}{}
for k, v := range t.optArgs {
res[k], err ... | [
"func",
"(",
"t",
"Term",
")",
"Build",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"if",
"t",
".",
"lastErr",
"!=",
"nil",
"{",
"return",
"nil",
",",
"t",
".",
"lastErr",
"\n",
"}",
"\n\n",
"if"... | // build takes the query tree and prepares it to be sent as a JSON
// expression | [
"build",
"takes",
"the",
"query",
"tree",
"and",
"prepares",
"it",
"to",
"be",
"sent",
"as",
"a",
"JSON",
"expression"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L128-L188 |
30,259 | rethinkdb/rethinkdb-go | query.go | String | func (t Term) String() string {
if t.isMockAnything {
return "r.MockAnything()"
}
switch t.termType {
case p.Term_MAKE_ARRAY:
return fmt.Sprintf("[%s]", strings.Join(argsToStringSlice(t.args), ", "))
case p.Term_MAKE_OBJ:
return fmt.Sprintf("{%s}", strings.Join(optArgsToStringSlice(t.optArgs), ", "))
case ... | go | func (t Term) String() string {
if t.isMockAnything {
return "r.MockAnything()"
}
switch t.termType {
case p.Term_MAKE_ARRAY:
return fmt.Sprintf("[%s]", strings.Join(argsToStringSlice(t.args), ", "))
case p.Term_MAKE_OBJ:
return fmt.Sprintf("{%s}", strings.Join(optArgsToStringSlice(t.optArgs), ", "))
case ... | [
"func",
"(",
"t",
"Term",
")",
"String",
"(",
")",
"string",
"{",
"if",
"t",
".",
"isMockAnything",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"switch",
"t",
".",
"termType",
"{",
"case",
"p",
".",
"Term_MAKE_ARRAY",
":",
"return",
"fmt",
".",
"... | // String returns a string representation of the query tree | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"the",
"query",
"tree"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L191-L238 |
30,260 | rethinkdb/rethinkdb-go | query.go | ReadOne | func (t Term) ReadOne(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.One(dest)
} | go | func (t Term) ReadOne(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.One(dest)
} | [
"func",
"(",
"t",
"Term",
")",
"ReadOne",
"(",
"dest",
"interface",
"{",
"}",
",",
"s",
"QueryExecutor",
",",
"optArgs",
"...",
"RunOpts",
")",
"error",
"{",
"res",
",",
"err",
":=",
"t",
".",
"Run",
"(",
"s",
",",
"optArgs",
"...",
")",
"\n",
"i... | // ReadOne is a shortcut method that runs the query on the given connection
// and reads one response from the cursor before closing it.
//
// It returns any errors encountered from running the query or reading the response | [
"ReadOne",
"is",
"a",
"shortcut",
"method",
"that",
"runs",
"the",
"query",
"on",
"the",
"given",
"connection",
"and",
"reads",
"one",
"response",
"from",
"the",
"cursor",
"before",
"closing",
"it",
".",
"It",
"returns",
"any",
"errors",
"encountered",
"from... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L387-L393 |
30,261 | rethinkdb/rethinkdb-go | query.go | ReadAll | func (t Term) ReadAll(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.All(dest)
} | go | func (t Term) ReadAll(dest interface{}, s QueryExecutor, optArgs ...RunOpts) error {
res, err := t.Run(s, optArgs...)
if err != nil {
return err
}
return res.All(dest)
} | [
"func",
"(",
"t",
"Term",
")",
"ReadAll",
"(",
"dest",
"interface",
"{",
"}",
",",
"s",
"QueryExecutor",
",",
"optArgs",
"...",
"RunOpts",
")",
"error",
"{",
"res",
",",
"err",
":=",
"t",
".",
"Run",
"(",
"s",
",",
"optArgs",
"...",
")",
"\n",
"i... | // ReadAll is a shortcut method that runs the query on the given connection
// and reads all of the responses from the cursor before closing it.
//
// It returns any errors encountered from running the query or reading the responses | [
"ReadAll",
"is",
"a",
"shortcut",
"method",
"that",
"runs",
"the",
"query",
"on",
"the",
"given",
"connection",
"and",
"reads",
"all",
"of",
"the",
"responses",
"from",
"the",
"cursor",
"before",
"closing",
"it",
".",
"It",
"returns",
"any",
"errors",
"enc... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query.go#L399-L405 |
30,262 | rethinkdb/rethinkdb-go | errors.go | IsConflictErr | func IsConflictErr(err error) bool {
if err == nil {
return false
}
return strings.HasPrefix(err.Error(), "Duplicate primary key")
} | go | func IsConflictErr(err error) bool {
if err == nil {
return false
}
return strings.HasPrefix(err.Error(), "Duplicate primary key")
} | [
"func",
"IsConflictErr",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"strings",
".",
"HasPrefix",
"(",
"err",
".",
"Error",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // Error type helpers
// IsConflictErr returns true if the error is non-nil and the query failed
// due to a duplicate primary key. | [
"Error",
"type",
"helpers",
"IsConflictErr",
"returns",
"true",
"if",
"the",
"error",
"is",
"non",
"-",
"nil",
"and",
"the",
"query",
"failed",
"due",
"to",
"a",
"duplicate",
"primary",
"key",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/errors.go#L176-L182 |
30,263 | rethinkdb/rethinkdb-go | mock.go | MockAnything | func MockAnything() Term {
t := constructRootTerm("MockAnything", p.Term_DATUM, nil, nil)
t.isMockAnything = true
return t
} | go | func MockAnything() Term {
t := constructRootTerm("MockAnything", p.Term_DATUM, nil, nil)
t.isMockAnything = true
return t
} | [
"func",
"MockAnything",
"(",
")",
"Term",
"{",
"t",
":=",
"constructRootTerm",
"(",
"\"",
"\"",
",",
"p",
".",
"Term_DATUM",
",",
"nil",
",",
"nil",
")",
"\n",
"t",
".",
"isMockAnything",
"=",
"true",
"\n\n",
"return",
"t",
"\n",
"}"
] | // MockAnything can be used in place of any term, this is useful when you want
// mock similar queries or queries that you don't quite know the exact structure
// of. | [
"MockAnything",
"can",
"be",
"used",
"in",
"place",
"of",
"any",
"term",
"this",
"is",
"useful",
"when",
"you",
"want",
"mock",
"similar",
"queries",
"or",
"queries",
"that",
"you",
"don",
"t",
"quite",
"know",
"the",
"exact",
"structure",
"of",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L26-L31 |
30,264 | rethinkdb/rethinkdb-go | mock.go | NewMock | func NewMock(opts ...ConnectOpts) *Mock {
m := &Mock{
ExpectedQueries: make([]*MockQuery, 0),
Queries: make([]MockQuery, 0),
}
if len(opts) > 0 {
m.opts = opts[0]
}
return m
} | go | func NewMock(opts ...ConnectOpts) *Mock {
m := &Mock{
ExpectedQueries: make([]*MockQuery, 0),
Queries: make([]MockQuery, 0),
}
if len(opts) > 0 {
m.opts = opts[0]
}
return m
} | [
"func",
"NewMock",
"(",
"opts",
"...",
"ConnectOpts",
")",
"*",
"Mock",
"{",
"m",
":=",
"&",
"Mock",
"{",
"ExpectedQueries",
":",
"make",
"(",
"[",
"]",
"*",
"MockQuery",
",",
"0",
")",
",",
"Queries",
":",
"make",
"(",
"[",
"]",
"MockQuery",
",",
... | // NewMock creates an instance of Mock, you can optionally pass ConnectOpts to
// the function, if passed any mocked query will be generated using those
// options. | [
"NewMock",
"creates",
"an",
"instance",
"of",
"Mock",
"you",
"can",
"optionally",
"pass",
"ConnectOpts",
"to",
"the",
"function",
"if",
"passed",
"any",
"mocked",
"query",
"will",
"be",
"generated",
"using",
"those",
"options",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L190-L201 |
30,265 | rethinkdb/rethinkdb-go | mock.go | AssertExpectations | func (m *Mock) AssertExpectations(t testingT) bool {
var somethingMissing bool
var failedExpectations int
// iterate through each expectation
expectedQueries := m.expectedQueries()
for _, expectedQuery := range expectedQueries {
if !m.queryWasExecuted(expectedQuery) && expectedQuery.executed == 0 {
something... | go | func (m *Mock) AssertExpectations(t testingT) bool {
var somethingMissing bool
var failedExpectations int
// iterate through each expectation
expectedQueries := m.expectedQueries()
for _, expectedQuery := range expectedQueries {
if !m.queryWasExecuted(expectedQuery) && expectedQuery.executed == 0 {
something... | [
"func",
"(",
"m",
"*",
"Mock",
")",
"AssertExpectations",
"(",
"t",
"testingT",
")",
"bool",
"{",
"var",
"somethingMissing",
"bool",
"\n",
"var",
"failedExpectations",
"int",
"\n\n",
"// iterate through each expectation",
"expectedQueries",
":=",
"m",
".",
"expect... | // AssertExpectations asserts that everything specified with On and Return was
// in fact executed as expected. Queries may have been executed in any order. | [
"AssertExpectations",
"asserts",
"that",
"everything",
"specified",
"with",
"On",
"and",
"Return",
"was",
"in",
"fact",
"executed",
"as",
"expected",
".",
"Queries",
"may",
"have",
"been",
"executed",
"in",
"any",
"order",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L222-L250 |
30,266 | rethinkdb/rethinkdb-go | mock.go | AssertNumberOfExecutions | func (m *Mock) AssertNumberOfExecutions(t testingT, expectedQuery *MockQuery, expectedExecutions int) bool {
var actualExecutions int
for _, query := range m.queries() {
if query.Query.Term.compare(*expectedQuery.Query.Term, map[int64]int64{}) && query.Repeatability > -1 {
// if bytes.Equal(query.BuiltQuery, exp... | go | func (m *Mock) AssertNumberOfExecutions(t testingT, expectedQuery *MockQuery, expectedExecutions int) bool {
var actualExecutions int
for _, query := range m.queries() {
if query.Query.Term.compare(*expectedQuery.Query.Term, map[int64]int64{}) && query.Repeatability > -1 {
// if bytes.Equal(query.BuiltQuery, exp... | [
"func",
"(",
"m",
"*",
"Mock",
")",
"AssertNumberOfExecutions",
"(",
"t",
"testingT",
",",
"expectedQuery",
"*",
"MockQuery",
",",
"expectedExecutions",
"int",
")",
"bool",
"{",
"var",
"actualExecutions",
"int",
"\n",
"for",
"_",
",",
"query",
":=",
"range",... | // AssertNumberOfExecutions asserts that the query was executed expectedExecutions times. | [
"AssertNumberOfExecutions",
"asserts",
"that",
"the",
"query",
"was",
"executed",
"expectedExecutions",
"times",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L253-L268 |
30,267 | rethinkdb/rethinkdb-go | mock.go | AssertExecuted | func (m *Mock) AssertExecuted(t testingT, expectedQuery *MockQuery) bool {
if !m.queryWasExecuted(expectedQuery) {
t.Errorf("The query \"%s\" should have been executed, but was not.", expectedQuery.Query.Term.String())
return false
}
return true
} | go | func (m *Mock) AssertExecuted(t testingT, expectedQuery *MockQuery) bool {
if !m.queryWasExecuted(expectedQuery) {
t.Errorf("The query \"%s\" should have been executed, but was not.", expectedQuery.Query.Term.String())
return false
}
return true
} | [
"func",
"(",
"m",
"*",
"Mock",
")",
"AssertExecuted",
"(",
"t",
"testingT",
",",
"expectedQuery",
"*",
"MockQuery",
")",
"bool",
"{",
"if",
"!",
"m",
".",
"queryWasExecuted",
"(",
"expectedQuery",
")",
"{",
"t",
".",
"Errorf",
"(",
"\"",
"\\\"",
"\\\""... | // AssertExecuted asserts that the method was executed.
// It can produce a false result when an argument is a pointer type and the underlying value changed after executing the mocked method. | [
"AssertExecuted",
"asserts",
"that",
"the",
"method",
"was",
"executed",
".",
"It",
"can",
"produce",
"a",
"false",
"result",
"when",
"an",
"argument",
"is",
"a",
"pointer",
"type",
"and",
"the",
"underlying",
"value",
"changed",
"after",
"executing",
"the",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/mock.go#L272-L278 |
30,268 | rethinkdb/rethinkdb-go | encoding/decoder.go | decodeValue | func decodeValue(dv, sv reflect.Value, blank bool) error {
return valueDecoder(dv, sv, blank)(dv, sv)
} | go | func decodeValue(dv, sv reflect.Value, blank bool) error {
return valueDecoder(dv, sv, blank)(dv, sv)
} | [
"func",
"decodeValue",
"(",
"dv",
",",
"sv",
"reflect",
".",
"Value",
",",
"blank",
"bool",
")",
"error",
"{",
"return",
"valueDecoder",
"(",
"dv",
",",
"sv",
",",
"blank",
")",
"(",
"dv",
",",
"sv",
")",
"\n",
"}"
] | // decodeValue decodes the source value into the destination value | [
"decodeValue",
"decodes",
"the",
"source",
"value",
"into",
"the",
"destination",
"value"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/decoder.go#L61-L63 |
30,269 | rethinkdb/rethinkdb-go | encoding/decoder.go | indirect | func indirect(v reflect.Value, decodeNull bool) reflect.Value {
// If v is a named type and is addressable,
// start with its address, so that if the type has pointer methods,
// we find them.
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
v = v.Addr()
}
for {
// Load value from interfac... | go | func indirect(v reflect.Value, decodeNull bool) reflect.Value {
// If v is a named type and is addressable,
// start with its address, so that if the type has pointer methods,
// we find them.
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
v = v.Addr()
}
for {
// Load value from interfac... | [
"func",
"indirect",
"(",
"v",
"reflect",
".",
"Value",
",",
"decodeNull",
"bool",
")",
"reflect",
".",
"Value",
"{",
"// If v is a named type and is addressable,",
"// start with its address, so that if the type has pointer methods,",
"// we find them.",
"if",
"v",
".",
"Ki... | // indirect walks down v allocating pointers as needed,
// until it gets to a non-pointer. | [
"indirect",
"walks",
"down",
"v",
"allocating",
"pointers",
"as",
"needed",
"until",
"it",
"gets",
"to",
"a",
"non",
"-",
"pointer",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/encoding/decoder.go#L122-L150 |
30,270 | rethinkdb/rethinkdb-go | node.go | Closed | func (n *Node) Closed() bool {
n.mu.RLock()
defer n.mu.RUnlock()
return n.closed
} | go | func (n *Node) Closed() bool {
n.mu.RLock()
defer n.mu.RUnlock()
return n.closed
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Closed",
"(",
")",
"bool",
"{",
"n",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n\n",
"return",
"n",
".",
"closed",
"\n",
"}"
] | // Closed returns true if the node is closed | [
"Closed",
"returns",
"true",
"if",
"the",
"node",
"is",
"closed"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/node.go#L36-L41 |
30,271 | rethinkdb/rethinkdb-go | node.go | Query | func (n *Node) Query(ctx context.Context, q Query) (cursor *Cursor, err error) {
if n.Closed() {
return nil, ErrInvalidNode
}
return n.pool.Query(ctx, q)
} | go | func (n *Node) Query(ctx context.Context, q Query) (cursor *Cursor, err error) {
if n.Closed() {
return nil, ErrInvalidNode
}
return n.pool.Query(ctx, q)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Query",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"cursor",
"*",
"Cursor",
",",
"err",
"error",
")",
"{",
"if",
"n",
".",
"Closed",
"(",
")",
"{",
"return",
"nil",
",",
"ErrInvalidNod... | // Query executes a ReQL query using this nodes connection pool. | [
"Query",
"executes",
"a",
"ReQL",
"query",
"using",
"this",
"nodes",
"connection",
"pool",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/node.go#L93-L99 |
30,272 | rethinkdb/rethinkdb-go | node.go | Exec | func (n *Node) Exec(ctx context.Context, q Query) (err error) {
if n.Closed() {
return ErrInvalidNode
}
return n.pool.Exec(ctx, q)
} | go | func (n *Node) Exec(ctx context.Context, q Query) (err error) {
if n.Closed() {
return ErrInvalidNode
}
return n.pool.Exec(ctx, q)
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"Query",
")",
"(",
"err",
"error",
")",
"{",
"if",
"n",
".",
"Closed",
"(",
")",
"{",
"return",
"ErrInvalidNode",
"\n",
"}",
"\n\n",
"return",
"n",
".",
... | // Exec executes a ReQL query using this nodes connection pool. | [
"Exec",
"executes",
"a",
"ReQL",
"query",
"using",
"this",
"nodes",
"connection",
"pool",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/node.go#L102-L108 |
30,273 | rethinkdb/rethinkdb-go | query_aggregation.go | Group | func (t Term) Group(fieldOrFunctions ...interface{}) Term {
return constructMethodTerm(t, "Group", p.Term_GROUP, funcWrapArgs(fieldOrFunctions), map[string]interface{}{})
} | go | func (t Term) Group(fieldOrFunctions ...interface{}) Term {
return constructMethodTerm(t, "Group", p.Term_GROUP, funcWrapArgs(fieldOrFunctions), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Group",
"(",
"fieldOrFunctions",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_GROUP",
",",
"funcWrapArgs",
"(",
"fieldOrFunctions",
")",
"... | // Group takes a stream and partitions it into multiple groups based on the
// fields or functions provided. Commands chained after group will be
// called on each of these grouped sub-streams, producing grouped data. | [
"Group",
"takes",
"a",
"stream",
"and",
"partitions",
"it",
"into",
"multiple",
"groups",
"based",
"on",
"the",
"fields",
"or",
"functions",
"provided",
".",
"Commands",
"chained",
"after",
"group",
"will",
"be",
"called",
"on",
"each",
"of",
"these",
"group... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L106-L108 |
30,274 | rethinkdb/rethinkdb-go | query_aggregation.go | Contains | func (t Term) Contains(args ...interface{}) Term {
return constructMethodTerm(t, "Contains", p.Term_CONTAINS, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Contains(args ...interface{}) Term {
return constructMethodTerm(t, "Contains", p.Term_CONTAINS, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Contains",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_CONTAINS",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"["... | // Contains returns whether or not a sequence contains all the specified values,
// or if functions are provided instead, returns whether or not a sequence
// contains values matching all the specified functions. | [
"Contains",
"returns",
"whether",
"or",
"not",
"a",
"sequence",
"contains",
"all",
"the",
"specified",
"values",
"or",
"if",
"functions",
"are",
"provided",
"instead",
"returns",
"whether",
"or",
"not",
"a",
"sequence",
"contains",
"values",
"matching",
"all",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L167-L169 |
30,275 | rethinkdb/rethinkdb-go | query_aggregation.go | Count | func (t Term) Count(args ...interface{}) Term {
return constructMethodTerm(t, "Count", p.Term_COUNT, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Count(args ...interface{}) Term {
return constructMethodTerm(t, "Count", p.Term_COUNT, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Count",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_COUNT",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"s... | // Count the number of elements in the sequence. With a single argument,
// count the number of elements equal to it. If the argument is a function,
// it is equivalent to calling filter before count. | [
"Count",
"the",
"number",
"of",
"elements",
"in",
"the",
"sequence",
".",
"With",
"a",
"single",
"argument",
"count",
"the",
"number",
"of",
"elements",
"equal",
"to",
"it",
".",
"If",
"the",
"argument",
"is",
"a",
"function",
"it",
"is",
"equivalent",
"... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L184-L186 |
30,276 | rethinkdb/rethinkdb-go | query_aggregation.go | Sum | func (t Term) Sum(args ...interface{}) Term {
return constructMethodTerm(t, "Sum", p.Term_SUM, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Sum(args ...interface{}) Term {
return constructMethodTerm(t, "Sum", p.Term_SUM, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Sum",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_SUM",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Sum returns the sum of all the elements of a sequence. If called with a field
// name, sums all the values of that field in the sequence, skipping elements of
// the sequence that lack that field. If called with a function, calls that
// function on every element of the sequence and sums the results, skipping
// ele... | [
"Sum",
"returns",
"the",
"sum",
"of",
"all",
"the",
"elements",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"sums",
"all",
"the",
"values",
"of",
"that",
"field",
"in",
"the",
"sequence",
"skipping",
"elements",
"of",
"the",... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L204-L206 |
30,277 | rethinkdb/rethinkdb-go | query_aggregation.go | Avg | func (t Term) Avg(args ...interface{}) Term {
return constructMethodTerm(t, "Avg", p.Term_AVG, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Avg(args ...interface{}) Term {
return constructMethodTerm(t, "Avg", p.Term_AVG, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Avg",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_AVG",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Avg returns the average of all the elements of a sequence. If called with a field
// name, averages all the values of that field in the sequence, skipping elements of
// the sequence that lack that field. If called with a function, calls that function
// on every element of the sequence and averages the results, ski... | [
"Avg",
"returns",
"the",
"average",
"of",
"all",
"the",
"elements",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"averages",
"all",
"the",
"values",
"of",
"that",
"field",
"in",
"the",
"sequence",
"skipping",
"elements",
"of",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L222-L224 |
30,278 | rethinkdb/rethinkdb-go | query_aggregation.go | Min | func (t Term) Min(args ...interface{}) Term {
return constructMethodTerm(t, "Min", p.Term_MIN, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Min(args ...interface{}) Term {
return constructMethodTerm(t, "Min", p.Term_MIN, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Min",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MIN",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Min finds the minimum of a sequence. If called with a field name, finds the element
// of that sequence with the smallest value in that field. If called with a function,
// calls that function on every element of the sequence and returns the element
// which produced the smallest value, ignoring any elements where t... | [
"Min",
"finds",
"the",
"minimum",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"finds",
"the",
"element",
"of",
"that",
"sequence",
"with",
"the",
"smallest",
"value",
"in",
"that",
"field",
".",
"If",
"called",
"with",
"a",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L249-L251 |
30,279 | rethinkdb/rethinkdb-go | query_aggregation.go | Max | func (t Term) Max(args ...interface{}) Term {
return constructMethodTerm(t, "Max", p.Term_MAX, funcWrapArgs(args), map[string]interface{}{})
} | go | func (t Term) Max(args ...interface{}) Term {
return constructMethodTerm(t, "Max", p.Term_MAX, funcWrapArgs(args), map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Max",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MAX",
",",
"funcWrapArgs",
"(",
"args",
")",
",",
"map",
"[",
"strin... | // Max finds the maximum of a sequence. If called with a field name, finds the element
// of that sequence with the largest value in that field. If called with a function,
// calls that function on every element of the sequence and returns the element
// which produced the largest value, ignoring any elements where the... | [
"Max",
"finds",
"the",
"maximum",
"of",
"a",
"sequence",
".",
"If",
"called",
"with",
"a",
"field",
"name",
"finds",
"the",
"element",
"of",
"that",
"sequence",
"with",
"the",
"largest",
"value",
"in",
"that",
"field",
".",
"If",
"called",
"with",
"a",
... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_aggregation.go#L298-L300 |
30,280 | rethinkdb/rethinkdb-go | utils.go | constructRootTerm | func constructRootTerm(name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
return Term{
name: name,
rootTerm: true,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj(optArgs),
}
} | go | func constructRootTerm(name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
return Term{
name: name,
rootTerm: true,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj(optArgs),
}
} | [
"func",
"constructRootTerm",
"(",
"name",
"string",
",",
"termType",
"p",
".",
"Term_TermType",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"optArgs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"Term",
"{",
"na... | // Helper functions for constructing terms
// constructRootTerm is an alias for creating a new term. | [
"Helper",
"functions",
"for",
"constructing",
"terms",
"constructRootTerm",
"is",
"an",
"alias",
"for",
"creating",
"a",
"new",
"term",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L16-L24 |
30,281 | rethinkdb/rethinkdb-go | utils.go | constructMethodTerm | func constructMethodTerm(prevVal Term, name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
args = append([]interface{}{prevVal}, args...)
return Term{
name: name,
rootTerm: false,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj... | go | func constructMethodTerm(prevVal Term, name string, termType p.Term_TermType, args []interface{}, optArgs map[string]interface{}) Term {
args = append([]interface{}{prevVal}, args...)
return Term{
name: name,
rootTerm: false,
termType: termType,
args: convertTermList(args),
optArgs: convertTermObj... | [
"func",
"constructMethodTerm",
"(",
"prevVal",
"Term",
",",
"name",
"string",
",",
"termType",
"p",
".",
"Term_TermType",
",",
"args",
"[",
"]",
"interface",
"{",
"}",
",",
"optArgs",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"Term",
"{",
... | // constructMethodTerm is an alias for creating a new term. Unlike constructRootTerm
// this function adds the previous expression in the tree to the argument list to
// create a method term. | [
"constructMethodTerm",
"is",
"an",
"alias",
"for",
"creating",
"a",
"new",
"term",
".",
"Unlike",
"constructRootTerm",
"this",
"function",
"adds",
"the",
"previous",
"expression",
"in",
"the",
"tree",
"to",
"the",
"argument",
"list",
"to",
"create",
"a",
"meth... | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L29-L39 |
30,282 | rethinkdb/rethinkdb-go | utils.go | newQuery | func newQuery(t Term, qopts map[string]interface{}, copts *ConnectOpts) (q Query, err error) {
queryOpts := map[string]interface{}{}
for k, v := range qopts {
queryOpts[k], err = Expr(v).Build()
if err != nil {
return
}
}
if copts.Database != "" {
queryOpts["db"], err = DB(copts.Database).Build()
if er... | go | func newQuery(t Term, qopts map[string]interface{}, copts *ConnectOpts) (q Query, err error) {
queryOpts := map[string]interface{}{}
for k, v := range qopts {
queryOpts[k], err = Expr(v).Build()
if err != nil {
return
}
}
if copts.Database != "" {
queryOpts["db"], err = DB(copts.Database).Build()
if er... | [
"func",
"newQuery",
"(",
"t",
"Term",
",",
"qopts",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"copts",
"*",
"ConnectOpts",
")",
"(",
"q",
"Query",
",",
"err",
"error",
")",
"{",
"queryOpts",
":=",
"map",
"[",
"string",
"]",
"interface",
... | // Helper functions for creating internal RQL types | [
"Helper",
"functions",
"for",
"creating",
"internal",
"RQL",
"types"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L43-L70 |
30,283 | rethinkdb/rethinkdb-go | utils.go | makeArray | func makeArray(args termsList) Term {
return Term{
name: "[...]",
termType: p.Term_MAKE_ARRAY,
args: args,
}
} | go | func makeArray(args termsList) Term {
return Term{
name: "[...]",
termType: p.Term_MAKE_ARRAY,
args: args,
}
} | [
"func",
"makeArray",
"(",
"args",
"termsList",
")",
"Term",
"{",
"return",
"Term",
"{",
"name",
":",
"\"",
"\"",
",",
"termType",
":",
"p",
".",
"Term_MAKE_ARRAY",
",",
"args",
":",
"args",
",",
"}",
"\n",
"}"
] | // makeArray takes a slice of terms and produces a single MAKE_ARRAY term | [
"makeArray",
"takes",
"a",
"slice",
"of",
"terms",
"and",
"produces",
"a",
"single",
"MAKE_ARRAY",
"term"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L73-L79 |
30,284 | rethinkdb/rethinkdb-go | utils.go | makeObject | func makeObject(args termsObj) Term {
return Term{
name: "{...}",
termType: p.Term_MAKE_OBJ,
optArgs: args,
}
} | go | func makeObject(args termsObj) Term {
return Term{
name: "{...}",
termType: p.Term_MAKE_OBJ,
optArgs: args,
}
} | [
"func",
"makeObject",
"(",
"args",
"termsObj",
")",
"Term",
"{",
"return",
"Term",
"{",
"name",
":",
"\"",
"\"",
",",
"termType",
":",
"p",
".",
"Term_MAKE_OBJ",
",",
"optArgs",
":",
"args",
",",
"}",
"\n",
"}"
] | // makeObject takes a map of terms and produces a single MAKE_OBJECT term | [
"makeObject",
"takes",
"a",
"map",
"of",
"terms",
"and",
"produces",
"a",
"single",
"MAKE_OBJECT",
"term"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L82-L88 |
30,285 | rethinkdb/rethinkdb-go | utils.go | implVarScan | func implVarScan(value Term) bool {
if value.termType == p.Term_IMPLICIT_VAR {
return true
}
for _, v := range value.args {
if implVarScan(v) {
return true
}
}
for _, v := range value.optArgs {
if implVarScan(v) {
return true
}
}
return false
} | go | func implVarScan(value Term) bool {
if value.termType == p.Term_IMPLICIT_VAR {
return true
}
for _, v := range value.args {
if implVarScan(v) {
return true
}
}
for _, v := range value.optArgs {
if implVarScan(v) {
return true
}
}
return false
} | [
"func",
"implVarScan",
"(",
"value",
"Term",
")",
"bool",
"{",
"if",
"value",
".",
"termType",
"==",
"p",
".",
"Term_IMPLICIT_VAR",
"{",
"return",
"true",
"\n",
"}",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"value",
".",
"args",
"{",
"if",
"implVar... | // implVarScan recursivly checks a value to see if it contains an
// IMPLICIT_VAR term. If it does it returns true | [
"implVarScan",
"recursivly",
"checks",
"a",
"value",
"to",
"see",
"if",
"it",
"contains",
"an",
"IMPLICIT_VAR",
"term",
".",
"If",
"it",
"does",
"it",
"returns",
"true"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L142-L159 |
30,286 | rethinkdb/rethinkdb-go | utils.go | optArgsToMap | func optArgsToMap(optArgs OptArgs) map[string]interface{} {
data, err := encode(optArgs)
if err == nil && data != nil {
if m, ok := data.(map[string]interface{}); ok {
return m
}
}
return map[string]interface{}{}
} | go | func optArgsToMap(optArgs OptArgs) map[string]interface{} {
data, err := encode(optArgs)
if err == nil && data != nil {
if m, ok := data.(map[string]interface{}); ok {
return m
}
}
return map[string]interface{}{}
} | [
"func",
"optArgsToMap",
"(",
"optArgs",
"OptArgs",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"data",
",",
"err",
":=",
"encode",
"(",
"optArgs",
")",
"\n\n",
"if",
"err",
"==",
"nil",
"&&",
"data",
"!=",
"nil",
"{",
"if",
"m",
","... | // Convert an opt args struct to a map. | [
"Convert",
"an",
"opt",
"args",
"struct",
"to",
"a",
"map",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L162-L172 |
30,287 | rethinkdb/rethinkdb-go | utils.go | convertTermList | func convertTermList(l []interface{}) termsList {
if len(l) == 0 {
return nil
}
terms := make(termsList, len(l))
for i, v := range l {
terms[i] = Expr(v)
}
return terms
} | go | func convertTermList(l []interface{}) termsList {
if len(l) == 0 {
return nil
}
terms := make(termsList, len(l))
for i, v := range l {
terms[i] = Expr(v)
}
return terms
} | [
"func",
"convertTermList",
"(",
"l",
"[",
"]",
"interface",
"{",
"}",
")",
"termsList",
"{",
"if",
"len",
"(",
"l",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"terms",
":=",
"make",
"(",
"termsList",
",",
"len",
"(",
"l",
")",
")",
... | // Convert a list into a slice of terms | [
"Convert",
"a",
"list",
"into",
"a",
"slice",
"of",
"terms"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L175-L186 |
30,288 | rethinkdb/rethinkdb-go | utils.go | convertTermObj | func convertTermObj(o map[string]interface{}) termsObj {
if len(o) == 0 {
return nil
}
terms := make(termsObj, len(o))
for k, v := range o {
terms[k] = Expr(v)
}
return terms
} | go | func convertTermObj(o map[string]interface{}) termsObj {
if len(o) == 0 {
return nil
}
terms := make(termsObj, len(o))
for k, v := range o {
terms[k] = Expr(v)
}
return terms
} | [
"func",
"convertTermObj",
"(",
"o",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"termsObj",
"{",
"if",
"len",
"(",
"o",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"terms",
":=",
"make",
"(",
"termsObj",
",",
"len",
"(",
"... | // Convert a map into a map of terms | [
"Convert",
"a",
"map",
"into",
"a",
"map",
"of",
"terms"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L189-L200 |
30,289 | rethinkdb/rethinkdb-go | utils.go | allArgsToStringSlice | func allArgsToStringSlice(args termsList, optArgs termsObj) []string {
allArgs := make([]string, len(args)+len(optArgs))
i := 0
for _, v := range args {
allArgs[i] = v.String()
i++
}
for k, v := range optArgs {
allArgs[i] = k + "=" + v.String()
i++
}
return allArgs
} | go | func allArgsToStringSlice(args termsList, optArgs termsObj) []string {
allArgs := make([]string, len(args)+len(optArgs))
i := 0
for _, v := range args {
allArgs[i] = v.String()
i++
}
for k, v := range optArgs {
allArgs[i] = k + "=" + v.String()
i++
}
return allArgs
} | [
"func",
"allArgsToStringSlice",
"(",
"args",
"termsList",
",",
"optArgs",
"termsObj",
")",
"[",
"]",
"string",
"{",
"allArgs",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"args",
")",
"+",
"len",
"(",
"optArgs",
")",
")",
"\n",
"i",
":=",... | // Helper functions for debugging | [
"Helper",
"functions",
"for",
"debugging"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L204-L218 |
30,290 | rethinkdb/rethinkdb-go | utils.go | shouldRetryQuery | func shouldRetryQuery(q Query, err error) bool {
if err == nil {
return false
}
if _, ok := err.(RQLConnectionError); ok {
return true
}
return err == ErrConnectionClosed
} | go | func shouldRetryQuery(q Query, err error) bool {
if err == nil {
return false
}
if _, ok := err.(RQLConnectionError); ok {
return true
}
return err == ErrConnectionClosed
} | [
"func",
"shouldRetryQuery",
"(",
"q",
"Query",
",",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"err",
".",
"(",
"RQLConnectionError",
")",
";",
"ok",
"{",
"retu... | // shouldRetryQuery checks the result of a query and returns true if the query
// should be retried | [
"shouldRetryQuery",
"checks",
"the",
"result",
"of",
"a",
"query",
"and",
"returns",
"true",
"if",
"the",
"query",
"should",
"be",
"retried"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/utils.go#L273-L283 |
30,291 | rethinkdb/rethinkdb-go | query_time.go | ISO8601 | func ISO8601(date interface{}, optArgs ...ISO8601Opts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("ISO8601", p.Term_ISO8601, []interface{}{date}, opts)
} | go | func ISO8601(date interface{}, optArgs ...ISO8601Opts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("ISO8601", p.Term_ISO8601, []interface{}{date}, opts)
} | [
"func",
"ISO8601",
"(",
"date",
"interface",
"{",
"}",
",",
"optArgs",
"...",
"ISO8601Opts",
")",
"Term",
"{",
"opts",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"}",
"\n",
"if",
"len",
"(",
"optArgs",
")",
">=",
"1",
"{",
"opts",... | // ISO8601 returns a time object based on an ISO8601 formatted date-time string | [
"ISO8601",
"returns",
"a",
"time",
"object",
"based",
"on",
"an",
"ISO8601",
"formatted",
"date",
"-",
"time",
"string"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L32-L39 |
30,292 | rethinkdb/rethinkdb-go | query_time.go | Timezone | func (t Term) Timezone(args ...interface{}) Term {
return constructMethodTerm(t, "Timezone", p.Term_TIMEZONE, args, map[string]interface{}{})
} | go | func (t Term) Timezone(args ...interface{}) Term {
return constructMethodTerm(t, "Timezone", p.Term_TIMEZONE, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Timezone",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TIMEZONE",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interfac... | // Timezone returns the timezone of the time object | [
"Timezone",
"returns",
"the",
"timezone",
"of",
"the",
"time",
"object"
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L50-L52 |
30,293 | rethinkdb/rethinkdb-go | query_time.go | TimeOfDay | func (t Term) TimeOfDay(args ...interface{}) Term {
return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
} | go | func (t Term) TimeOfDay(args ...interface{}) Term {
return constructMethodTerm(t, "TimeOfDay", p.Term_TIME_OF_DAY, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"TimeOfDay",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TIME_OF_DAY",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inte... | // TimeOfDay returns the number of seconds elapsed since the beginning of the
// day stored in the time object. | [
"TimeOfDay",
"returns",
"the",
"number",
"of",
"seconds",
"elapsed",
"since",
"the",
"beginning",
"of",
"the",
"day",
"stored",
"in",
"the",
"time",
"object",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L82-L84 |
30,294 | rethinkdb/rethinkdb-go | query_time.go | Year | func (t Term) Year(args ...interface{}) Term {
return constructMethodTerm(t, "Year", p.Term_YEAR, args, map[string]interface{}{})
} | go | func (t Term) Year(args ...interface{}) Term {
return constructMethodTerm(t, "Year", p.Term_YEAR, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Year",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_YEAR",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{... | // Year returns the year of a time object. | [
"Year",
"returns",
"the",
"year",
"of",
"a",
"time",
"object",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L87-L89 |
30,295 | rethinkdb/rethinkdb-go | query_time.go | Day | func (t Term) Day(args ...interface{}) Term {
return constructMethodTerm(t, "Day", p.Term_DAY, args, map[string]interface{}{})
} | go | func (t Term) Day(args ...interface{}) Term {
return constructMethodTerm(t, "Day", p.Term_DAY, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Day",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_DAY",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
"{",... | // Day return the day of a time object as a number between 1 and 31. | [
"Day",
"return",
"the",
"day",
"of",
"a",
"time",
"object",
"as",
"a",
"number",
"between",
"1",
"and",
"31",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L99-L101 |
30,296 | rethinkdb/rethinkdb-go | query_time.go | Hours | func (t Term) Hours(args ...interface{}) Term {
return constructMethodTerm(t, "Hours", p.Term_HOURS, args, map[string]interface{}{})
} | go | func (t Term) Hours(args ...interface{}) Term {
return constructMethodTerm(t, "Hours", p.Term_HOURS, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Hours",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_HOURS",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface",
... | // Hours returns the hour in a time object as a number between 0 and 23. | [
"Hours",
"returns",
"the",
"hour",
"in",
"a",
"time",
"object",
"as",
"a",
"number",
"between",
"0",
"and",
"23",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L118-L120 |
30,297 | rethinkdb/rethinkdb-go | query_time.go | Minutes | func (t Term) Minutes(args ...interface{}) Term {
return constructMethodTerm(t, "Minutes", p.Term_MINUTES, args, map[string]interface{}{})
} | go | func (t Term) Minutes(args ...interface{}) Term {
return constructMethodTerm(t, "Minutes", p.Term_MINUTES, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"Minutes",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_MINUTES",
",",
"args",
",",
"map",
"[",
"string",
"]",
"interface"... | // Minutes returns the minute in a time object as a number between 0 and 59. | [
"Minutes",
"returns",
"the",
"minute",
"in",
"a",
"time",
"object",
"as",
"a",
"number",
"between",
"0",
"and",
"59",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L123-L125 |
30,298 | rethinkdb/rethinkdb-go | query_time.go | ToISO8601 | func (t Term) ToISO8601(args ...interface{}) Term {
return constructMethodTerm(t, "ToISO8601", p.Term_TO_ISO8601, args, map[string]interface{}{})
} | go | func (t Term) ToISO8601(args ...interface{}) Term {
return constructMethodTerm(t, "ToISO8601", p.Term_TO_ISO8601, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ToISO8601",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TO_ISO8601",
",",
"args",
",",
"map",
"[",
"string",
"]",
"inter... | // ToISO8601 converts a time object to its iso 8601 format. | [
"ToISO8601",
"converts",
"a",
"time",
"object",
"to",
"its",
"iso",
"8601",
"format",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L134-L136 |
30,299 | rethinkdb/rethinkdb-go | query_time.go | ToEpochTime | func (t Term) ToEpochTime(args ...interface{}) Term {
return constructMethodTerm(t, "ToEpochTime", p.Term_TO_EPOCH_TIME, args, map[string]interface{}{})
} | go | func (t Term) ToEpochTime(args ...interface{}) Term {
return constructMethodTerm(t, "ToEpochTime", p.Term_TO_EPOCH_TIME, args, map[string]interface{}{})
} | [
"func",
"(",
"t",
"Term",
")",
"ToEpochTime",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"Term",
"{",
"return",
"constructMethodTerm",
"(",
"t",
",",
"\"",
"\"",
",",
"p",
".",
"Term_TO_EPOCH_TIME",
",",
"args",
",",
"map",
"[",
"string",
"]",
"... | // ToEpochTime converts a time object to its epoch time. | [
"ToEpochTime",
"converts",
"a",
"time",
"object",
"to",
"its",
"epoch",
"time",
"."
] | 04a849766900ad9c936ba78770186640e3bede20 | https://github.com/rethinkdb/rethinkdb-go/blob/04a849766900ad9c936ba78770186640e3bede20/query_time.go#L139-L141 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.