コード例 #1
0
ファイル: UnsafeArrayData.java プロジェクト: nkeywal/spark
 @Override
 public UnsafeArrayData copy() {
   UnsafeArrayData arrayCopy = new UnsafeArrayData();
   final byte[] arrayDataCopy = new byte[sizeInBytes];
   PlatformDependent.copyMemory(
       baseObject, baseOffset, arrayDataCopy, PlatformDependent.BYTE_ARRAY_OFFSET, sizeInBytes);
   arrayCopy.pointTo(arrayDataCopy, PlatformDependent.BYTE_ARRAY_OFFSET, numElements, sizeInBytes);
   return arrayCopy;
 }
コード例 #2
0
ファイル: UnsafeArrayData.java プロジェクト: nkeywal/spark
 @Override
 public byte[] getBinary(int ordinal) {
   assertIndexIsValid(ordinal);
   final int offset = getElementOffset(ordinal);
   if (offset < 0) return null;
   final int size = getElementSize(offset, ordinal);
   final byte[] bytes = new byte[size];
   PlatformDependent.copyMemory(
       baseObject, baseOffset + offset, bytes, PlatformDependent.BYTE_ARRAY_OFFSET, size);
   return bytes;
 }
コード例 #3
0
  /** Write a record to the sorter. */
  public void insertRecord(
      Object recordBaseObject, long recordBaseOffset, int lengthInBytes, long prefix)
      throws IOException {
    // Need 4 bytes to store the record length.
    final int totalSpaceRequired = lengthInBytes + 4;
    if (!haveSpaceForRecord(totalSpaceRequired)) {
      allocateSpaceForRecord(totalSpaceRequired);
    }

    final long recordAddress =
        memoryManager.encodePageNumberAndOffset(currentPage, currentPagePosition);
    final Object dataPageBaseObject = currentPage.getBaseObject();
    PlatformDependent.UNSAFE.putInt(dataPageBaseObject, currentPagePosition, lengthInBytes);
    currentPagePosition += 4;
    PlatformDependent.copyMemory(
        recordBaseObject, recordBaseOffset, dataPageBaseObject, currentPagePosition, lengthInBytes);
    currentPagePosition += lengthInBytes;
    freeSpaceInCurrentPage -= totalSpaceRequired;
    sorter.insertRecord(recordAddress, prefix);
  }
コード例 #4
0
ファイル: UTF8String.java プロジェクト: rdeepa/spark
 /**
  * Writes the content of this string into a memory address, identified by an object and an offset.
  * The target memory address must already been allocated, and have enough space to hold all the
  * bytes in this string.
  */
 public void writeToMemory(Object target, long targetOffset) {
   PlatformDependent.copyMemory(base, offset, target, targetOffset, numBytes);
 }
コード例 #5
0
ファイル: UnsafeArrayData.java プロジェクト: nkeywal/spark
 public void writeToMemory(Object target, long targetOffset) {
   PlatformDependent.copyMemory(baseObject, baseOffset, target, targetOffset, sizeInBytes);
 }