List of usage examples for java.util.concurrent Future toString
public String toString()
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.lucene.InMemoryIAViewRepository.java
public List<Category> findRelevantCategoriesForDocument(InformationAssetView iaView, List<CategoryWithLuceneQuery> categoriesWithQuery) { List<Category> listOfRelevantCategories = new ArrayList<Category>(); SearcherManager searcherManager = null; IndexSearcher searcher = null;/*from w ww.j a v a 2s. c o m*/ RAMDirectory ramDirectory = null; try { ramDirectory = createRamDirectoryForDocument(iaView); searcherManager = new SearcherManager(ramDirectory, null); searcher = searcherManager.acquire(); List<Future<CategoryWithLuceneQuery>> listOfFutureFoundCategories = new ArrayList<Future<CategoryWithLuceneQuery>>(); for (CategoryWithLuceneQuery category : categoriesWithQuery) { Future<CategoryWithLuceneQuery> futureSearchResults = asyncTaskManager .runUnitInMemoryCategoryQuery(searcher, category); listOfFutureFoundCategories.add(futureSearchResults); } for (Future<CategoryWithLuceneQuery> futureFoundCategory : listOfFutureFoundCategories) { Category category; try { category = futureFoundCategory.get(); if (category != null) { listOfRelevantCategories.add(category); } } catch (InterruptedException | ExecutionException e) { logger.error( ".findRelevantCategories: an exception occured while retrieving the categorisation result: , exception: {}", futureFoundCategory.toString(), e); } } } catch (IOException e) { throw new TaxonomyException(TaxonomyErrorType.LUCENE_IO_EXCEPTION, e); } finally { LuceneHelperTools.releaseSearcherManagerQuietly(searcherManager, searcher); LuceneHelperTools.closeCloseableObjectQuietly(ramDirectory); } return listOfRelevantCategories; }
From source file:uk.gov.nationalarchives.discovery.taxonomy.common.service.impl.QueryBasedCategoriserServiceImpl.java
private List<CategorisationResult> runCategorisationWithFSDirectory(InformationAssetView iaView, List<Category> listOfRelevantCategories) { List<CategorisationResult> listOfCategoryResults = new ArrayList<CategorisationResult>(); List<Future<CategorisationResult>> listOfFutureCategoryResults = new ArrayList<Future<CategorisationResult>>(); // TODO PERF cache filter on current document // Filter filter = new CachingWrapperFilter(new QueryWrapperFilter(new // TermQuery(new Term( // InformationAssetViewFields.DOCREFERENCE.toString(), // iaView.getDOCREFERENCE())))); Query filter = new TermQuery( new Term(InformationAssetViewFields.DOCREFERENCE.toString(), iaView.getDOCREFERENCE())); for (Category category : listOfRelevantCategories) { listOfFutureCategoryResults.add(asyncTaskManager.runUnitFSCategoryQuery(filter, category)); }/*from ww w. j av a 2 s . c om*/ for (Future<CategorisationResult> futureCatResult : listOfFutureCategoryResults) { try { CategorisationResult categorisationResult = futureCatResult.get(); if (categorisationResult != null) { listOfCategoryResults.add(categorisationResult); } } catch (InterruptedException | ExecutionException e) { logger.error( ".runCategorisationWithFSDirectory: an exception occured while retreiving the categorisation result: , exception: {}", futureCatResult.toString(), e); } } return listOfCategoryResults; }