Example usage for org.apache.spark.sql.catalyst.expressions.codegen UnsafeRowWriter setNullAt

List of usage examples for org.apache.spark.sql.catalyst.expressions.codegen UnsafeRowWriter setNullAt

Introduction

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

Prototype

public void setNullAt(int ordinal) 

Source Link

Usage

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

License:Open Source License

@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) throws StandardException {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else//w ww .  j  av a 2 s.c  om
        unsafeRowWriter.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./*  w  ww  .  jav a2s  .c  o  m*/
 *
 *
 * @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);
    }
}

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

License:Apache License

/**
 *
 * Write to a Project Tungsten UnsafeRow format.
 *
 * @see UnsafeRowWriter#write(int, byte[])
 *
 * @param unsafeRowWriter/*from   w  w w .  jav  a2s . c  o m*/
 * @param ordinal
 * @throws StandardException
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) throws StandardException {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        unsafeRowWriter.write(ordinal, dataValue);
    }
}

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

License:Apache License

/**
 *
 * Write to a Project Tungsten UnsafeRow Format.
 *
 * @see UnsafeRowWriter#write(int, boolean)
 *
 * @param unsafeRowWriter/*from  w  w w .  j a va 2s .  co  m*/
 * @param ordinal
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        isNull = false;
        unsafeRowWriter.write(ordinal, value);
    }
}

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

License:Apache License

/**
 *
 * Write into the Project Tungsten Format (UnsafeRow).
 *
 * @see UnsafeRowWriter#write(int, UTF8String)
 *
 * @param unsafeRowWriter//w  w  w . j  a  v  a2  s.  co m
 * @param ordinal
 */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        unsafeRowWriter.write(ordinal, UTF8String.fromString(value));
    }
}

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

License:Apache License

/**
 *
 * Writes to a project Tungsten format (UnsafeRow).  Writes the
 * data as an encoded int.//from   w w w .ja v  a 2 s  .com
 *
 * @see UnsafeRowWriter#write(int, int)
 *
 * @param unsafeRowWriter
 * @param ordinal
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else
        unsafeRowWriter.write(ordinal, encodedDate);
}

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

License:Apache License

/**
 *
 * Write to a Project Tungsten Format (UnsafeRow).
 *
 * @see UnsafeRowWriter#write(int, Decimal, int, int)
 *
 * @param unsafeRowWriter//from w  w w  .  jav a2 s.  co  m
 * @param ordinal
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        Decimal foobar = Decimal.apply(value, value.precision(), value.scale());
        unsafeRowWriter.write(ordinal, Decimal.apply(value, value.precision(), value.scale()),
                value.precision(), value.scale());
    }
}

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

License:Apache License

/**
 *
 * Write into Project Tungsten Format (UnsafeRow)
 *
 * @see UnsafeRowWriter#write(int, double)
 *
 * @param unsafeRowWriter/*from  w  ww .  j  a v a 2 s . c o m*/
 * @param ordinal
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else
        unsafeRowWriter.write(ordinal, value);
}

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

License:Apache License

@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else/*  w  ww .j  ava2  s . co m*/
        unsafeRowWriter.write(ordinal, value);
}

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

License:Apache License

/**
 *
 * Write into a Project Tungsten format (UnsafeRow).  This calls the
 * reference's write method./*from  ww  w .  j av  a2s .co m*/
 *
 *
 * @param unsafeRowWriter
 * @param ordinal
 * @throws StandardException
  */
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) throws StandardException {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        value.write(unsafeRowWriter, ordinal);
    }
}