예제 #1
0
 @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
 @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
 /**
  * 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
 public void writeToMemory(Object target, long targetOffset) {
   PlatformDependent.copyMemory(baseObject, baseOffset, target, targetOffset, sizeInBytes);
 }