/** Opens a {@link ReaderManager} from the internal {@link IndexWriter}. */ private void initReaderManager() throws IOException { if (!initializedReaderManager) { synchronized (this) { // verify that the taxo-writer hasn't been closed on us. ensureOpen(); if (!initializedReaderManager) { readerManager = new ReaderManager(indexWriter, false); shouldRefreshReaderManager = false; initializedReaderManager = true; } } } }
@Override public ReaderManager createReaderManager() { checkConfiguration(); try { return new ReaderManager(directory); } catch (IOException ex) { throw new RuntimeException(ex.getMessage(), ex); } }
@Test public void testReaderManager() throws IOException { ReaderManager readerManager = new ReaderManager(AosIndexUtil.directory()); IndexReader indexReader = null; try { indexReader = readerManager.acquire(); IndexSearcher indexSearcher = new IndexSearcher(indexReader); } finally { if (indexReader == null) { readerManager.release(DirectoryReader.open(AosIndexUtil.directory())); } } }
@ConditionalOnProperty(prefix = "lucene.categoriser.", value = "useTSetBasedCategoriser") public @Bean ReaderManager trainingSetReaderManager() throws IOException { return new ReaderManager(trainingSetDirectory()); }