public void testNativeDirectMemoryCompatibility() {
   decimalSerializer.serializeNative(OBJECT, stream, 0);
   ODirectMemoryPointer pointer = new ODirectMemoryPointer(stream);
   try {
     Assert.assertEquals(decimalSerializer.deserializeFromDirectMemory(pointer, 0), OBJECT);
   } finally {
     pointer.free();
   }
 }
예제 #2
0
  public void testNativeDirectMemoryCompatibility() {
    binarySerializer.serializeNativeObject(OBJECT, stream, 0);

    ODirectMemoryPointer pointer = ODirectMemoryPointerFactory.instance().createPointer(stream);

    try {
      Assert.assertEquals(binarySerializer.deserializeFromDirectMemoryObject(pointer, 0), OBJECT);
    } finally {
      pointer.free();
    }
  }
예제 #3
0
  private void flushPage(long fileId, long pageIndex, ODirectMemoryPointer dataPointer)
      throws IOException {
    if (writeAheadLog != null) {
      OLogSequenceNumber lsn = ODurablePage.getLogSequenceNumberFromPage(dataPointer);
      OLogSequenceNumber flushedLSN = writeAheadLog.getFlushedLSN();
      if (flushedLSN == null || flushedLSN.compareTo(lsn) < 0) writeAheadLog.flush();
    }

    final byte[] content = dataPointer.get(0, pageSize);
    OLongSerializer.INSTANCE.serializeNative(MAGIC_NUMBER, content, 0);

    final int crc32 = calculatePageCrc(content);
    OIntegerSerializer.INSTANCE.serializeNative(crc32, content, OLongSerializer.LONG_SIZE);

    final OFileClassic fileClassic = files.get(fileId);
    fileClassic.write(pageIndex * pageSize, content);

    if (syncOnPageFlush) fileClassic.synch();
  }
예제 #4
0
 @Override
 public ComparableBinary deserializeFromDirectMemory(ODirectMemoryPointer pointer, long offset) {
   return new ComparableBinary(pointer.get(offset, LENGTH));
 }
예제 #5
0
 @Override
 public void serializeInDirectMemory(
     ComparableBinary object, ODirectMemoryPointer pointer, long offset, Object... hints) {
   final byte[] buffer = object.toByteArray();
   pointer.set(offset, buffer, 0, buffer.length);
 }