/** Just like {@link #open(Path)}, but allows you to * also specify a custom {@link LockFactory}. */ public static FSDirectory open(Path path, LockFactory lockFactory) throws IOException { if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return new MMapDirectory(path, lockFactory); } else if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); } }
public LsiIndex(IndexEngineParser parser, String directoryPath, Scorer scorer, FacetingManager facetingManager) throws IOException { this.parser = parser; this.scorer = scorer; this.facetingManager = facetingManager; Preconditions.checkNotNull(directoryPath); dirLocation = new File(directoryPath); if (!dirLocation.exists() || !dirLocation.isDirectory()) { throw new IllegalArgumentException("Wrong directory path."); } directory = new MMapDirectory(dirLocation); reopenWriter(); searchObjects = new AtomicReference<Pair<BlockingDeque<IndexSearcher>, BlockingDeque<QueryMatcher>>>(); reopenSearcher(); }
private static Directory setPreload(Directory directory, Path location, LockFactory lockFactory, Set<String> preLoadExtensions) throws IOException { if (preLoadExtensions.isEmpty() == false && directory instanceof MMapDirectory && ((MMapDirectory) directory).getPreload() == false) { if (preLoadExtensions.contains("*")) { ((MMapDirectory) directory).setPreload(true); return directory; } MMapDirectory primary = new MMapDirectory(location, lockFactory); primary.setPreload(true); return new FileSwitchDirectory(preLoadExtensions, primary, directory, true) { @Override public String[] listAll() throws IOException { // avoid listing twice return primary.listAll(); } }; } return directory; } }
protected Directory newFSDirectory(Path location, LockFactory lockFactory) throws IOException { final String storeType = indexSettings.getSettings().get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), IndexModule.Type.FS.getSettingsKey()); if (IndexModule.Type.FS.match(storeType)) { final IndexModule.Type type = IndexModule.defaultStoreType(IndexModule.NODE_STORE_ALLOW_MMAPFS.get(indexSettings.getNodeSettings())); switch (type) { case MMAPFS: return new MMapDirectory(location, lockFactory); case SIMPLEFS: return new SimpleFSDirectory(location, lockFactory); case NIOFS: return new NIOFSDirectory(location, lockFactory); default: throw new AssertionError("unexpected built-in store type [" + type + "]"); } } else if (IndexModule.Type.SIMPLEFS.match(storeType)) { return new SimpleFSDirectory(location, lockFactory); } else if (IndexModule.Type.NIOFS.match(storeType)) { return new NIOFSDirectory(location, lockFactory); } else if (IndexModule.Type.MMAPFS.match(storeType)) { return new MMapDirectory(location, lockFactory); } throw new IllegalArgumentException("No directory found for type [" + storeType + "]"); }
public static IndexWriter storeOnlyWriter(String pathToIndexDir) throws IOException { return new IndexWriter(new MMapDirectory(Paths.get(pathToIndexDir)), storeConfig); }
public static IndexWriter storeOnlyWriter(String pathToIndexDir) throws IOException { return new IndexWriter(new MMapDirectory(Paths.get(pathToIndexDir)), storeConfig); }
/** * returns a index writer with the specified writer config. * * @param pathToIndexDir * @param config * @return * @throws IOException */ public static IndexWriter writer(String pathToIndexDir, IndexWriterConfig config) throws IOException{ return new IndexWriter(new MMapDirectory(Paths.get(pathToIndexDir)), config); }
/** * returns a index writer with the specified writer config. * * @param pathToIndexDir * @param config * @return * @throws IOException */ public static IndexWriter writer(String pathToIndexDir, IndexWriterConfig config) throws IOException{ return new IndexWriter(new MMapDirectory(Paths.get(pathToIndexDir)), config); }
public static IndexWriter storeOnlyWriter(String pathToIndexDir) throws IOException { return new IndexWriter(new MMapDirectory(new File(pathToIndexDir)), storeConfig); }
public static IndexSearcher loadLuceneIndex(File file) throws IOException { final Directory directory = new MMapDirectory(file); final IndexReader reader = DirectoryReader.open(directory); final IndexSearcher luceneIndex = new IndexSearcher(reader); return luceneIndex; } }
public static IndexSearcher loadLuceneIndex(File file) throws IOException { final Directory directory = new MMapDirectory(file); final IndexReader reader = DirectoryReader.open(directory); final IndexSearcher luceneIndex = new IndexSearcher(reader); return luceneIndex; } }
/** * returns a index writer with the specified writer config. * * @param pathToIndexDir * @param config * @return * @throws IOException */ public static IndexWriter writer(String pathToIndexDir, IndexWriterConfig config) throws IOException { return new IndexWriter(new MMapDirectory(new File(pathToIndexDir)), config); }
public void setIndex(String index) throws IOException { directory = new MMapDirectory(new File(index)); ireader = DirectoryReader.open(directory); isearcher = new IndexSearcher(ireader); }
public static IndexReader ramReader(String pathToIndex) throws IOException { return DirectoryReader.open(new RAMDirectory(new MMapDirectory( new File(pathToIndex)), IOContext.READ)); }
@Override public Directory createDirectory(String indexName) throws IOException { Path directoryPath = rootDirectory.resolve( indexName ); initializeIndexDirectory( directoryPath ); return new MMapDirectory( directoryPath ); }
public TripleIndex() throws IOException { Properties prop = new Properties(); InputStream input = TripleIndex.class.getResourceAsStream("/config/agdistis.properties"); prop.load(input); String envIndex = System.getenv("AGDISTIS_INDEX"); String index = envIndex != null ? envIndex : prop.getProperty("index"); log.info("The index will be here: " + index); directory = new MMapDirectory(new File(index)); ireader = DirectoryReader.open(directory); isearcher = new IndexSearcher(ireader); this.urlValidator = new UrlValidator(); cache = CacheBuilder.newBuilder().maximumSize(50000).build(); }
/** Just like {@link #open(File)}, but allows you to * also specify a custom {@link LockFactory}. */ public static FSDirectory open(File path, LockFactory lockFactory) throws IOException { if ((Constants.WINDOWS || Constants.SUN_OS || Constants.LINUX) && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return new MMapDirectory(path, lockFactory); } else if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); } }
/** Just like {@link #open(Path)}, but allows you to * also specify a custom {@link LockFactory}. */ public static FSDirectory open(Path path, LockFactory lockFactory) throws IOException { if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return new MMapDirectory(path, lockFactory); } else if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); } }
/** Just like {@link #open(Path)}, but allows you to * also specify a custom {@link LockFactory}. */ public static FSDirectory open(Path path, LockFactory lockFactory) throws IOException { if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return new MMapDirectory(path, lockFactory); } else if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); } }
/** Just like {@link #open(Path)}, but allows you to * also specify a custom {@link LockFactory}. */ public static FSDirectory open(Path path, LockFactory lockFactory) throws IOException { if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) { return new MMapDirectory(path, lockFactory); } else if (Constants.WINDOWS) { return new SimpleFSDirectory(path, lockFactory); } else { return new NIOFSDirectory(path, lockFactory); } }