Class BaseDataBlock
- java.lang.Object
-
- org.apache.pinot.common.datablock.BaseDataBlock
-
- All Implemented Interfaces:
DataBlock
- Direct Known Subclasses:
ColumnarDataBlock,MetadataBlock,RowDataBlock
public abstract class BaseDataBlock extends Object implements DataBlock
Base data block mostly replicating implementation ofDataTableImplV3. +-----------------------------------------------+ | 13 integers of header: | | VERSION | | NUM_ROWS | | NUM_COLUMNS | | EXCEPTIONS SECTION START OFFSET | | EXCEPTIONS SECTION LENGTH | | DICTIONARY_MAP SECTION START OFFSET | | DICTIONARY_MAP SECTION LENGTH | | DATA_SCHEMA SECTION START OFFSET | | DATA_SCHEMA SECTION LENGTH | | FIXED_SIZE_DATA SECTION START OFFSET | | FIXED_SIZE_DATA SECTION LENGTH | | VARIABLE_SIZE_DATA SECTION START OFFSET | | VARIABLE_SIZE_DATA SECTION LENGTH | +-----------------------------------------------+ | EXCEPTIONS SECTION | +-----------------------------------------------+ | DICTIONARY_MAP SECTION | +-----------------------------------------------+ | DATA_SCHEMA SECTION | +-----------------------------------------------+ | FIXED_SIZE_DATA SECTION | +-----------------------------------------------+ | VARIABLE_SIZE_DATA SECTION | +-----------------------------------------------+ | METADATA LENGTH | | METADATA SECTION | +-----------------------------------------------+ To support both row and columnar data format. the size of the data payload will be exactly the same. the only difference is the data layout in FIXED_SIZE_DATA and VARIABLE_SIZE_DATA section, see each impl for details.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.pinot.common.datablock.DataBlock
DataBlock.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected DataSchema_dataSchemaprotected Map<Integer,String>_errCodeToExceptionMapprotected int_fixDataSizeprotected ByteBuffer_fixedSizeDataprotected byte[]_fixedSizeDataBytesprotected Map<String,String>_metadataprotected int_numColumnsprotected int_numRowsprotected String[]_stringDictionaryprotected ByteBuffer_variableSizeDataprotected byte[]_variableSizeDataBytesprotected static intHEADER_SIZE
-
Constructor Summary
Constructors Constructor Description BaseDataBlock()Construct empty data table.BaseDataBlock(int numRows, DataSchema dataSchema, String[] stringDictionary, byte[] fixedSizeDataBytes, byte[] variableSizeDataBytes)construct a base data block.BaseDataBlock(ByteBuffer byteBuffer)
-
Method Summary
Modifier and Type Method Description voidaddException(int errCode, String errMsg)voidaddException(ProcessingException processingException)protected String[]deserializeStringDictionary(ByteBuffer buffer)Helper method to deserialize dictionary map.BigDecimalgetBigDecimal(int rowId, int colId)ByteArraygetBytes(int rowId, int colId)protected abstract intgetDataBlockVersionType()Return the int serialized form of the data block version and type.DataSchemagetDataSchema()doublegetDouble(int rowId, int colId)double[]getDoubleArray(int rowId, int colId)Map<Integer,String>getExceptions()floatgetFloat(int rowId, int colId)float[]getFloatArray(int rowId, int colId)intgetInt(int rowId, int colId)int[]getIntArray(int rowId, int colId)longgetLong(int rowId, int colId)long[]getLongArray(int rowId, int colId)Map<String,String>getMetadata()org.roaringbitmap.RoaringBitmapgetNullRowIds(int colId)intgetNumberOfRows()protected abstract intgetOffsetInFixedBuffer(int rowId, int colId)return the offset in_fixedSizeDataBytesof the row/column ID.StringgetString(int rowId, int colId)String[]getStringArray(int rowId, int colId)intgetVersion()protected abstract intpositionOffsetInVariableBufferAndGetLength(int rowId, int colId)position the_variableSizeDataBytesto the corresponding row/column ID.protected byte[]serializeStringDictionary()Helper method to serialize dictionary map.byte[]toBytes()StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.pinot.common.datablock.DataBlock
toDataOnlyDataTable, toMetadataOnlyDataTable
-
-
-
-
Field Detail
-
HEADER_SIZE
protected static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
_numRows
protected int _numRows
-
_numColumns
protected int _numColumns
-
_fixDataSize
protected int _fixDataSize
-
_dataSchema
protected DataSchema _dataSchema
-
_stringDictionary
protected String[] _stringDictionary
-
_fixedSizeDataBytes
protected byte[] _fixedSizeDataBytes
-
_fixedSizeData
protected ByteBuffer _fixedSizeData
-
_variableSizeDataBytes
protected byte[] _variableSizeDataBytes
-
_variableSizeData
protected ByteBuffer _variableSizeData
-
-
Constructor Detail
-
BaseDataBlock
public BaseDataBlock(int numRows, @Nullable DataSchema dataSchema, String[] stringDictionary, byte[] fixedSizeDataBytes, byte[] variableSizeDataBytes)construct a base data block.- Parameters:
numRows- num of rows in the blockdataSchema- schema of the data in the blockstringDictionary- dictionary encoding mapfixedSizeDataBytes- byte[] for fix-sized columns.variableSizeDataBytes- byte[] for variable length columns (arrays).
-
BaseDataBlock
public BaseDataBlock()
Construct empty data table.
-
BaseDataBlock
public BaseDataBlock(ByteBuffer byteBuffer) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getVersion
public int getVersion()
- Specified by:
getVersionin interfaceDataBlock
-
getDataBlockVersionType
protected abstract int getDataBlockVersionType()
Return the int serialized form of the data block version and type.- Returns:
-
getOffsetInFixedBuffer
protected abstract int getOffsetInFixedBuffer(int rowId, int colId)return the offset in_fixedSizeDataBytesof the row/column ID.- Parameters:
rowId- row IDcolId- column ID- Returns:
- the offset in the fixed size buffer for the row/columnID.
-
positionOffsetInVariableBufferAndGetLength
protected abstract int positionOffsetInVariableBufferAndGetLength(int rowId, int colId)position the_variableSizeDataBytesto the corresponding row/column ID. and return the length of bytes to extract from the variable size buffer.- Parameters:
rowId- row IDcolId- column ID- Returns:
- the length to extract from variable size buffer.
-
getMetadata
public Map<String,String> getMetadata()
- Specified by:
getMetadatain interfaceDataBlock
-
getDataSchema
public DataSchema getDataSchema()
- Specified by:
getDataSchemain interfaceDataBlock
-
getNumberOfRows
public int getNumberOfRows()
- Specified by:
getNumberOfRowsin interfaceDataBlock
-
getDouble
public double getDouble(int rowId, int colId)
-
getBigDecimal
public BigDecimal getBigDecimal(int rowId, int colId)
- Specified by:
getBigDecimalin interfaceDataBlock
-
getString
public String getString(int rowId, int colId)
-
getBytes
public ByteArray getBytes(int rowId, int colId)
-
getIntArray
public int[] getIntArray(int rowId, int colId)- Specified by:
getIntArrayin interfaceDataBlock
-
getLongArray
public long[] getLongArray(int rowId, int colId)- Specified by:
getLongArrayin interfaceDataBlock
-
getFloatArray
public float[] getFloatArray(int rowId, int colId)- Specified by:
getFloatArrayin interfaceDataBlock
-
getDoubleArray
public double[] getDoubleArray(int rowId, int colId)- Specified by:
getDoubleArrayin interfaceDataBlock
-
getStringArray
public String[] getStringArray(int rowId, int colId)
- Specified by:
getStringArrayin interfaceDataBlock
-
getNullRowIds
@Nullable public org.roaringbitmap.RoaringBitmap getNullRowIds(int colId)
- Specified by:
getNullRowIdsin interfaceDataBlock
-
serializeStringDictionary
protected byte[] serializeStringDictionary() throws IOExceptionHelper method to serialize dictionary map.- Throws:
IOException
-
deserializeStringDictionary
protected String[] deserializeStringDictionary(ByteBuffer buffer) throws IOException
Helper method to deserialize dictionary map.- Throws:
IOException
-
addException
public void addException(ProcessingException processingException)
- Specified by:
addExceptionin interfaceDataBlock
-
addException
public void addException(int errCode, String errMsg)- Specified by:
addExceptionin interfaceDataBlock
-
getExceptions
public Map<Integer,String> getExceptions()
- Specified by:
getExceptionsin interfaceDataBlock
-
toBytes
public byte[] toBytes() throws IOException- Specified by:
toBytesin interfaceDataBlock- Throws:
IOException
-
-