/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); ensureCanRead(name); Path path = directory.resolve(name); try (FileChannel c = FileChannel.open(path, StandardOpenOption.READ)) { final String resourceDescription = "MMapIndexInput(path=\"" + path.toString() + "\")"; final boolean useUnmap = getUseUnmap(); return ByteBufferIndexInput.newInstance(resourceDescription, map(resourceDescription, c, 0, c.size()), c.size(), chunkSizePower, new ByteBufferGuard(resourceDescription, useUnmap ? CLEANER : null)); } }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); ensureCanRead(name); Path path = directory.resolve(name); try (FileChannel c = FileChannel.open(path, StandardOpenOption.READ)) { final String resourceDescription = "MMapIndexInput(path=\"" + path.toString() + "\")"; final boolean useUnmap = getUseUnmap(); return ByteBufferIndexInput.newInstance(resourceDescription, map(resourceDescription, c, 0, c.size()), c.size(), chunkSizePower, new ByteBufferGuard(resourceDescription, useUnmap ? CLEANER : null)); } }