/** 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); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); final File path = new File(directory, name); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path.getPath() + "\")", path, context, getReadChunkSize()); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); Path path = directory.resolve(name); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); Path path = directory.resolve(name); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
/** 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); SeekableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.READ); return new SimpleFSIndexInput("SimpleFSIndexInput(path=\"" + path + "\")", channel, context); }
@Override public IndexInputSlicer createSlicer(final String name, final IOContext context) throws IOException { ensureOpen(); final File file = new File(getDirectory(), name); final RandomAccessFile descriptor = new RandomAccessFile(file, "r"); return new IndexInputSlicer() { @Override public void close() throws IOException { descriptor.close(); } @Override public IndexInput openSlice(String sliceDescription, long offset, long length) { return new SimpleFSIndexInput("SimpleFSIndexInput(" + sliceDescription + " in path=\"" + file.getPath() + "\" slice=" + offset + ":" + (offset+length) + ")", descriptor, offset, length, BufferedIndexInput.bufferSize(context), getReadChunkSize()); } @Override public IndexInput openFullSlice() { try { return openSlice("full-slice", 0, descriptor.length()); } catch (IOException ex) { throw new RuntimeException(ex); } } }; }