Example usage for org.apache.spark.sql.catalyst.expressions.codegen UnsafeArrayWriter setNull

List of usage examples for org.apache.spark.sql.catalyst.expressions.codegen UnsafeArrayWriter setNull

Introduction

In this page you can find the example usage for org.apache.spark.sql.catalyst.expressions.codegen UnsafeArrayWriter setNull.

Prototype

public void setNull(int ordinal) 

Source Link

Usage

From source file:com.splicemachine.db.iapi.types.HBaseRowLocation.java

License:Open Source License

@Override
public void writeArray(UnsafeArrayWriter unsafeArrayWriter, int ordinal) throws StandardException {
    if (isNull())
        unsafeArrayWriter.setNull(ordinal);
    else//from   w  w w.ja  v a 2 s.c o  m
        unsafeArrayWriter.write(ordinal, slice.getByteCopy());
}

From source file:com.splicemachine.db.iapi.types.SQLArray.java

License:Apache License

/**
 *
 * Write into a Project Tungsten format (UnsafeRow).  This calls the
 * reference's write method./*ww w .j  av  a2  s.c om*/
 *
 *
 * @param unsafeRowWriter
 * @param ordinal
 * @throws StandardException
  */
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) throws StandardException {
    if (isNull()) {
        unsafeRowWriter.setNullAt(ordinal);
    } else {
        UnsafeArrayWriter unsafeArrayWriter = new UnsafeArrayWriter();
        BufferHolder bh = new BufferHolder(new UnsafeRow(value.length));
        unsafeArrayWriter.initialize(bh, value.length, 8); // 4 bytes for int?
        for (int i = 0; i < value.length; i++) {
            if (value[i] == null || value[i].isNull()) {
                unsafeArrayWriter.setNull(i);
            } else {
                value[i].writeArray(unsafeArrayWriter, i);
            }
        }
        long currentOffset = unsafeRowWriter.holder().cursor;
        unsafeRowWriter.setOffsetAndSize(ordinal, bh.cursor - 16);
        unsafeRowWriter.holder().grow(bh.cursor - 16);
        Platform.copyMemory(bh.buffer, 16, unsafeRowWriter.holder().buffer, currentOffset, bh.cursor - 16);
    }
}