Package org.apache.solr.common.util
Class FastOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.solr.common.util.FastOutputStream
-
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
public class FastOutputStream extends OutputStream implements DataOutput
Single threaded buffered OutputStream Internal Solr use only, subject to change.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buf
protected OutputStream
out
protected int
pos
protected long
written
-
Constructor Summary
Constructors Constructor Description FastOutputStream(OutputStream w)
FastOutputStream(OutputStream sink, byte[] tempBuffer, int start)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
flush(byte[] buf, int offset, int len)
All writes to the sink will go through this methodvoid
flushBuffer()
Only flushes the buffer of the FastOutputStream, not that of the underlying stream.void
reserve(int len)
reserve at least len bytes at the end of the buffer.void
setWritten(long written)
Resets the count returned by written()long
size()
static FastOutputStream
wrap(OutputStream sink)
void
write(byte b)
void
write(byte[] b)
void
write(byte[] arr, int off, int len)
void
write(int b)
void
writeBoolean(boolean v)
void
writeByte(int v)
void
writeBytes(String s)
void
writeChar(int v)
void
writeChars(String s)
void
writeDouble(double v)
void
writeFloat(float v)
void
writeInt(int v)
void
writeLong(long v)
void
writeShort(int v)
void
writeUTF(String s)
void
writeUtf8CharSeq(Utf8CharSequence utf8)
Copies aUtf8CharSequence
without making extra copieslong
written()
Returns the number of bytes actually written to the underlying OutputStream, not including anything currently buffered by this class itself.
-
-
-
Field Detail
-
out
protected final OutputStream out
-
buf
protected byte[] buf
-
written
protected long written
-
pos
protected int pos
-
-
Constructor Detail
-
FastOutputStream
public FastOutputStream(OutputStream w)
-
FastOutputStream
public FastOutputStream(OutputStream sink, byte[] tempBuffer, int start)
-
-
Method Detail
-
wrap
public static FastOutputStream wrap(OutputStream sink)
-
write
public void write(int b) throws IOException
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b) throws IOException
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte b) throws IOException
- Throws:
IOException
-
write
public void write(byte[] arr, int off, int len) throws IOException
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
reserve
public void reserve(int len) throws IOException
reserve at least len bytes at the end of the buffer. Invalid if len > buffer.length- Throws:
IOException
-
writeBoolean
public void writeBoolean(boolean v) throws IOException
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
public void writeByte(int v) throws IOException
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeShort
public void writeShort(int v) throws IOException
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeChar
public void writeChar(int v) throws IOException
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeInt
public void writeInt(int v) throws IOException
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
public void writeLong(long v) throws IOException
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
public void writeFloat(float v) throws IOException
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
public void writeDouble(double v) throws IOException
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
public void writeBytes(String s) throws IOException
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChars
public void writeChars(String s) throws IOException
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
public void writeUTF(String s) throws IOException
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flushBuffer
public void flushBuffer() throws IOException
Only flushes the buffer of the FastOutputStream, not that of the underlying stream.- Throws:
IOException
-
flush
public void flush(byte[] buf, int offset, int len) throws IOException
All writes to the sink will go through this method- Throws:
IOException
-
size
public long size()
-
written
public long written()
Returns the number of bytes actually written to the underlying OutputStream, not including anything currently buffered by this class itself.
-
setWritten
public void setWritten(long written)
Resets the count returned by written()
-
writeUtf8CharSeq
public void writeUtf8CharSeq(Utf8CharSequence utf8) throws IOException
Copies aUtf8CharSequence
without making extra copies- Throws:
IOException
-
-