Example usage for org.apache.spark.unsafe Platform putInt

List of usage examples for org.apache.spark.unsafe Platform putInt

Introduction

In this page you can find the example usage for org.apache.spark.unsafe Platform putInt.

Prototype

public static void putInt(Object object, long offset, int value) 

Source Link

Usage

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

License:Apache License

/**
 *
 * Write to a Project Tungsten Format (UnsafeRow).  We encode Time as
 * 2 ints.// w ww . j av a  2s  .co  m
 *
 * @param unsafeRowWriter
 * @param ordinal
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        BufferHolder holder = unsafeRowWriter.holder();
        holder.grow(8);
        Platform.putInt(holder.buffer, holder.cursor, encodedTime);
        Platform.putInt(holder.buffer, holder.cursor + 4, encodedTimeFraction);
        unsafeRowWriter.setOffsetAndSize(ordinal, 8);
        holder.cursor = 8;
    }
}

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

License:Apache License

/**
 *
 * Write to Project Tungsten format (UnsafeRow).  Timestamp is
 * written as 3 ints.//w w w . j  a v  a2s  .com
 *
 *
 * @param unsafeRowWriter
 * @param ordinal
  */
@Override
public void write(UnsafeRowWriter unsafeRowWriter, int ordinal) {
    if (isNull())
        unsafeRowWriter.setNullAt(ordinal);
    else {
        BufferHolder holder = unsafeRowWriter.holder();
        holder.grow(12);
        Platform.putInt(holder.buffer, holder.cursor, encodedDate);
        Platform.putInt(holder.buffer, holder.cursor + 4, encodedTime);
        Platform.putInt(holder.buffer, holder.cursor + 8, nanos);
        unsafeRowWriter.setOffsetAndSize(ordinal, 12);
        holder.cursor = 12;
    }
}

From source file:edu.ucla.cs.wis.bigdatalog.spark.storage.map.BytesToBytesMap.java

License:Apache License

/**
 * Acquire a new page from the memory manager.
 * @return whether there is enough space to allocate the new page.
 *//*from   w w w  .jav a 2 s  . c  o m*/
private boolean acquireNewPage(long required) {
    try {
        currentPage = allocatePage(required);
    } catch (OutOfMemoryError e) {
        return false;
    }
    dataPages.add(currentPage);
    Platform.putInt(currentPage.getBaseObject(), currentPage.getBaseOffset(), 0);
    pageCursor = 4;
    return true;
}