Examples of ODirectMemoryPointer


Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

      OLogSequenceNumber lsn = null;

      while (pos < record.length) {
        if (currentPage == null) {
          ODirectMemoryPointer pointer = new ODirectMemoryPointer(OWALPage.PAGE_SIZE);
          currentPage = new OWALPage(pointer, true);
          pagesCache.add(currentPage);
          filledUpTo += OWALPage.RECORDS_OFFSET;
        }

        int freeSpace = currentPage.getFreeSpace();
        if (freeSpace < OWALPage.MIN_RECORD_SIZE) {
          filledUpTo += freeSpace + OWALPage.RECORDS_OFFSET;
          ODirectMemoryPointer pointer = new ODirectMemoryPointer(OWALPage.PAGE_SIZE);
          currentPage = new OWALPage(pointer, true);
          pagesCache.add(currentPage);
          pageIndex++;

          freeSpace = currentPage.getFreeSpace();
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

        }

        if (!checkPageIntegrity(pageContent))
          throw new OWALPageBrokenException("WAL page with index " + pageIndex + " is broken.");

        ODirectMemoryPointer pointer = new ODirectMemoryPointer(pageContent);
        try {
          OWALPage page = new OWALPage(pointer, false);

          byte[] content = page.getRecord(pageOffset);
          if (record == null)
            record = content;
          else {
            byte[] oldRecord = record;

            record = new byte[record.length + content.length];
            System.arraycopy(oldRecord, 0, record, 0, oldRecord.length);
            System.arraycopy(content, 0, record, oldRecord.length, record.length - oldRecord.length);
          }

          if (page.mergeWithNextPage(pageOffset)) {
            pageOffset = OWALPage.RECORDS_OFFSET;
            pageIndex++;
            if (pageIndex >= pageCount)
              throw new OWALPageBrokenException("WAL page with index " + pageIndex + " is broken.");
          } else {
            if (page.getFreeSpace() >= OWALPage.MIN_RECORD_SIZE && pageIndex < pageCount - 1)
              throw new OWALPageBrokenException("WAL page with index " + pageIndex + " is broken.");

            break;
          }
        } finally {
          pointer.free();
        }
      }

      lastReadRecord = new WeakReference<OPair<OLogSequenceNumber, byte[]>>(new OPair<OLogSequenceNumber, byte[]>(lsn, record));
      return record;
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

        rndFile.seek((pagesCount - 1) * OWALPage.PAGE_SIZE);
        byte[] content = new byte[OWALPage.PAGE_SIZE];
        rndFile.readFully(content);

        if (checkPageIntegrity(content)) {
          ODirectMemoryPointer pointer = new ODirectMemoryPointer(content);
          currentPage = new OWALPage(pointer, false);
          filledUpTo = (pagesCount - 1) * OWALPage.PAGE_SIZE + currentPage.getFilledUpTo();
          nextPositionToFlush = (pagesCount - 1) * OWALPage.PAGE_SIZE;
        } else {
          ODirectMemoryPointer pointer = new ODirectMemoryPointer(OWALPage.PAGE_SIZE);
          currentPage = new OWALPage(pointer, true);
          filledUpTo = pagesCount * OWALPage.PAGE_SIZE + currentPage.getFilledUpTo();
          nextPositionToFlush = pagesCount * OWALPage.PAGE_SIZE;
        }

View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

                pendingLSNToFlush = new OLogSequenceNumber(order, filePointer + flushedPages * OWALPage.PAGE_SIZE + pos);

              pos += page.getSerializedRecordSize(pos);
            }

            ODirectMemoryPointer dataPointer;
            if (flushedPages == maxSize - 1) {
              dataPointer = new ODirectMemoryPointer(OWALPage.PAGE_SIZE);
              page.getPagePointer().moveData(0, dataPointer, 0, OWALPage.PAGE_SIZE);
            } else {
              dataPointer = page.getPagePointer();
            }

            pagesToFlush[flushedPages] = dataPointer;
          }

          flushedPages++;
        }

        synchronized (rndFile) {
          rndFile.seek(filePointer);
          for (int i = 0; i < pagesToFlush.length; i++) {
            ODirectMemoryPointer dataPointer = pagesToFlush[i];
            byte[] pageContent = dataPointer.get(0, OWALPage.PAGE_SIZE);
            if (i == pagesToFlush.length - 1)
              dataPointer.free();

            flushPage(pageContent);
            filePointer += OWALPage.PAGE_SIZE;
          }

View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

    if (fileClassic == null)
      throw new IllegalArgumentException("File with id " + fileId + " not found in WOW Cache");

    if (fileClassic.getFilledUpTo() >= endPosition) {
      fileClassic.read(startPosition, content, content.length - 2 * PAGE_PADDING, PAGE_PADDING);
      final ODirectMemoryPointer pointer = new ODirectMemoryPointer(content);

      final OLogSequenceNumber storedLSN = ODurablePage.getLogSequenceNumberFromPage(pointer);
      dataPointer = new OCachePointer(pointer, storedLSN);
    } else {
      fileClassic.allocateSpace((int) (endPosition - fileClassic.getFilledUpTo()));

      final ODirectMemoryPointer pointer = new ODirectMemoryPointer(content);
      dataPointer = new OCachePointer(pointer, new OLogSequenceNumber(0, -1));
    }

    return dataPointer;
  }
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

@Test
public class ClusterPageTest {
  private static final int SYSTEM_OFFSET = 24;

  public void testAddOneRecord() throws Exception {
    ODirectMemoryPointer pagePointer = new ODirectMemoryPointer(new byte[OClusterPage.PAGE_SIZE + ODurablePage.PAGE_PADDING]);
    OCachePointer cachePointer = new OCachePointer(pagePointer, new OLogSequenceNumber(0, 0));
    cachePointer.incrementReferrer();

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

      cachePointer.decrementReferrer();
    }
  }

  public void testAddTreeRecords() throws Exception {
    ODirectMemoryPointer pagePointer = new ODirectMemoryPointer(new byte[OClusterPage.PAGE_SIZE + ODurablePage.PAGE_PADDING]);
    OCachePointer cachePointer = new OCachePointer(pagePointer, new OLogSequenceNumber(0, 0));
    cachePointer.incrementReferrer();

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

      cachePointer.decrementReferrer();
    }
  }

  public void testAddFullPage() throws Exception {
    ODirectMemoryPointer pagePointer = new ODirectMemoryPointer(new byte[OClusterPage.PAGE_SIZE + ODurablePage.PAGE_PADDING]);
    OCachePointer cachePointer = new OCachePointer(pagePointer, new OLogSequenceNumber(0, 0));
    cachePointer.incrementReferrer();

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

      cachePointer.decrementReferrer();
    }
  }

  public void testDeleteAddLowerVersion() throws Exception {
    ODirectMemoryPointer pagePointer = new ODirectMemoryPointer(new byte[OClusterPage.PAGE_SIZE + ODurablePage.PAGE_PADDING]);
    OCachePointer cachePointer = new OCachePointer(pagePointer, new OLogSequenceNumber(0, 0));
    cachePointer.incrementReferrer();

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
View Full Code Here

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer

      cachePointer.decrementReferrer();
    }
  }

  public void testDeleteAddLowerVersionKeepTombstoneVersion() throws Exception {
    ODirectMemoryPointer pagePointer = new ODirectMemoryPointer(new byte[OClusterPage.PAGE_SIZE + ODurablePage.PAGE_PADDING]);
    OCachePointer cachePointer = new OCachePointer(pagePointer, new OLogSequenceNumber(0, 0));
    cachePointer.incrementReferrer();

    OCacheEntry cacheEntry = new OCacheEntry(0, 0, cachePointer, false);
    try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.