Search in sources :

Example 1 with BitmaskNativeType

use of org.apache.ignite.internal.schema.BitmaskNativeType in project ignite-3 by apache.

the class RowAssembler method appendBitmask.

/**
 * Appends BitSet value for the current column to the chunk.
 *
 * @param bitSet Column value.
 * @return {@code this} for chaining.
 * @throws SchemaMismatchException If a value doesn't match the current column type.
 */
public RowAssembler appendBitmask(BitSet bitSet) throws SchemaMismatchException {
    Column col = curCols.column(curCol);
    checkType(NativeTypeSpec.BITMASK);
    BitmaskNativeType maskType = (BitmaskNativeType) col.type();
    if (bitSet.length() > maskType.bits()) {
        throw new IllegalArgumentException("Failed to set bitmask for column '" + col.name() + "' " + "(mask size exceeds allocated size) [mask=" + bitSet + ", maxSize=" + maskType.bits() + "]");
    }
    byte[] arr = bitSet.toByteArray();
    buf.putBytes(curOff, arr);
    for (int i = 0; i < maskType.sizeInBytes() - arr.length; i++) {
        buf.put(curOff + arr.length + i, (byte) 0);
    }
    shiftColumn(maskType.sizeInBytes());
    return this;
}
Also used : BitmaskNativeType(org.apache.ignite.internal.schema.BitmaskNativeType) Column(org.apache.ignite.internal.schema.Column)

Aggregations

BitmaskNativeType (org.apache.ignite.internal.schema.BitmaskNativeType)1 Column (org.apache.ignite.internal.schema.Column)1