@InterfaceAudience.Private @InterfaceStability.Evolving public class ByteSlot extends OutputStream
ByteSlot slot = new ByteSlot();
// write data
slot.write(...);
slot.write(...);
// write header with the size of the written data
slot.markHead();
slot.write(Bytes.toBytes(slot.size()));
// flush to stream as [header, data]
slot.writeTo(stream);
Modifier and Type | Field and Description |
---|---|
private byte[] |
buf |
private static int |
GROW_ALIGN |
private int |
head |
private static int |
LARGE_GROW_SIZE |
private static int |
LARGE_GROW_SIZE_THRESHOLD |
private static int |
RESET_THRESHOLD |
private int |
size |
Constructor and Description |
---|
ByteSlot() |
Modifier and Type | Method and Description |
---|---|
private void |
ensureCapacity(int minCapacity) |
byte[] |
getBuffer() |
int |
getHead() |
void |
markHead() |
void |
reset() |
int |
size() |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeAt(int offset,
int b) |
void |
writeTo(OutputStream stream) |
close, flush, write
private static final int LARGE_GROW_SIZE_THRESHOLD
private static final int LARGE_GROW_SIZE
private static final int RESET_THRESHOLD
private static final int GROW_ALIGN
private byte[] buf
private int head
private int size
public ByteSlot()
public void reset()
public void markHead()
public int getHead()
public int size()
public byte[] getBuffer()
public void writeAt(int offset, int b)
public void write(int b)
write
in class OutputStream
public void write(byte[] b, int off, int len)
write
in class OutputStream
public void writeTo(OutputStream stream) throws IOException
IOException
private void ensureCapacity(int minCapacity)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.