final IndexOutput createOutput(BiFunction<String, ByteBuffersDataOutput, IndexInput> outputToInput) throws IOException { if (content != null) { throw new IOException("Can only write to a file once: " + fileName); } String clazzName = ByteBuffersDirectory.class.getSimpleName(); String outputName = String.format(Locale.ROOT, "%s output (file=%s)", clazzName, fileName); return new ByteBuffersIndexOutput( bbOutputSupplier.get(), outputName, fileName, new CRC32(), (output) -> { content = outputToInput.apply(fileName, output); cachedLength = output.size(); }); } }
@Override public void writeByte(byte b) throws IOException { ensureOpen(); delegate.writeByte(b); }
@Override public long getChecksum() throws IOException { ensureOpen(); throw new IOException("This index output has no checksum computing ability: " + toString());
@Override public void writeLong(long i) throws IOException { ensureOpen(); delegate.writeLong(i); }
@Override public long getChecksum() throws IOException { ensureOpen(); throw new IOException("This index output has no checksum computing ability: " + toString());
final IndexOutput createOutput(BiFunction<String, ByteBuffersDataOutput, IndexInput> outputToInput) throws IOException { if (content != null) { throw new IOException("Can only write to a file once: " + fileName); } String clazzName = ByteBuffersDirectory.class.getSimpleName(); String outputName = String.format(Locale.ROOT, "%s output (file=%s)", clazzName, fileName); return new ByteBuffersIndexOutput( bbOutputSupplier.get(), outputName, fileName, new CRC32(), (output) -> { content = outputToInput.apply(fileName, output); cachedLength = output.size(); }); } }
@Override public void writeString(String s) throws IOException { ensureOpen(); delegate.writeString(s); }
@Override public void writeSetOfStrings(Set<String> set) throws IOException { ensureOpen(); delegate.writeSetOfStrings(set); }
@Override public long getFilePointer() { ensureOpen(); return delegate.size(); }
@Override public void writeBytes(byte[] b, int length) throws IOException { ensureOpen(); delegate.writeBytes(b, length); }
@Override public void copyBytes(DataInput input, long numBytes) throws IOException { ensureOpen(); delegate.copyBytes(input, numBytes); }
@Override public void writeBytes(byte[] b, int offset, int length) throws IOException { ensureOpen(); delegate.writeBytes(b, offset, length); }
@Override public void writeInt(int i) throws IOException { ensureOpen(); delegate.writeInt(i); }
@Override public void writeShort(short i) throws IOException { ensureOpen(); delegate.writeShort(i); }
@Override public void writeMapOfStrings(Map<String, String> map) throws IOException { ensureOpen(); delegate.writeMapOfStrings(map); }
@Override public void writeInt(int i) throws IOException { ensureOpen(); delegate.writeInt(i); }
@Override public void writeMapOfStrings(Map<String, String> map) throws IOException { ensureOpen(); delegate.writeMapOfStrings(map); }
@Override public void writeSetOfStrings(Set<String> set) throws IOException { ensureOpen(); delegate.writeSetOfStrings(set); }
@Override public long getFilePointer() { ensureOpen(); return delegate.size(); }
@Override public void writeShort(short i) throws IOException { ensureOpen(); delegate.writeShort(i); }