Package org.apache.parquet.bytes
Class BytesInput
- java.lang.Object
-
- org.apache.parquet.bytes.BytesInput
-
- Direct Known Subclasses:
ConcatenatingByteArrayCollector
public abstract class BytesInput extends Object
A source of bytes capable of writing itself to an output. A BytesInput should be consumed right away. It is not a container. For example if it is referring to a stream, subsequent BytesInput reads from the stream will be incorrect if the previous has not been consumed.
-
-
Constructor Summary
Constructors Constructor Description BytesInput()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static BytesInput
concat(List<BytesInput> inputs)
logically concatenate the provided inputsstatic BytesInput
concat(BytesInput... inputs)
logically concatenate the provided inputsstatic BytesInput
copy(BytesInput bytesInput)
copies the input into a new byte arraystatic BytesInput
empty()
static BytesInput
from(byte[] in)
static BytesInput
from(byte[] in, int offset, int length)
static BytesInput
from(ByteArrayOutputStream baos)
static BytesInput
from(InputStream in, int bytes)
static BytesInput
from(ByteBuffer... buffers)
static BytesInput
from(ByteBuffer buffer, int offset, int length)
Deprecated.Will be removed in 2.0.0static BytesInput
from(List<ByteBuffer> buffers)
static BytesInput
from(CapacityByteArrayOutputStream arrayOut)
static BytesInput
fromInt(int intValue)
static BytesInput
fromUnsignedVarInt(int intValue)
static BytesInput
fromUnsignedVarLong(long longValue)
static BytesInput
fromZigZagVarInt(int intValue)
static BytesInput
fromZigZagVarLong(long longValue)
abstract long
size()
byte[]
toByteArray()
ByteBuffer
toByteBuffer()
ByteBufferInputStream
toInputStream()
abstract void
writeAllTo(OutputStream out)
writes the bytes into a stream
-
-
-
Method Detail
-
concat
public static BytesInput concat(BytesInput... inputs)
logically concatenate the provided inputs- Parameters:
inputs
- the inputs to concatenate- Returns:
- a concatenated input
-
concat
public static BytesInput concat(List<BytesInput> inputs)
logically concatenate the provided inputs- Parameters:
inputs
- the inputs to concatenate- Returns:
- a concatenated input
-
from
public static BytesInput from(InputStream in, int bytes)
- Parameters:
in
- an input streambytes
- number of bytes to read- Returns:
- a BytesInput that will read that number of bytes from the stream
-
from
@Deprecated public static BytesInput from(ByteBuffer buffer, int offset, int length)
Deprecated.Will be removed in 2.0.0- Parameters:
buffer
-length
- number of bytes to read- Returns:
- a BytesInput that will read the given bytes from the ByteBuffer
-
from
public static BytesInput from(ByteBuffer... buffers)
- Parameters:
buffers
- an array of byte buffers- Returns:
- a BytesInput that will read the given bytes from the ByteBuffers
-
from
public static BytesInput from(List<ByteBuffer> buffers)
- Parameters:
buffers
- a list of byte buffers- Returns:
- a BytesInput that will read the given bytes from the ByteBuffers
-
from
public static BytesInput from(byte[] in)
- Parameters:
in
- a byte array- Returns:
- a Bytes input that will write the given bytes
-
from
public static BytesInput from(byte[] in, int offset, int length)
-
fromInt
public static BytesInput fromInt(int intValue)
- Parameters:
intValue
- the int to write- Returns:
- a BytesInput that will write 4 bytes in little endian
-
fromUnsignedVarInt
public static BytesInput fromUnsignedVarInt(int intValue)
- Parameters:
intValue
- the int to write- Returns:
- a BytesInput that will write var int
-
fromZigZagVarInt
public static BytesInput fromZigZagVarInt(int intValue)
- Parameters:
intValue
- the int to write- Returns:
- a ByteInput that contains the int value as a variable-length zig-zag encoded int
-
fromUnsignedVarLong
public static BytesInput fromUnsignedVarLong(long longValue)
- Parameters:
longValue
- the long to write- Returns:
- a BytesInput that will write var long
-
fromZigZagVarLong
public static BytesInput fromZigZagVarLong(long longValue)
- Parameters:
longValue
- the long to write- Returns:
- a ByteInput that contains the long value as a variable-length zig-zag encoded long
-
from
public static BytesInput from(CapacityByteArrayOutputStream arrayOut)
- Parameters:
arrayOut
- a capacity byte array output stream to wrap into a BytesInput- Returns:
- a BytesInput that will write the content of the buffer
-
from
public static BytesInput from(ByteArrayOutputStream baos)
- Parameters:
baos
- - stream to wrap into a BytesInput- Returns:
- a BytesInput that will write the content of the buffer
-
empty
public static BytesInput empty()
- Returns:
- an empty bytes input
-
copy
public static BytesInput copy(BytesInput bytesInput) throws IOException
copies the input into a new byte array- Parameters:
bytesInput
- a BytesInput- Returns:
- a copy of the BytesInput
- Throws:
IOException
- if there is an exception when reading bytes from the BytesInput
-
writeAllTo
public abstract void writeAllTo(OutputStream out) throws IOException
writes the bytes into a stream- Parameters:
out
- an output stream- Throws:
IOException
- if there is an exception writing
-
toByteArray
public byte[] toByteArray() throws IOException
- Returns:
- a new byte array materializing the contents of this input
- Throws:
IOException
- if there is an exception reading
-
toByteBuffer
public ByteBuffer toByteBuffer() throws IOException
- Returns:
- a new ByteBuffer materializing the contents of this input
- Throws:
IOException
- if there is an exception reading
-
toInputStream
public ByteBufferInputStream toInputStream() throws IOException
- Returns:
- a new InputStream materializing the contents of this input
- Throws:
IOException
- if there is an exception reading
-
size
public abstract long size()
- Returns:
- the size in bytes that would be written
-
-