Search in sources :

Example 1 with TopEntriesCollectorManager

use of org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollectorManager in project geode by apache.

the class LuceneQueryImpl method findTopEntries.

private TopEntries<K> findTopEntries() throws LuceneQueryException {
    TopEntriesCollectorManager manager = new TopEntriesCollectorManager(null, limit);
    LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(query, indexName, manager, limit);
    // TODO provide a timeout to the user?
    TopEntries<K> entries = null;
    try {
        TopEntriesFunctionCollector collector = new TopEntriesFunctionCollector(context);
        ResultCollector<TopEntriesCollector, TopEntries<K>> rc = onRegion().setArguments(context).withCollector(collector).execute(LuceneQueryFunction.ID);
        entries = rc.getResult();
    } catch (FunctionException e) {
        if (e.getCause() instanceof LuceneQueryException) {
            throw new LuceneQueryException(e);
        } else if (e.getCause() instanceof TransactionException) {
            // When run from client with single hop disabled
            throw new LuceneQueryException(LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION);
        } else if (e.getCause() instanceof RuntimeException) {
            throw (RuntimeException) e.getCause();
        }
        throw e;
    } catch (TransactionException e) {
        // When function execution is run from server
        throw new LuceneQueryException(LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION);
    }
    return entries;
}
Also used : LuceneFunctionContext(org.apache.geode.cache.lucene.internal.distributed.LuceneFunctionContext) TopEntriesCollector(org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollector) LuceneQueryException(org.apache.geode.cache.lucene.LuceneQueryException) TopEntriesFunctionCollector(org.apache.geode.cache.lucene.internal.distributed.TopEntriesFunctionCollector) FunctionException(org.apache.geode.cache.execute.FunctionException) TransactionException(org.apache.geode.cache.TransactionException) TopEntriesCollectorManager(org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollectorManager) TopEntries(org.apache.geode.cache.lucene.internal.distributed.TopEntries)

Aggregations

TransactionException (org.apache.geode.cache.TransactionException)1 FunctionException (org.apache.geode.cache.execute.FunctionException)1 LuceneQueryException (org.apache.geode.cache.lucene.LuceneQueryException)1 LuceneFunctionContext (org.apache.geode.cache.lucene.internal.distributed.LuceneFunctionContext)1 TopEntries (org.apache.geode.cache.lucene.internal.distributed.TopEntries)1 TopEntriesCollector (org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollector)1 TopEntriesCollectorManager (org.apache.geode.cache.lucene.internal.distributed.TopEntriesCollectorManager)1 TopEntriesFunctionCollector (org.apache.geode.cache.lucene.internal.distributed.TopEntriesFunctionCollector)1