@Override public ResultIterator<E> iterator(FetchOptions fetchOptions) throws SearchException { if (fetchOptions.getFetchMode() == FetchOptions.FetchMode.EAGER) { hSearchQuery.getTimeoutManager().start(); List<EntityInfo> entityInfos = hSearchQuery.queryEntityInfos(); return filterNulls(new EagerIterator<>(entityInfos, getResultLoader(), fetchOptions.getFetchSize())); } else if (fetchOptions.getFetchMode() == FetchOptions.FetchMode.LAZY) { DocumentExtractor extractor = hSearchQuery.queryDocumentExtractor(); //triggers actual Lucene search return filterNulls(new LazyIterator<>(extractor, getResultLoader(), fetchOptions.getFetchSize())); } else { throw new IllegalArgumentException("Unknown FetchMode " + fetchOptions.getFetchMode()); } }
@Override public ResultIterator<E> iterator(FetchOptions fetchOptions) throws SearchException { partitionHandlingSupport.checkCacheAvailable(); HSQuery hSearchQuery = queryDefinition.getHsQuery(); if (fetchOptions.getFetchMode() == FetchOptions.FetchMode.EAGER) { hSearchQuery.getTimeoutManager().start(); List<EntityInfo> entityInfos = hSearchQuery.queryEntityInfos(); return filterNulls(new EagerIterator<>(entityInfos, getResultLoader(hSearchQuery), fetchOptions.getFetchSize())); } else if (fetchOptions.getFetchMode() == FetchOptions.FetchMode.LAZY) { DocumentExtractor extractor = hSearchQuery.queryDocumentExtractor(); //triggers actual Lucene search return filterNulls(new LazyIterator<>(extractor, getResultLoader(hSearchQuery), fetchOptions.getFetchSize())); } else { throw new IllegalArgumentException("Unknown FetchMode " + fetchOptions.getFetchMode()); } }
@Override public ResultIterator<E> iterator(FetchOptions fetchOptions) throws SearchException { hSearchQuery.maxResults(getNodeMaxResults()); switch (fetchOptions.getFetchMode()) { case EAGER: { ClusteredQueryCommand command = ClusteredQueryCommand.createEagerIterator(hSearchQuery, cache); HashMap<UUID, ClusteredTopDocs> topDocsResponses = broadcastQuery(command); return new DistributedIterator<>(sort, fetchOptions.getFetchSize(), this.resultSize, maxResults, firstResult, topDocsResponses, cache); } case LAZY: { UUID lazyItId = UUID.randomUUID(); ClusteredQueryCommand command = ClusteredQueryCommand.createLazyIterator(hSearchQuery, cache, lazyItId); HashMap<UUID, ClusteredTopDocs> topDocsResponses = broadcastQuery(command); // Make a sort copy to avoid reversed results return new DistributedLazyIterator<>(sort, fetchOptions.getFetchSize(), this.resultSize, maxResults, firstResult, lazyItId, topDocsResponses, asyncExecutor, cache); } default: throw new IllegalArgumentException("Unknown FetchMode " + fetchOptions.getFetchMode()); } }
@Override public ResultIterator<E> iterator(FetchOptions fetchOptions) throws SearchException { partitionHandlingSupport.checkCacheAvailable(); queryDefinition.setMaxResults(getNodeMaxResults()); switch (fetchOptions.getFetchMode()) { case EAGER: { ClusteredQueryCommand command = ClusteredQueryCommand.createEagerIterator(queryDefinition, cache); Map<Address, NodeTopDocs> topDocsResponses = broadcastQuery(command); return new DistributedIterator<>(queryDefinition.getSort(), fetchOptions.getFetchSize(), resultSize, maxResults, firstResult, topDocsResponses, cache); } case LAZY: { UUID queryId = UUID.randomUUID(); ClusteredQueryCommand command = ClusteredQueryCommand.createLazyIterator(queryDefinition, cache, queryId); Map<Address, NodeTopDocs> topDocsResponses = broadcastQuery(command); // Make a sort copy to avoid reversed results return new DistributedLazyIterator<>(queryDefinition.getSort(), fetchOptions.getFetchSize(), resultSize, maxResults, firstResult, queryId, topDocsResponses, invoker, cache); } default: throw new IllegalArgumentException("Unknown FetchMode " + fetchOptions.getFetchMode()); } }