| 1 | package rethinkdbscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.14 bytes/" |
| 5 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/" |
| 6 | "errorsscip-go gomod github.com/golang/go/src go1.14 errors/" |
| 7 | "reflectscip-go gomod github.com/golang/go/src go1.14 reflect/" |
| 8 | "syncscip-go gomod github.com/golang/go/src go1.14 sync/" |
| 9 | |
| 10 | "github.com/opentracing/opentracing-goscip-go gomod github.com/opentracing/opentracing-go v1.1.0 `github.com/opentracing/opentracing-go`/" |
| 11 | "golang.org/x/net/contextscip-go gomod golang.org/x/net eb5bcb51f2a3 `golang.org/x/net/context`/" |
| 12 | "gopkg.in/rethinkdb/rethinkdb-go.v6/encodingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/" |
| 13 | pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/ "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2scip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/" |
| 14 | ) |
| 15 | |
| 16 | var ( |
| 17 | errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. = errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("cursor is nil") |
| 18 | errCursorClosedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errCursorClosed. = errorsscip-go gomod github.com/golang/go/src go1.14 errors/.Newscip-go gomod github.com/golang/go/src go1.14 errors/New().("connection connClosed, cannot read cursor") |
| 19 | ) |
| 20 | |
| 21 | func newCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/newCursor().(ctx contextscip-go gomod golang.org/x/net eb5bcb51f2a3 `golang.org/x/net/context`/.Contextscip-go gomod golang.org/x/net eb5bcb51f2a3 `golang.org/x/net/context`/Context#, conn *Connectionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Connection#, cursorType string, token int64, term *Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term#, opts map[string]interface{}) *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor# { |
| 22 | if cursorType == "" { |
| 23 | cursorType = "Cursor" |
| 24 | } |
| 25 | |
| 26 | connOpts := &ConnectOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ConnectOpts#{} |
| 27 | if conn != nil { |
| 28 | connOpts = conn.optsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Connection#opts. |
| 29 | } |
| 30 | |
| 31 | cursor := &Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#{ |
| 32 | connscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#conn.: conn, |
| 33 | connOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#connOpts.: connOpts, |
| 34 | tokenscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#token.: token, |
| 35 | cursorTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#cursorType.: cursorType, |
| 36 | termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#term.: term, |
| 37 | optsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#opts.: opts, |
| 38 | bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.: make([]interface{}, 0), |
| 39 | responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.: make([]jsonscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.14 `encoding/json`/RawMessage#, 0), |
| 40 | ctxscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#ctx.: ctx, |
| 41 | } |
| 42 | |
| 43 | return cursor |
| 44 | } |
| 45 | |
| 46 | // Cursor is the result of a query. Its cursor starts before the first row |
| 47 | // of the result set. A Cursor is not thread safe and should only be accessed |
| 48 | // by a single goroutine at any given time. Use Next to advance through the |
| 49 | // rows: |
| 50 | // |
| 51 | // cursor, err := query.Run(session) |
| 52 | // ... |
| 53 | // defer cursor.Close() |
| 54 | // |
| 55 | // var response interface{} |
| 56 | // for cursor.Next(&response) { |
| 57 | // ... |
| 58 | // } |
| 59 | // err = cursor.Err() // get any error encountered during iteration |
| 60 | // ... |
| 61 | type Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor# struct { |
| 62 | releaseConnscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#releaseConn. func() error |
| 63 | |
| 64 | connscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#conn. *Connectionscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Connection# |
| 65 | connOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#connOpts. *ConnectOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ConnectOpts# |
| 66 | tokenscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#token. int64 |
| 67 | cursorTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#cursorType. string |
| 68 | termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#term. *Termscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Term# |
| 69 | optsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#opts. map[string]interface{} |
| 70 | ctxscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#ctx. contextscip-go gomod golang.org/x/net eb5bcb51f2a3 `golang.org/x/net/context`/.Contextscip-go gomod golang.org/x/net eb5bcb51f2a3 `golang.org/x/net/context`/Context# |
| 71 | |
| 72 | muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu. syncscip-go gomod github.com/golang/go/src go1.14 sync/.RWMutexscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex# |
| 73 | lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. error |
| 74 | fetchingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#fetching. bool |
| 75 | closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. bool |
| 76 | finishedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#finished. bool |
| 77 | isAtomscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isAtom. bool |
| 78 | isSingleValuescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isSingleValue. bool |
| 79 | pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. int |
| 80 | bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. []interface{} |
| 81 | responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. []jsonscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.14 `encoding/json`/RawMessage# |
| 82 | profilescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#profile. interface{} |
| 83 | } |
| 84 | |
| 85 | // Profile returns the information returned from the query profiler. |
| 86 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Profilescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Profile().() interface{} { |
| 87 | if c == nil { |
| 88 | return nil |
| 89 | } |
| 90 | |
| 91 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RLockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RLock().() |
| 92 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RUnlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RUnlock().() |
| 93 | |
| 94 | return c.profilescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#profile. |
| 95 | } |
| 96 | |
| 97 | // Type returns the cursor type (by default "Cursor") |
| 98 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Typescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Type().() string { |
| 99 | if c == nil { |
| 100 | return "Cursor" |
| 101 | } |
| 102 | |
| 103 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RLockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RLock().() |
| 104 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RUnlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RUnlock().() |
| 105 | |
| 106 | return c.cursorTypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#cursorType. |
| 107 | } |
| 108 | |
| 109 | // Err returns nil if no errors happened during iteration, or the actual |
| 110 | // error otherwise. |
| 111 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Errscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Err().() error { |
| 112 | if c == nil { |
| 113 | return errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. |
| 114 | } |
| 115 | |
| 116 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RLockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RLock().() |
| 117 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RUnlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RUnlock().() |
| 118 | |
| 119 | return c.lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. |
| 120 | } |
| 121 | |
| 122 | // Close closes the cursor, preventing further enumeration. If the end is |
| 123 | // encountered, the cursor is connClosed automatically. Close is idempotent. |
| 124 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() error { |
| 125 | if c == nil { |
| 126 | return errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. |
| 127 | } |
| 128 | |
| 129 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 130 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 131 | |
| 132 | var err error |
| 133 | |
| 134 | // If cursor is already connClosed return immediately |
| 135 | closed := c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. |
| 136 | if closed { |
| 137 | return nil |
| 138 | } |
| 139 | |
| 140 | // Get connection and check its valid, don't need to lock as this is only |
| 141 | // set when the cursor is created |
| 142 | conn := c.connscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#conn. |
| 143 | if conn == nil { |
| 144 | return nil |
| 145 | } |
| 146 | if conn.isClosedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Connection#isClosed().() { |
| 147 | return nil |
| 148 | } |
| 149 | |
| 150 | // Stop any unfinished queries |
| 151 | if !c.finishedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#finished. { |
| 152 | _, _, err = conn.Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Connection#Query().(c.ctxscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#ctx., newStopQueryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/newStopQuery().(c.tokenscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#token.)) |
| 153 | } |
| 154 | |
| 155 | if c.releaseConnscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#releaseConn. != nil { |
| 156 | if err := c.releaseConnscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#releaseConn.(); err != nil { |
| 157 | return err |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if span := opentracingscip-go gomod github.com/opentracing/opentracing-go v1.1.0 `github.com/opentracing/opentracing-go`/.SpanFromContextscip-go gomod github.com/opentracing/opentracing-go v1.1.0 `github.com/opentracing/opentracing-go`/SpanFromContext().(c.ctxscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#ctx.); span != nil { |
| 162 | span.Finishscip-go gomod github.com/opentracing/opentracing-go v1.1.0 `github.com/opentracing/opentracing-go`/Span#Finish().() |
| 163 | } |
| 164 | |
| 165 | c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. = true |
| 166 | c.connscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#conn. = nil |
| 167 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = nil |
| 168 | c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. = nil |
| 169 | |
| 170 | return err |
| 171 | } |
| 172 | |
| 173 | // Next retrieves the next document from the result set, blocking if necessary. |
| 174 | // This method will also automatically retrieve another batch of documents from |
| 175 | // the server when the current one is exhausted, or before that in background |
| 176 | // if possible. |
| 177 | // |
| 178 | // Next returns true if a document was successfully unmarshalled onto result, |
| 179 | // and false at the end of the result set or if an error happened. |
| 180 | // When Next returns false, the Err method should be called to verify if |
| 181 | // there was an error during iteration. |
| 182 | // |
| 183 | // Also note that you are able to reuse the same variable multiple times as |
| 184 | // `Next` zeroes the value before scanning in the result. |
| 185 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Nextscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Next().(dest interface{}) bool { |
| 186 | if c == nil { |
| 187 | return false |
| 188 | } |
| 189 | |
| 190 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 191 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 192 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 193 | return false |
| 194 | } |
| 195 | |
| 196 | hasMore, err := c.nextLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#nextLocked().(dest, true) |
| 197 | if c.handleErrorLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#handleErrorLocked().(err) != nil { |
| 198 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 199 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 200 | return false |
| 201 | } |
| 202 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 203 | |
| 204 | if !hasMore { |
| 205 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 206 | } |
| 207 | |
| 208 | return hasMore |
| 209 | } |
| 210 | |
| 211 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) nextLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#nextLocked().(dest interface{}, progressCursor bool) (bool, error) { |
| 212 | for { |
| 213 | if err := c.seekCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#seekCursor().(true); err != nil { |
| 214 | return false, err |
| 215 | } |
| 216 | |
| 217 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 218 | return false, nil |
| 219 | } |
| 220 | |
| 221 | if len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) == 0 && c.finishedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#finished. { |
| 222 | return false, nil |
| 223 | } |
| 224 | |
| 225 | if len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) > 0 { |
| 226 | data := c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.[0] |
| 227 | if progressCursor { |
| 228 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.[1:] |
| 229 | } |
| 230 | err := encodingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/.Decodescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/Decode().(dest, data) |
| 231 | if err != nil { |
| 232 | return false, err |
| 233 | } |
| 234 | |
| 235 | return true, nil |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | // Peek behaves similarly to Next, retreiving the next document from the result set |
| 241 | // and blocking if necessary. Peek, however, does not progress the position of the cursor. |
| 242 | // This can be useful for expressions which can return different types to attempt to |
| 243 | // decode them into different interfaces. |
| 244 | // |
| 245 | // Like Next, it will also automatically retrieve another batch of documents from |
| 246 | // the server when the current one is exhausted, or before that in background |
| 247 | // if possible. |
| 248 | // |
| 249 | // Unlike Next, Peek does not progress the position of the cursor. Peek |
| 250 | // will return errors from decoding, but they will not be persisted in the cursor |
| 251 | // and therefore will not be available on cursor.Err(). This can be useful for |
| 252 | // expressions that can return different types to attempt to decode them into |
| 253 | // different interfaces. |
| 254 | // |
| 255 | // Peek returns true if a document was successfully unmarshalled onto result, |
| 256 | // and false at the end of the result set or if an error happened. Peek also |
| 257 | // returns the error (if any) that occured |
| 258 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Peekscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Peek().(dest interface{}) (bool, error) { |
| 259 | if c == nil { |
| 260 | return false, errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. |
| 261 | } |
| 262 | |
| 263 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 264 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 265 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 266 | return false, nil |
| 267 | } |
| 268 | |
| 269 | hasMore, err := c.nextLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#nextLocked().(dest, false) |
| 270 | if _, isDecodeErr := err.(*encodingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/.DecodeTypeErrorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/encoding`/DecodeTypeError#); isDecodeErr { |
| 271 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 272 | return false, err |
| 273 | } |
| 274 | |
| 275 | if c.handleErrorLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#handleErrorLocked().(err) != nil { |
| 276 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 277 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 278 | return false, err |
| 279 | } |
| 280 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 281 | |
| 282 | return hasMore, nil |
| 283 | } |
| 284 | |
| 285 | // Skip progresses the cursor by one record. It is useful after a successful |
| 286 | // Peek to avoid duplicate decoding work. |
| 287 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Skipscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Skip().() { |
| 288 | if c == nil { |
| 289 | return |
| 290 | } |
| 291 | |
| 292 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 293 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 294 | c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips.++ |
| 295 | } |
| 296 | |
| 297 | // NextResponse retrieves the next raw response from the result set, blocking if necessary. |
| 298 | // Unlike Next the returned response is the raw JSON document returned from the |
| 299 | // database. |
| 300 | // |
| 301 | // NextResponse returns false (and a nil byte slice) at the end of the result |
| 302 | // set or if an error happened. |
| 303 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) NextResponsescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#NextResponse().() ([]byte, bool) { |
| 304 | if c == nil { |
| 305 | return nil, false |
| 306 | } |
| 307 | |
| 308 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 309 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 310 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 311 | return nil, false |
| 312 | } |
| 313 | |
| 314 | b, hasMore, err := c.nextResponseLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#nextResponseLocked().() |
| 315 | if c.handleErrorLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#handleErrorLocked().(err) != nil { |
| 316 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 317 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 318 | return nil, false |
| 319 | } |
| 320 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 321 | |
| 322 | if !hasMore { |
| 323 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 324 | } |
| 325 | |
| 326 | return b, hasMore |
| 327 | } |
| 328 | |
| 329 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) nextResponseLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#nextResponseLocked().() ([]byte, bool, error) { |
| 330 | for { |
| 331 | if err := c.seekCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#seekCursor().(false); err != nil { |
| 332 | return nil, false, err |
| 333 | } |
| 334 | |
| 335 | if len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) == 0 && c.finishedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#finished. { |
| 336 | return nil, false, nil |
| 337 | } |
| 338 | |
| 339 | if len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) > 0 { |
| 340 | var response jsonscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.14 `encoding/json`/RawMessage# |
| 341 | response, c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. = c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[0], c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[1:] |
| 342 | |
| 343 | return []byte(response), true, nil |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | // All retrieves all documents from the result set into the provided slice |
| 349 | // and closes the cursor. |
| 350 | // |
| 351 | // The result argument must necessarily be the address for a slice. The slice |
| 352 | // may be nil or previously allocated. |
| 353 | // |
| 354 | // Also note that you are able to reuse the same variable multiple times as |
| 355 | // `All` zeroes the value before scanning in the result. It also attempts |
| 356 | // to reuse the existing slice without allocating any more space by either |
| 357 | // resizing or returning a selection of the slice if necessary. |
| 358 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Allscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#All().(result interface{}) error { |
| 359 | if c == nil { |
| 360 | return errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. |
| 361 | } |
| 362 | |
| 363 | resultv := reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.14 reflect/ValueOf().(result) |
| 364 | if resultv.Kindscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Kind().() != reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Ptrscip-go gomod github.com/golang/go/src go1.14 reflect/Ptr. || resultv.Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Elem().().Kindscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Kind().() != reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Slicescip-go gomod github.com/golang/go/src go1.14 reflect/Slice. { |
| 365 | panic("result argument must be a slice address") |
| 366 | } |
| 367 | slicev := resultv.Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Elem().() |
| 368 | slicev = slicev.Slicescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Slice().(0, slicev.Capscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Cap().()) |
| 369 | elemt := slicev.Typescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Type().().Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Type#Elem().() |
| 370 | i := 0 |
| 371 | for { |
| 372 | if slicev.Lenscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Len().() == i { |
| 373 | elemp := reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Newscip-go gomod github.com/golang/go/src go1.14 reflect/New().(elemt) |
| 374 | if !c.Nextscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Next().(elemp.Interfacescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Interface().()) { |
| 375 | break |
| 376 | } |
| 377 | slicev = reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Appendscip-go gomod github.com/golang/go/src go1.14 reflect/Append().(slicev, elemp.Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Elem().()) |
| 378 | slicev = slicev.Slicescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Slice().(0, slicev.Capscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Cap().()) |
| 379 | } else { |
| 380 | if !c.Nextscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Next().(slicev.Indexscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Index().(i).Addrscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Addr().().Interfacescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Interface().()) { |
| 381 | break |
| 382 | } |
| 383 | } |
| 384 | i++ |
| 385 | } |
| 386 | resultv.Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Elem().().Setscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Set().(slicev.Slicescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Slice().(0, i)) |
| 387 | |
| 388 | if err := c.Errscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Err().(); err != nil { |
| 389 | _ = c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 390 | return err |
| 391 | } |
| 392 | |
| 393 | if err := c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().(); err != nil { |
| 394 | return err |
| 395 | } |
| 396 | |
| 397 | return nil |
| 398 | } |
| 399 | |
| 400 | // One retrieves a single document from the result set into the provided |
| 401 | // slice and closes the cursor. |
| 402 | // |
| 403 | // Also note that you are able to reuse the same variable multiple times as |
| 404 | // `One` zeroes the value before scanning in the result. |
| 405 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Onescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#One().(result interface{}) error { |
| 406 | if c == nil { |
| 407 | return errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. |
| 408 | } |
| 409 | |
| 410 | if c.IsNilscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#IsNil().() { |
| 411 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 412 | return ErrEmptyResultscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ErrEmptyResult. |
| 413 | } |
| 414 | |
| 415 | hasResult := c.Nextscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Next().(result) |
| 416 | |
| 417 | if err := c.Errscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Err().(); err != nil { |
| 418 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 419 | return err |
| 420 | } |
| 421 | |
| 422 | if err := c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().(); err != nil { |
| 423 | return err |
| 424 | } |
| 425 | |
| 426 | if !hasResult { |
| 427 | return ErrEmptyResultscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ErrEmptyResult. |
| 428 | } |
| 429 | |
| 430 | return nil |
| 431 | } |
| 432 | |
| 433 | // Interface retrieves all documents from the result set and returns the data |
| 434 | // as an interface{} and closes the cursor. |
| 435 | // |
| 436 | // If the query returns multiple documents then a slice will be returned, |
| 437 | // otherwise a single value will be returned. |
| 438 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Interfacescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Interface().() (interface{}, error) { |
| 439 | if c == nil { |
| 440 | return nil, errNilCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errNilCursor. |
| 441 | } |
| 442 | |
| 443 | var results []interface{} |
| 444 | var result interface{} |
| 445 | for c.Nextscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Next().(&result) { |
| 446 | results = append(results, result) |
| 447 | } |
| 448 | |
| 449 | if err := c.Errscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Err().(); err != nil { |
| 450 | return nil, err |
| 451 | } |
| 452 | |
| 453 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RLockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RLock().() |
| 454 | isSingleValue := c.isSingleValuescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isSingleValue. |
| 455 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RUnlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RUnlock().() |
| 456 | |
| 457 | if isSingleValue { |
| 458 | if len(results) == 0 { |
| 459 | return nil, nil |
| 460 | } |
| 461 | |
| 462 | return results[0], nil |
| 463 | } |
| 464 | |
| 465 | return results, nil |
| 466 | } |
| 467 | |
| 468 | // Listen listens for rows from the database and sends the result onto the given |
| 469 | // channel. The type that the row is scanned into is determined by the element |
| 470 | // type of the channel. |
| 471 | // |
| 472 | // Also note that this function returns immediately. |
| 473 | // |
| 474 | // cursor, err := r.Expr([]int{1,2,3}).Run(session) |
| 475 | // if err != nil { |
| 476 | // panic(err) |
| 477 | // } |
| 478 | // |
| 479 | // ch := make(chan int) |
| 480 | // cursor.Listen(ch) |
| 481 | // <- ch // 1 |
| 482 | // <- ch // 2 |
| 483 | // <- ch // 3 |
| 484 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) Listenscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Listen().(channel interface{}) { |
| 485 | go func() { |
| 486 | channelv := reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.14 reflect/ValueOf().(channel) |
| 487 | if channelv.Kindscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Kind().() != reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Chanscip-go gomod github.com/golang/go/src go1.14 reflect/Chan. { |
| 488 | panic("input argument must be a channel") |
| 489 | } |
| 490 | elemt := channelv.Typescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Type().().Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Type#Elem().() |
| 491 | for { |
| 492 | elemp := reflectscip-go gomod github.com/golang/go/src go1.14 reflect/.Newscip-go gomod github.com/golang/go/src go1.14 reflect/New().(elemt) |
| 493 | if !c.Nextscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Next().(elemp.Interfacescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Interface().()) { |
| 494 | break |
| 495 | } |
| 496 | channelv.Sendscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Send().(elemp.Elemscip-go gomod github.com/golang/go/src go1.14 reflect/Value#Elem().()) |
| 497 | } |
| 498 | |
| 499 | c.Closescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#Close().() |
| 500 | channelv.Closescip-go gomod github.com/golang/go/src go1.14 reflect/Value#Close().() |
| 501 | }() |
| 502 | } |
| 503 | |
| 504 | // IsNil tests if the current row is nil. |
| 505 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) IsNilscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#IsNil().() bool { |
| 506 | if c == nil { |
| 507 | return true |
| 508 | } |
| 509 | |
| 510 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RLockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RLock().() |
| 511 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..RUnlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#RUnlock().() |
| 512 | |
| 513 | if len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) > 0 { |
| 514 | return c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.[0] == nil |
| 515 | } |
| 516 | |
| 517 | if len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) > 0 { |
| 518 | response := c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[0] |
| 519 | if response == nil { |
| 520 | return true |
| 521 | } |
| 522 | |
| 523 | if string(response) == "null" { |
| 524 | return true |
| 525 | } |
| 526 | |
| 527 | return false |
| 528 | } |
| 529 | |
| 530 | return true |
| 531 | } |
| 532 | |
| 533 | // fetchMore fetches more rows from the database. |
| 534 | // |
| 535 | // If wait is true then it will wait for the database to reply otherwise it |
| 536 | // will return after sending the continue query. |
| 537 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) fetchMorescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#fetchMore().() error { |
| 538 | var err error |
| 539 | |
| 540 | if !c.fetchingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#fetching. { |
| 541 | c.fetchingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#fetching. = true |
| 542 | |
| 543 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 544 | return errCursorClosedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errCursorClosed. |
| 545 | } |
| 546 | |
| 547 | q := Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#{ |
| 548 | Typescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#Type.: pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Query_CONTINUEscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Query_CONTINUE., |
| 549 | Tokenscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Query#Token.: c.tokenscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#token., |
| 550 | } |
| 551 | |
| 552 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 553 | _, _, err = c.connscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#conn..Queryscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Connection#Query().(c.ctxscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#ctx., q) |
| 554 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 555 | } |
| 556 | |
| 557 | return err |
| 558 | } |
| 559 | |
| 560 | // handleError sets the value of lastErr to err if lastErr is not yet set. |
| 561 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) handleErrorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#handleError().(err error) error { |
| 562 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 563 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 564 | |
| 565 | return c.handleErrorLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#handleErrorLocked().(err) |
| 566 | } |
| 567 | |
| 568 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) handleErrorLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#handleErrorLocked().(err error) error { |
| 569 | if c.lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. == nil { |
| 570 | c.lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. = err |
| 571 | } |
| 572 | |
| 573 | return c.lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. |
| 574 | } |
| 575 | |
| 576 | // extend adds the result of a continue query to the cursor. |
| 577 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) extendscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#extend().(response *Responsescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Response#) { |
| 578 | c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Lockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Lock().() |
| 579 | defer c.muscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#mu..Unlockscip-go gomod github.com/golang/go/src go1.14 sync/RWMutex#Unlock().() |
| 580 | |
| 581 | c.extendLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#extendLocked().(response) |
| 582 | } |
| 583 | |
| 584 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) extendLockedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#extendLocked().(response *Responsescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Response#) { |
| 585 | c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. = append(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses., response.Responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Response#Responses....) |
| 586 | c.finishedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#finished. = response.Typescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Response#Type. != pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Response_SUCCESS_PARTIALscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Response_SUCCESS_PARTIAL. |
| 587 | c.fetchingscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#fetching. = false |
| 588 | c.isAtomscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isAtom. = response.Typescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Response#Type. == pscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/.Response_SUCCESS_ATOMscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6/ql2`/Response_SUCCESS_ATOM. |
| 589 | } |
| 590 | |
| 591 | // seekCursor takes care of loading more data if needed and applying pending skips |
| 592 | // |
| 593 | // bufferResponse determines whether the response will be parsed into the buffer |
| 594 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) seekCursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#seekCursor().(bufferResponse bool) error { |
| 595 | if c.lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. != nil { |
| 596 | return c.lastErrscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#lastErr. |
| 597 | } |
| 598 | |
| 599 | if len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) == 0 && len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) == 0 && c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 600 | return errCursorClosedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errCursorClosed. |
| 601 | } |
| 602 | |
| 603 | // Loop over loading data, applying skips as necessary and loading more data as needed |
| 604 | // until either the cursor is connClosed or finished, or we have applied all outstanding |
| 605 | // skips and data is available |
| 606 | for { |
| 607 | c.applyPendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#applyPendingSkips().(bufferResponse) // if we are buffering the responses, skip can drain from the buffer |
| 608 | |
| 609 | if bufferResponse && len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) == 0 && len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) > 0 { |
| 610 | if err := c.bufferNextResponsescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#bufferNextResponse().(); err != nil { |
| 611 | return err |
| 612 | } |
| 613 | continue // go around the loop again to re-apply pending skips |
| 614 | } else if len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) == 0 && len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) == 0 && !c.finishedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#finished. { |
| 615 | // We skipped all of our data, load some more |
| 616 | if err := c.fetchMorescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#fetchMore().(); err != nil { |
| 617 | return err |
| 618 | } |
| 619 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 620 | return nil |
| 621 | } |
| 622 | continue // go around the loop again to re-apply pending skips |
| 623 | } |
| 624 | return nil |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | // applyPendingSkips applies all pending skips to the buffer and |
| 629 | // returns whether there are more pending skips to be applied |
| 630 | // |
| 631 | // if drainFromBuffer is true, we will drain from the buffer, otherwise |
| 632 | // we drain from the responses |
| 633 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) applyPendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#applyPendingSkips().(drainFromBuffer bool) (stillPending bool) { |
| 634 | if c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. == 0 { |
| 635 | return false |
| 636 | } |
| 637 | |
| 638 | if drainFromBuffer { |
| 639 | if len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) > c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. { |
| 640 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.[c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips.:] |
| 641 | c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. = 0 |
| 642 | return false |
| 643 | } |
| 644 | |
| 645 | c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. -= len(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.) |
| 646 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer.[:0] |
| 647 | return c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. > 0 |
| 648 | } |
| 649 | |
| 650 | if len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) > c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. { |
| 651 | c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. = c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips.:] |
| 652 | c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. = 0 |
| 653 | return false |
| 654 | } |
| 655 | |
| 656 | c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. -= len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) |
| 657 | c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. = c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[:0] |
| 658 | return c.pendingSkipsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#pendingSkips. > 0 |
| 659 | } |
| 660 | |
| 661 | // bufferResponse reads a single response and stores the result into the buffer |
| 662 | // if the response is from an atomic response, it will check if the |
| 663 | // response contains multiple records and store them all into the buffer |
| 664 | func (c *Cursorscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#) bufferNextResponsescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#bufferNextResponse().() error { |
| 665 | if c.closedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#closed. { |
| 666 | return errCursorClosedscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/errCursorClosed. |
| 667 | } |
| 668 | // If there are no responses, nothing to do |
| 669 | if len(c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.) == 0 { |
| 670 | return nil |
| 671 | } |
| 672 | |
| 673 | response := c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[0] |
| 674 | c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses. = c.responsesscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#responses.[1:] |
| 675 | |
| 676 | var value interface{} |
| 677 | decoder := jsonscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/.NewDecoderscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/NewDecoder().(bytesscip-go gomod github.com/golang/go/src go1.14 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.14 bytes/NewBuffer().(response)) |
| 678 | if c.connOptsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#connOpts..UseJSONNumberscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/ConnectOpts#UseJSONNumber. { |
| 679 | decoder.UseNumberscip-go gomod github.com/golang/go/src go1.14 `encoding/json`/Decoder#UseNumber().() |
| 680 | } |
| 681 | err := decoder.Decodescip-go gomod github.com/golang/go/src go1.14 `encoding/json`/Decoder#Decode().(&value) |
| 682 | if err != nil { |
| 683 | return err |
| 684 | } |
| 685 | |
| 686 | value, err = recursivelyConvertPseudotypescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/recursivelyConvertPseudotype().(value, c.optsscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#opts.) |
| 687 | if err != nil { |
| 688 | return err |
| 689 | } |
| 690 | |
| 691 | // If response is an ATOM then try and convert to an array |
| 692 | if data, ok := value.([]interface{}); ok && c.isAtomscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isAtom. { |
| 693 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = append(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer., data...) |
| 694 | } else if value == nil { |
| 695 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = append(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer., nil) |
| 696 | } else { |
| 697 | c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer. = append(c.bufferscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#buffer., value) |
| 698 | |
| 699 | // If this is the only value in the response and the response was an |
| 700 | // atom then set the single value flag |
| 701 | if c.isAtomscip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isAtom. { |
| 702 | c.isSingleValuescip-go gomod gopkg.in/rethinkdb/rethinkdb-go.v6 . `gopkg.in/rethinkdb/rethinkdb-go.v6`/Cursor#isSingleValue. = true |
| 703 | } |
| 704 | } |
| 705 | return nil |
| 706 | } |