ByteBuffersDataOutput

class ByteBuffersDataOutput @JvmOverloads constructor(minBitsPerBlock: Int = DEFAULT_MIN_BITS_PER_BLOCK, maxBitsPerBlock: Int = DEFAULT_MAX_BITS_PER_BLOCK, blockAllocate: (Int) -> ByteBuffer = ALLOCATE_BB_ON_HEAP, blockReuse: (ByteBuffer) -> Unit = NO_REUSE) : DataOutput, Accountable

A DataOutput storing data in a list of ByteBuffers.

Constructors

Link copied to clipboard
constructor(minBitsPerBlock: Int = DEFAULT_MIN_BITS_PER_BLOCK, maxBitsPerBlock: Int = DEFAULT_MAX_BITS_PER_BLOCK, blockAllocate: (Int) -> ByteBuffer = ALLOCATE_BB_ON_HEAP, blockReuse: (ByteBuffer) -> Unit = NO_REUSE)
constructor(expectedSize: Long)

Create a new output, suitable for writing a file of around expectedSize bytes.

Types

Link copied to clipboard
class ByteBufferRecycler(delegate: (Int) -> ByteBuffer)

An implementation of a ByteBuffer allocation and recycling policy. The blocks are recycled if exactly the same size is requested, otherwise they're released to be GCed.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).

Functions

Link copied to clipboard
open override fun copyBytes(input: DataInput, numBytes: Long)

Copy numBytes bytes from input to ourself.

Link copied to clipboard
fun copyTo(output: DataOutput)

Copy the current content of this object into another DataOutput.

Link copied to clipboard
open override fun ramBytesUsed(): Long

Return the memory usage of this object in bytes. Negative values are illegal.

Link copied to clipboard
fun reset()

This method resets this object to a clean (zero-size) state and publishes any currently allocated buffers for reuse to the reuse strategy provided in the constructor.

Link copied to clipboard
fun size(): Long
Link copied to clipboard

Return a contiguous array with the current content written to the output. The returned array is always a copy (can be mutated).

Link copied to clipboard

Return a list of read-only view of ByteBuffer blocks over the current content written to the output.

Link copied to clipboard

Return a ByteBuffersDataInput for the set of current buffers (.toBufferList).

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Returns a list of writeable blocks over the (source) content buffers.

Link copied to clipboard
open override fun writeByte(b: Byte)

Writes a single byte.

Link copied to clipboard
fun writeBytes(buffer: ByteBuffer)

open override fun writeBytes(b: ByteArray, length: Int)
open override fun writeBytes(src: ByteArray, offset: Int, length: Int)

Writes an array of bytes.

Link copied to clipboard
fun writeGroupVInts(values: IntArray, limit: Int)

Encode integers using group-varint. It uses VInt to encode tail values that are not enough for a group.

fun writeGroupVInts(values: LongArray, limit: Int)

Encode integers using group-varint. It uses VInt to encode tail values that are not enough for a group. we need a long[] because this is what postings are using, all longs are actually required to be integers.

Link copied to clipboard
open override fun writeInt(v: Int)

Writes an int as four bytes (LE byte order).

Link copied to clipboard
open override fun writeLong(v: Long)

Writes a long as eight bytes (LE byte order).

Link copied to clipboard
open override fun writeMapOfStrings(map: Map<String, String>)

Writes a String map.

Link copied to clipboard
open override fun writeSetOfStrings(set: MutableSet<String>)

Writes a String set.

Link copied to clipboard
open override fun writeShort(v: Short)

Writes a short as two bytes (LE byte order).

Link copied to clipboard
open override fun writeString(v: String)

Writes a string.

Link copied to clipboard
fun writeVInt(i: Int)

Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are supported, but should be avoided.

Link copied to clipboard

Writes an long in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.

Link copied to clipboard
fun writeZInt(i: Int)

Write a zig-zag-encoded .writeVInt integer. This is typically useful to write small signed ints and is equivalent to calling writeVInt(BitUtil.zigZagEncode(i)).

Link copied to clipboard

Write a zig-zag-encoded .writeVLong long. Writes between one and ten bytes. This is typically useful to write small signed ints.