public class BitVectorHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
bitIndex(int absoluteBitIndex)
Get the relative index of bit within the byte in validity buffer.
|
static int |
byteIndex(int absoluteBitIndex)
Get the index of byte corresponding to bit index in validity buffer.
|
static boolean |
checkAllBitsEqualTo(ArrowBuf validityBuffer,
int valueCount,
boolean checkOneBits)
Tests if all bits in a validity buffer are equal 0 or 1, according to the specified parameter.
|
static int |
get(ArrowBuf buffer,
int index)
Check if a bit at a given index is set or not.
|
static byte |
getBitsFromCurrentByte(ArrowBuf data,
int index,
int offset)
Returns the byte at index from data right-shifted by offset.
|
static byte |
getBitsFromNextByte(ArrowBuf data,
int index,
int offset)
Returns the byte at
index from left-shifted by (8 - offset). |
static int |
getNullCount(ArrowBuf validityBuffer,
int valueCount)
Given a validity buffer, find the number of bits that are not set.
|
static int |
getValidityBufferSize(int valueCount)
Compute the size of validity buffer required to manage a given number
of elements in a vector.
|
static ArrowBuf |
loadValidityBuffer(ArrowFieldNode fieldNode,
ArrowBuf sourceValidityBuffer,
BufferAllocator allocator)
Returns a new buffer if the source validity buffer is either all null or all
not-null, otherwise returns a buffer pointing to the same memory as source.
|
static ArrowBuf |
setValidityBit(ArrowBuf validityBuffer,
BufferAllocator allocator,
int valueCount,
int index,
int value)
Set the bit at a given index to provided value (1 or 0).
|
static void |
setValidityBit(ArrowBuf validityBuffer,
int index,
int value)
Set the bit at a given index to provided value (1 or 0).
|
static void |
setValidityBitToOne(ArrowBuf validityBuffer,
int index)
Set the bit at provided index to 1.
|
public static int byteIndex(int absoluteBitIndex)
public static int bitIndex(int absoluteBitIndex)
public static void setValidityBitToOne(ArrowBuf validityBuffer, int index)
validityBuffer - validity buffer of the vectorindex - index to be setpublic static void setValidityBit(ArrowBuf validityBuffer, int index, int value)
validityBuffer - validity buffer of the vectorindex - index to be setvalue - value to setpublic static ArrowBuf setValidityBit(ArrowBuf validityBuffer, BufferAllocator allocator, int valueCount, int index, int value)
validityBuffer - validity buffer of the vectorallocator - allocator for the buffervalueCount - number of values to allocate/setindex - index to be setvalue - value to setpublic static int get(ArrowBuf buffer, int index)
buffer - buffer to checkindex - index of the bufferpublic static int getValidityBufferSize(int valueCount)
valueCount - number of elements in the vectorpublic static int getNullCount(ArrowBuf validityBuffer, int valueCount)
validityBuffer - validity buffer of the vectorvalueCount - number of values in the vectorpublic static boolean checkAllBitsEqualTo(ArrowBuf validityBuffer, int valueCount, boolean checkOneBits)
validityBuffer - the validity buffer.valueCount - the bit count.checkOneBits - if set to true, the method checks if all bits are equal to 1;
otherwise, it checks if all bits are equal to 0.public static byte getBitsFromCurrentByte(ArrowBuf data, int index, int offset)
public static byte getBitsFromNextByte(ArrowBuf data, int index, int offset)
index from left-shifted by (8 - offset).public static ArrowBuf loadValidityBuffer(ArrowFieldNode fieldNode, ArrowBuf sourceValidityBuffer, BufferAllocator allocator)
fieldNode - The fieldNode containing the null countsourceValidityBuffer - The source validity buffer that will have its
position copied if there is a mix of null and non-null valuesallocator - The allocator to use for creating a new buffer if necessary.Copyright © 2019 The Apache Software Foundation. All rights reserved.