Returns {@link Observable} with one item 1 but only after query
dependencies have been fully emitted (and ignored).

@param query

@return {@link Observable} with one element 1
437190
static Observable<Integer> singleIntegerAfterDependencies(Query query) {
        return concatButIgnoreFirstSequence(query.depends(), Observable.just(1));
    }
1109772
public static Evaluator parse(String query) {
        try {
            QueryParser p = new QueryParser(query);
            return p.parse();
        } catch (IllegalArgumentException e) {
            throw new Selector.SelectorParseException(e.getMessage());
        }
    }
879373
<E> Observable<E> wrapObservable(Observable<E> obs) {
        return obs.subscribeOn(Schedulers.io()).observeOn(Schedulers.io());
    }
121613
public Observable<ServiceResponse<OperationsListResultsInner>> listWithServiceResponseAsync() {
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.list(this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationsListResultsInner>>>() {
                @Override
                public Observable<ServiceResponse<OperationsListResultsInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<OperationsListResultsInner> clientResponse = listDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
487793
public Observable<AsyncSearchQueryResult> execute(final SearchQuery query, final long timeout,
        final TimeUnit timeUnit) {
        return deferAndWatch(new Func1<Subscriber, Observable<SearchQueryResponse>>() {
            @Override
            public Observable<SearchQueryResponse> call(Subscriber subscriber) {
                final SearchQueryRequest request = new SearchQueryRequest(
                        query.indexName(),
                        query.export().toString(),
                        bucket,
                        username,
                        password
                );
                Utils.addRequestSpan(environment, request, "search");
                request.subscriber(subscriber);
                return applyTimeout(core.<SearchQueryResponse>send(request), request, environment, timeout, timeUnit);
            }
        })
        .flatMap(new Func1<SearchQueryResponse, Observable<SearchQueryResponse>>() {
            @Override
            public Observable<SearchQueryResponse> call(final SearchQueryResponse r) {
                if (shouldRetry(r.statusCode())) {
                    return Observable.error(new RetryableException(r));
                }
                return Observable.just(r);
            }
        })
        .retryWhen(RetryBuilder
            .anyOf(RetryableException.class)
            .max(10)
            .delay(Delay.exponential(TimeUnit.MILLISECONDS, upperRetryLimit, lowerRetryLimit))
            .doOnRetry(new Action4<Integer, Throwable, Long, TimeUnit>() {
                @Override
                public void call(Integer attempt, Throwable error, Long delay, TimeUnit delayUnit) {
                    LOGGER.debug("Retrying {} because of {} (attempt {}, delay {} {})", query.export(),
                        error.getMessage(), attempt, delay, delayUnit);
            }
            })
            .build()
        )
        .map(new Func1<SearchQueryResponse, AsyncSearchQueryResult>() {
            @Override
            public AsyncSearchQueryResult call(final SearchQueryResponse response) {
                if (response.status().isSuccess()) {
                    JsonObject json = JsonObject.fromJson(response.payload());
                    return DefaultAsyncSearchQueryResult.fromJson(json);
                } else if (response.payload().contains("index not found")) {
                    return DefaultAsyncSearchQueryResult.fromIndexNotFound(query.indexName());
                } else if (response.status() == ResponseStatus.INVALID_ARGUMENTS) {
                    return DefaultAsyncSearchQueryResult.fromHttp400(response.payload());
                } else if (response.statusCode() == HTTP_PRECONDITION_FAILED) {
                    return DefaultAsyncSearchQueryResult.fromHttp412();
                } else {
                    throw new CouchbaseException("Could not query search index, "
                        + response.status() + ": " + response.payload());
                }
            }
        }).onErrorResumeNext(new Func1<Throwable, Observable<? extends AsyncSearchQueryResult>>() {
            @Override
            public Observable<? extends AsyncSearchQueryResult> call(Throwable throwable) {
                if (throwable instanceof CannotRetryException) {
                    if (throwable.getCause() != null && throwable.getCause() instanceof RetryableException) {
                        RetryableException x = (RetryableException) throwable.getCause();
                        if (x.response().statusCode() == HTTP_TOO_MANY_REQUESTS) {
                            return Observable.just(DefaultAsyncSearchQueryResult.fromHttp429(x.response().payload()));
                        } else {
                            return Observable.error(new CouchbaseException("Could not query search index, "
                                + x.response().status() + ": " + x.response().payload()));
                        }
                    }
                }
                return Observable.error(throwable);
            }
        });
    }
1318595
@Nullable
    private Object getSingleResult(Query query) {
        if (projection != null) {
            Object result = query.getSingleResult();
            if (result != null) {
                if (!result.getClass().isArray()) {
                    result = new Object[]{result};
                }
                return projection.newInstance((Object[]) result);
            } else {
                return null;
            }
        } else {
            return query.getSingleResult();
        }
    }
557976
public function one($query)
    {
        $authSession = $this->repositoryDispatcher->getCookieAuthSession();

        $url = null;
        $options = [
            RequestOptions::HEADERS => [
                'Cookie' => $authSession->getName() . '=' . $authSession->getValue(),
            ],
        ];

        // Prepares request options
        if (is_scalar($query)) {
            $url = $this->endpoint . '/rest/api/2/issue/' . $query;
        } elseif (is_array($query)
            && (array_key_exists('id', $query) || array_key_exists('key', $query))
        ) {
            // Prepares key by query
            if (isset($query['id'])) {
                $url = $this->endpoint . '/rest/api/2/issue/' . $query['id'];
                unset($query['id']);
            } elseif (isset($query['key'])) {
                $url = $this->endpoint . '/rest/api/2/issue/' . $query['key'];
                unset($query['key']);
            }

            // Prepares query params
            foreach ($query as $param => $value) {
                if ('fields' === $param) {
                    if (is_array($value)) {
                        $query[$param] = implode(',', $value);
                    }
                } elseif ('expand' === $param) {
                    if (is_array($value)) {
                        $query[$param] = implode(',', $value);
                    }
                } else {
                    unset($query[$param]);
                }
            }

            $options[RequestOptions::QUERY] = $query;
        } else {
            throw new \Exception('Bad params');
        }

        $response = $this->client->request('GET', $url, $options);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $issue = $this->createInstance(json_decode($contents, true));

        return $issue;
    }
992952
@Nonnull
  public ApiFuture<QuerySnapshot> get(@Nonnull Query query) {
    Preconditions.checkState(isEmpty(), READ_BEFORE_WRITE_ERROR_MSG);

    return query.get(transactionId);
  }
869564
@Deprecated
    public C expectAtMostOnce(Query query) {
        return expect(SqlQueries.atMostOneQuery().type(adapter(query)));
    }
465139
public Object getObjectByQuery(Query query) throws PersistenceBrokerException
    {
        Object result = null;
        if (query instanceof QueryByIdentity)
        {
            // example obj may be an entity or an Identity
            Object obj = query.getExampleObject();
            if (obj instanceof Identity)
            {
                Identity oid = (Identity) obj;
                result = getObjectByIdentity(oid);
            }
            else
            {
                // TODO: This workaround doesn't allow 'null' for PK fields
                if (!serviceBrokerHelper().hasNullPKField(getClassDescriptor(obj.getClass()), obj))
                {
                    Identity oid = serviceIdentity().buildIdentity(obj);
                    result = getObjectByIdentity(oid);
                }
            }
        }
        else
        {
            Class itemClass = query.getSearchClass();
            ClassDescriptor cld = getClassDescriptor(itemClass);
            /*
            use OJB intern Iterator, thus we are able to close used
            resources instantly
            */
            OJBIterator it = getIteratorFromQuery(query, cld);
            /*
            arminw:
            patch by Andre Clute, instead of taking the first found result
            try to get the first found none null result.
            He wrote:
            I have a situation where an item with a certain criteria is in my
            database twice -- once deleted, and then a non-deleted version of it.
            When I do a PB.getObjectByQuery(), the RsIterator get's both results
            from the database, but the first row is the deleted row, so my RowReader
            filters it out, and do not get the right result.
            */
            try
            {
                while (result==null && it.hasNext())
                {
                    result = it.next();
                }
            } // make sure that we close the used resources
            finally
            {
                if(it != null) it.releaseDbResources();
            }
        }
        return result;
    }
1109464
public Observable<ServiceResponse<List<Project>>> getProjectsWithServiceResponseAsync() {
        if (this.client.apiKey() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiKey() is required and cannot be null.");
        }
        return service.getProjects(this.client.apiKey(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<Project>>>>() {
                @Override
                public Observable<ServiceResponse<List<Project>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<List<Project>> clientResponse = getProjectsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
667898
public Pointer xpathPointer(Collection<?> collection, String query) {
    JXPathContext pathContext = JXPathContext.newContext(collection);
    Pointer result = null;

    try {
      result = pathContext.getPointer(query);
    } catch (JXPathNotFoundException e) {
      logger.warning(String.format("JXPath exception: %s", e.getMessage()));
    }

    return result;
  }
738113
@Override
    public <T> T query(MonetaryQuery<T> query) {
        Objects.requireNonNull(query);
        try {
            return query.queryFrom(this);
        } catch (MonetaryException | ArithmeticException e) {
            throw e;
        } catch (Exception e) {
            throw new MonetaryException("Query failed: " + query, e);
        }
    }
1021571
protected Observable<AsyncN1qlQueryResult> retryPrepareAndExecuteOnce(Throwable error, N1qlQuery query, CouchbaseEnvironment env, long timeout, TimeUnit timeUnit) {
        if (error instanceof QueryExecutionException &&
                shouldRetry(((QueryExecutionException) error).getN1qlError())) {
            queryCache.remove(query.statement().toString());
            return prepareAndExecute(query, env, timeout, timeUnit);
        }
        return Observable.error(error);
    }
889428
public Observable<ServiceResponse<List<Iteration>>> getIterationsWithServiceResponseAsync(UUID projectId) {
        if (projectId == null) {
            throw new IllegalArgumentException("Parameter projectId is required and cannot be null.");
        }
        if (this.client.apiKey() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiKey() is required and cannot be null.");
        }
        return service.getIterations(projectId, this.client.apiKey(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<List<Iteration>>>>() {
                @Override
                public Observable<ServiceResponse<List<Iteration>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<List<Iteration>> clientResponse = getIterationsDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
1191206
public static DependencyQueryBuilder create(DependencyQuery query)
   {
      DependencyQueryBuilder builder = new DependencyQueryBuilder();
      builder.setCoordinate(query.getCoordinate());
      builder.setFilter(query.getDependencyFilter());
      builder.setRepositories(query.getDependencyRepositories());
      builder.setScopeType(query.getScopeType());
      return builder;
   }
910472
public Observable<ServiceResponse<Project>> getProjectWithServiceResponseAsync(UUID projectId) {
        if (projectId == null) {
            throw new IllegalArgumentException("Parameter projectId is required and cannot be null.");
        }
        if (this.client.apiKey() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiKey() is required and cannot be null.");
        }
        return service.getProject(projectId, this.client.apiKey(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Project>>>() {
                @Override
                public Observable<ServiceResponse<Project>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Project> clientResponse = getProjectDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }