Prepare the Cursor returned by {@link Query::execute()}.

This method will apply cursor options present in the query structure
array. The Cursor may also be wrapped with an EagerCursor.

@param Cursor $cursor
@return CursorInterface
499853
protected function prepareCursor(Cursor $cursor)
    {
        /* Note: if this cursor resulted from a mapReduce command, applying the
         * read preference may be undesirable. Results would have been written
         * to the primary and replication may still be in progress.
         */
        if (isset($this->query['readPreference'])) {
            $cursor->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);
        }

        foreach ($this->getQueryOptions('hint', 'immortal', 'limit', 'maxTimeMS', 'skip', 'slaveOkay', 'sort') as $key => $value) {
            $cursor->$key($value);
        }

        if ( ! empty($this->query['snapshot'])) {
            $cursor->snapshot();
        }

        if ( ! empty($this->query['eagerCursor'])) {
            $cursor = new EagerCursor($cursor);
        }

        if (isset($this->query['useIdentifierKeys'])) {
            $cursor->setUseIdentifierKeys($this->query['useIdentifierKeys']);
        }

        return $cursor;
    }
1109688
public static ScanCursor of(String cursor) {
        ScanCursor scanCursor = new ScanCursor();
        scanCursor.setCursor(cursor);
        return scanCursor;
    }
136392
public function tokenize(Cursor $cursor)
    {
        $stream = [];

        foreach (parent::tokenize($cursor) as $offset => $token) {
            if ($token->is(Token::TYPE_STRING | Token::TYPE_BACK_QUOTED)) {
                $line = $token->getLine();

                $stream = array_merge($stream, $this->templateLexer->tokenize(new Cursor($token->getValue(), $line)));
            } else {
                $stream[] = $token;
            }
        }

        return $stream;
    }
572365
public Cursor getCursor() throws SQLException {
		if (cursor == null) {
			String finalSql = null;
			try {
				if (max == null) {
					finalSql = sql;
				} else {
					finalSql = sql + " LIMIT " + max;
				}
				if (cancelQueriesEnabled) {
					cancellationHook = apiCompatibility.createCancellationHook();
				}
				cursor = apiCompatibility.rawQuery(db, finalSql, getStringArray(), cancellationHook);
				cursor.moveToFirst();
				logger.trace("{}: started rawQuery cursor for: {}", this, finalSql);
			} catch (android.database.SQLException e) {
				throw SqlExceptionUtil.create("Problems executing Android query: " + finalSql, e);
			}
		}

		return cursor;
	}
793003
public function restGet($cursor) {
        if ($cursor instanceof Cursor) {
            $name = $cursor->getCollection()->getName();
            $criteria = $cursor->getCriteria();
            $limit = $cursor->limit();
            $skip = $cursor->skip();
            $sorts = $cursor->sort();

            $query = array();

            foreach ($criteria as $key => $value) {
                $query[$key] = $value;
            }

            if ($limit) {
                $query['!limit'] = $limit;
            }

            if ($skip) {
                $query['!skip'] = $skip;
            }

            if (!empty($sorts)) {
                foreach ($sorts as $key => $value) {
                    $query["!sort[$key]"] = $value;
                }
            }

            $qs = array();

            foreach ($query as $key => $value) {
                if (is_array($value)) {
                    foreach ($value as $k => $v) {
                        $qs[] = '!'.$key.'='.$v;
                    }
                } else {
                    $qs[] = $key.'='.$value;
                }
            }

            if ($qs) {
                $qs = '?'.implode('&', $qs);
            } else {
                $qs = '';
            }

            $url = $this->option('baseUrl').'/'.$name.'.json'.$qs;

            $client = new Client();
            $response = $client->get($url)->send();

            return json_decode($response->getBody(true), true);
        } else {
            throw new Exception('Unimplemented yet!');
        }
    }
1313938
private function wrapCursor(Cursor $baseCursor) : Iterator
    {
        return new CachingIterator(new HydratingIterator($baseCursor, $this->dm->getUnitOfWork(), $this->class));
    }
840113
public function execute($query)
    {
        $this->db->setQuery($query)->execute();

        $this->cursor = $this->db->getCursor();

        return $this;
    }
233592
public function loadCurrent($model, &$cursor)
    {
        $model->data = array_shift($cursor);
        $model->id = $model->data[$model->id_field];
    }
506594
public function getNumRows($cur = null)
	{
		$this->connect();

		return pg_num_rows((int) $cur ? $cur : $this->cursor);
	}
993135
public static <T extends Model> List<T> processCursor(Class<T> cls, Cursor cursor) {
		final List<T> entities = new ArrayList<T>();
		try {
			Constructor<T> entityConstructor = cls.getConstructor();
			if (cursor.moveToFirst()) {
				do {
					T entity = getEntity(cls, cursor.getLong(cursor.getColumnIndex(BaseColumns._ID)));
					if (entity == null) {
						entity = entityConstructor.newInstance();
					}

					entity.load(cursor);
					entities.add(entity);
				}
				while (cursor.moveToNext());
			}
		} catch (Exception e) {
			Log.e(TAG, "Failed to process cursor.", e);
		}

		return entities;
	}
1227175
public <T> CursorIterable<T> asIterable() {
		PreparedQuery preparedQuery = getDatastoreService().prepare(transaction, query);
		QueryResultIterable<Entity> iterable = preparedQuery.asQueryResultIterable(fetchOptions);
		return new CursorIterableImpl<T>(classMetadata, predicate, iterable).setKeysOnly(isKeysOnly());
	}
544383
public static function cursorToOffset($cursor)
    {
        $offset = substr(base64_decode($cursor), strlen(self::PREFIX));
        if (is_numeric($offset)){
            return intval($offset);
        } else {
            return null;
        }
    }
1062278
public function find($callable = null)
    {
        /** @var Cursor $cursor */
        $cursor = new Cursor($this, array(
            'expressionClass'   => $this->definition->getExpressionClass(),
            'batchSize'         => $this->definition->getOption('batchSize'),
            'clientTimeout'     => $this->definition->getOption('cursorClientTimeout'),
            'serverTimeout'     => $this->definition->getOption('cursorServerTimeout'),
        ));

        if (is_callable($callable)) {
            $callable($cursor->getExpression());
        }

        return $cursor;
    }
833770
public function next()
    {
        $cursor = $this;
        $this->retry(function() use ($cursor) {
            $cursor->getRiakCursor()->next();
        }, false);
    }
365010
public function getPaginatorCursor($params)
    {
        $filter = $this->getService('filterManager')->get('Jobs/PaginationQuery');
        /* @var $filter \Core\Repository\Filter\AbstractPaginationQuery  */
        $qb = $filter->filter($params, $this->createQueryBuilder());
        return $qb->getQuery()->execute();
    }
1193135
def _execute(self, *args):
        
        cursor = self.db.cursor()
        cursor.execute(*args)
        return cursor
234110
public function useCursor()
	{
	    //@codeCoverageIgnoreStart
	    if (! $this->jsWriter instanceOf \AltaMira\JsWriter\Ability\Cursorable ) {
            throw new \BadMethodCallException( "JsWriter cannot use cursor" );
	    }
	    //@codeCoverageIgnoreEnd
	    
	    $this->jsWriter->useCursor();
	    
	    return $this;
	}