@Override public void close() { for (LuceneSearcher searcher : luceneSearcherMap.values()) { try { searcher.reader.close(); searcher.directory.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
private RAMDirectory(FSDirectory dir, boolean closeDir, IOContext context) throws IOException { this(); for (String file : dir.listAll()) { if (!Files.isDirectory(dir.getDirectory().resolve(file))) { copyFrom(dir, file, file, context); } } if (closeDir) { dir.close(); } }
@Override public void close() throws IOException { directory.close(); }
@Override public void close() throws IOException { fsDir.close(); }
@Override public void close() throws IOException { directory.close(); }
private static void close(FSDirectory directory) { try { directory.close(); } catch (IOException e) { logger.warn("Can't close directory", e); } }
@Override public void close() { for (LuceneSearcher searcher : luceneSearcherMap.values()) { try { searcher.reader.close(); searcher.directory.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public void stop(BundleContext context) throws Exception { super.stop(context); if(directory!=null) directory.close(); INSTANCE = null; directory = null; logger.info("Stopping Lucene Index"); }
@Override public void tearDown() throws Exception { inputDir.close(); super.tearDown(); }
@Override public void stop() { try { directory.close(); } catch (Exception e) { log.unableToCloseLuceneDirectory( directory.getDirectory(), e ); } }
private RAMDirectory(FSDirectory dir, boolean closeDir, IOContext context) throws IOException { this(); for (String file : dir.listAll()) { if (!Files.isDirectory(dir.getDirectory().resolve(file))) { copyFrom(dir, file, file, context); } } if (closeDir) { dir.close(); } }
private RAMDirectory(FSDirectory dir, boolean closeDir, IOContext context) throws IOException { this(); for (String file : dir.listAll()) { if (!Files.isDirectory(dir.getDirectory().resolve(file))) { copyFrom(dir, file, file, context); } } if (closeDir) { dir.close(); } }
private RAMDirectory(FSDirectory dir, boolean closeDir, IOContext context) throws IOException { this(); for (String file : dir.listAll()) { if (!Files.isDirectory(dir.getDirectory().resolve(file))) { copyFrom(dir, file, file, context); } } if (closeDir) { dir.close(); } }
@Override public void stop() { try { directory.close(); } catch (Exception e) { log.unableToCloseLuceneDirectory( directory.getDirectory(), e ); } }
@Override public void stop() { @SuppressWarnings("unused") int readCurrentState = current; //Another unneeded value, to ensure visibility of state protected by memory barrier timer.cancel(); task.stop(); try { directory.close(); } catch (Exception e) { log.unableToCloseLuceneDirectory( directory.getDirectory(), e ); } }
@Override public void stop() { @SuppressWarnings("unused") int readCurrentState = current; //Another unneeded value, to ensure visibility of state protected by memory barrier timer.cancel(); task.stop(); try { directory.close(); } catch (Exception e) { log.unableToCloseLuceneDirectory( directory.getDirectory(), e ); } }
/** * Outputs a vector store in Lucene binary format. * * @param vectorFileName The name of the file to write to * @param objectVectors The vector store to be written to disk */ public static void writeVectorsInLuceneFormat(String vectorFileName, FlagConfig flagConfig, VectorStore objectVectors) throws IOException { VerbatimLogger.info("About to write " + objectVectors.getNumVectors() + " vectors of dimension " + flagConfig.dimension() + " to Lucene format file: " + vectorFileName + " ... "); File vectorFile = new File(vectorFileName); java.nio.file.Files.deleteIfExists(vectorFile.toPath()); String parentPath = vectorFile.getParent(); if (parentPath == null) parentPath = ""; FSDirectory fsDirectory = FSDirectory.open(FileSystems.getDefault().getPath(parentPath)); IndexOutput outputStream = fsDirectory.createOutput(vectorFile.getName(), IOContext.DEFAULT); writeToIndexOutput(objectVectors, flagConfig, outputStream); outputStream.close(); fsDirectory.close(); }
public void configure(CompassSettings settings) throws CompassException { String connection = settings.getSetting(CompassEnvironment.CONNECTION); indexPath = findIndexPath(connection); // Make sure we use the FSDirectory System.setProperty("org.apache.lucene.FSDirectory.class", getFSDirectoryClass()); FSDirectory directory; try { directory = FSDirectory.getDirectory(System.getProperty("java.io.tmpdir")); directory.close(); } catch (IOException e) { throw new SearchEngineException("Failed to open the lucene directory", e); } if (!directory.getClass().getName().equals(getFSDirectoryClass())) { throw new SearchEngineException("Setting type of FS directory is a JVM " + "level setting, you can not set different values within the same JVM"); } }
/** * Removes the given backup folder of this index.<p> * * @param path the backup folder to remove */ protected void removeIndexBackup(String path) { if (!isBackupReindexing()) { // if no backup is generated we don't need to do anything return; } // check if the target directory already exists File file = new File(path); if (!file.exists()) { // index does not exist yet return; } try { FSDirectory dir = FSDirectory.open(file.toPath()); dir.close(); CmsFileUtil.purgeDirectory(file); } catch (Exception e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_IO_INDEX_BACKUP_REMOVE_2, getName(), path), e); } }
@Override protected EmbeddedCacheManager createCacheManager() throws Exception { rootDir = new File(new File(parentDir).getAbsoluteFile(), rootDirectoryName); boolean rootDirCreated = rootDir.mkdirs(); assert rootDirCreated : "couldn't created root directory!"; File subDir = new File(rootDir, indexName); boolean directoriesCreated = subDir.mkdir(); assert directoriesCreated : "couldn't create directory for test"; //We need at least one Directory to exist on filesystem to trigger the problem FSDirectory luceneDirectory = FSDirectory.open(subDir.toPath()); luceneDirectory.close(); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .addStore(LuceneLoaderConfigurationBuilder.class) .preload(true) .autoChunkSize(110) .location(rootDir.getAbsolutePath()); return TestCacheManagerFactory.createCacheManager(builder); }