Search in sources :

Example 1 with QueryResponse

use of org.infinispan.query.clustered.QueryResponse in project infinispan by infinispan.

the class CQCreateEagerQuery method perform.

@Override
CompletionStage<QueryResponse> perform(BitSet segments) {
    SearchQueryBuilder query = queryDefinition.getSearchQueryBuilder();
    setFilter(segments);
    CompletionStage<NodeTopDocs> nodeTopDocs = query.isEntityProjection() ? collectKeys(query) : collectProjections(query);
    return nodeTopDocs.thenApply(QueryResponse::new);
}
Also used : NodeTopDocs(org.infinispan.query.clustered.NodeTopDocs) QueryResponse(org.infinispan.query.clustered.QueryResponse) SearchQueryBuilder(org.infinispan.query.dsl.embedded.impl.SearchQueryBuilder)

Example 2 with QueryResponse

use of org.infinispan.query.clustered.QueryResponse in project infinispan by infinispan.

the class CQDelete method perform.

@Override
CompletionStage<QueryResponse> perform(BitSet segments) {
    setFilter(segments);
    // Must never apply any kind of limits to a DELETE! Limits are just for paging a SELECT.
    if (queryDefinition.getFirstResult() != 0 || queryDefinition.getMaxResults() != Integer.MAX_VALUE) {
        throw CONTAINER.deleteStatementsCannotUsePaging();
    }
    SearchQueryBuilder query = queryDefinition.getSearchQueryBuilder();
    return blockingManager.supplyBlocking(() -> fetchReferences(query), this).thenApply(queryResult -> queryResult.hits().stream().map(ref -> cache.remove(ref.key()) != null ? 1 : 0).reduce(0, Integer::sum)).thenApply(QueryResponse::new);
}
Also used : QueryResponse(org.infinispan.query.clustered.QueryResponse) CONTAINER(org.infinispan.query.logging.Log.CONTAINER) CompletionStage(java.util.concurrent.CompletionStage) SearchQueryBuilder(org.infinispan.query.dsl.embedded.impl.SearchQueryBuilder) LuceneSearchResult(org.hibernate.search.backend.lucene.search.query.LuceneSearchResult) EntityReference(org.infinispan.search.mapper.common.EntityReference) BitSet(java.util.BitSet) QueryResponse(org.infinispan.query.clustered.QueryResponse) SearchQueryBuilder(org.infinispan.query.dsl.embedded.impl.SearchQueryBuilder)

Example 3 with QueryResponse

use of org.infinispan.query.clustered.QueryResponse in project infinispan by infinispan.

the class CQGetResultSize method perform.

@Override
CompletionStage<QueryResponse> perform(BitSet segments) {
    SearchQueryBuilder query = queryDefinition.getSearchQueryBuilder();
    setFilter(segments);
    return blockingManager.supplyBlocking(() -> query.build().fetchTotalHitCount(), this).thenApply(hitCount -> new QueryResponse(Math.toIntExact(hitCount)));
}
Also used : QueryResponse(org.infinispan.query.clustered.QueryResponse) SearchQueryBuilder(org.infinispan.query.dsl.embedded.impl.SearchQueryBuilder)

Aggregations

QueryResponse (org.infinispan.query.clustered.QueryResponse)3 SearchQueryBuilder (org.infinispan.query.dsl.embedded.impl.SearchQueryBuilder)3 BitSet (java.util.BitSet)1 CompletionStage (java.util.concurrent.CompletionStage)1 LuceneSearchResult (org.hibernate.search.backend.lucene.search.query.LuceneSearchResult)1 NodeTopDocs (org.infinispan.query.clustered.NodeTopDocs)1 CONTAINER (org.infinispan.query.logging.Log.CONTAINER)1 EntityReference (org.infinispan.search.mapper.common.EntityReference)1