@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); ensureCanRead(name); Path path = getDirectory().resolve(name); FileChannel fc = FileChannel.open(path, StandardOpenOption.READ); return new NIOFSIndexInput("NIOFSIndexInput(path=\"" + path + "\")", fc, context); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); Path path = getDirectory().resolve(name); FileChannel fc = FileChannel.open(path, StandardOpenOption.READ); return new NIOFSIndexInput("NIOFSIndexInput(path=\"" + path + "\")", fc, context); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); Path path = getDirectory().resolve(name); FileChannel fc = FileChannel.open(path, StandardOpenOption.READ); return new NIOFSIndexInput("NIOFSIndexInput(path=\"" + path + "\")", fc, context); }
@Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); ensureCanRead(name); Path path = getDirectory().resolve(name); FileChannel fc = FileChannel.open(path, StandardOpenOption.READ); return new NIOFSIndexInput("NIOFSIndexInput(path=\"" + path + "\")", fc, context); }
/** Creates an IndexInput for the file with the given name. */ @Override public IndexInput openInput(String name, IOContext context) throws IOException { ensureOpen(); return new NIOFSIndexInput(new File(getDirectory(), name), context, getReadChunkSize()); }
@Override public IndexInputSlicer createSlicer(final String name, final IOContext context) throws IOException { ensureOpen(); final File path = new File(getDirectory(), name); final RandomAccessFile descriptor = new RandomAccessFile(path, "r"); return new Directory.IndexInputSlicer() { @Override public void close() throws IOException { descriptor.close(); } @Override public IndexInput openSlice(String sliceDescription, long offset, long length) { return new NIOFSIndexInput(sliceDescription, path, descriptor, descriptor.getChannel(), 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); } } }; }
public static String toString(Directory directory) { if (directory instanceof NIOFSDirectory) { NIOFSDirectory niofsDirectory = (NIOFSDirectory)directory; return "niofs(" + niofsDirectory.getDirectory() + ")"; } if (directory instanceof MMapDirectory) { MMapDirectory mMapDirectory = (MMapDirectory)directory; return "mmapfs(" + mMapDirectory.getDirectory() + ")"; } if (directory instanceof SimpleFSDirectory) { SimpleFSDirectory simpleFSDirectory = (SimpleFSDirectory)directory; return "simplefs(" + simpleFSDirectory.getDirectory() + ")"; } if (directory instanceof FileSwitchDirectory) { FileSwitchDirectory fileSwitchDirectory = (FileSwitchDirectory) directory; return "default(" + toString(fileSwitchDirectory.getPrimaryDir()) + "," + toString(fileSwitchDirectory.getSecondaryDir()) + ")"; } return directory.toString(); }
public static String toString(Directory directory) { if (directory instanceof NIOFSDirectory) { NIOFSDirectory niofsDirectory = (NIOFSDirectory)directory; return "niofs(" + niofsDirectory.getDirectory() + ")"; } if (directory instanceof MMapDirectory) { MMapDirectory mMapDirectory = (MMapDirectory)directory; return "mmapfs(" + mMapDirectory.getDirectory() + ")"; } if (directory instanceof SimpleFSDirectory) { SimpleFSDirectory simpleFSDirectory = (SimpleFSDirectory)directory; return "simplefs(" + simpleFSDirectory.getDirectory() + ")"; } if (directory instanceof FileSwitchDirectory) { FileSwitchDirectory fileSwitchDirectory = (FileSwitchDirectory) directory; return "default(" + toString(fileSwitchDirectory.getPrimaryDir()) + "," + toString(fileSwitchDirectory.getSecondaryDir()) + ")"; } return directory.toString(); }