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(); }
@Override public ComparableBinary deserializeFromDirectMemory(ODirectMemoryPointer pointer, long offset) { return new ComparableBinary(pointer.get(offset, LENGTH)); }