Examples of OCacheEntry


Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

      if (lastPage < 0) {
        lastPage = 0;
        isNewPage = true;
      }

      OCacheEntry cacheEntry = diskCache.load(fileId, lastPage, false);
      cacheEntry.acquireExclusiveLock();
      try {
        startAtomicOperation();

        final ODurablePage.TrackMode trackMode = getTrackMode();

        OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, trackMode);
        if (bucket.isFull()) {
          cacheEntry.releaseExclusiveLock();
          diskCache.release(cacheEntry);

          isNewPage = true;
          cacheEntry = diskCache.allocateNewPage(fileId);

          cacheEntry.acquireExclusiveLock();
          bucket = new OClusterPositionMapBucket(cacheEntry, trackMode);
        }

        final long index = bucket.add(pageIndex, recordPosition);
        final OClusterPosition result = OClusterPositionFactory.INSTANCE.valueOf(index + cacheEntry.getPageIndex()
            * OClusterPositionMapBucket.MAX_ENTRIES);

        logPageChanges(bucket, fileId, cacheEntry.getPageIndex(), isNewPage);
        cacheEntry.markDirty();

        endAtomicOperation(false);
        return result;
      } catch (Throwable e) {
        endAtomicOperation(true);
        throw new OStorageException("Error during creation of mapping between logical adn physical record position.", e);
      } finally {
        cacheEntry.releaseExclusiveLock();
        diskCache.release(cacheEntry);
      }
    } finally {
      releaseExclusiveLock();
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

      int index = (int) (position % OClusterPositionMapBucket.MAX_ENTRIES);

      if (pageIndex >= diskCache.getFilledUpTo(fileId))
        return null;

      final OCacheEntry cacheEntry = diskCache.load(fileId, pageIndex, false);
      try {
        final OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, ODurablePage.TrackMode.NONE);
        return bucket.get(index);
      } finally {
        diskCache.release(cacheEntry);
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

      final long position = clusterPosition.longValue();

      long pageIndex = position / OClusterPositionMapBucket.MAX_ENTRIES;
      int index = (int) (position % OClusterPositionMapBucket.MAX_ENTRIES);

      final OCacheEntry cacheEntry = diskCache.load(fileId, pageIndex, false);
      cacheEntry.acquireExclusiveLock();
      try {
        startAtomicOperation();
        final ODurablePage.TrackMode trackMode = getTrackMode();
        final OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, trackMode);

        OClusterPositionMapBucket.PositionEntry positionEntry = bucket.remove(index);
        if (positionEntry == null)
          return null;

        cacheEntry.markDirty();

        logPageChanges(bucket, fileId, pageIndex, false);

        endAtomicOperation(false);
        return positionEntry;
      } catch (Throwable e) {
        endAtomicOperation(true);

        throw new OStorageException("Error during removal of mapping between logical and physical record position.", e);
      } finally {
        cacheEntry.releaseExclusiveLock();
        diskCache.release(cacheEntry);
      }
    } finally {
      releaseExclusiveLock();
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

      if (pageIndex >= filledUpTo)
        return new OClusterPosition[0];

      OClusterPosition[] result = null;
      do {
        OCacheEntry cacheEntry = diskCache.load(fileId, pageIndex, false);
        OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, ODurablePage.TrackMode.NONE);
        int resultSize = bucket.getSize() - index;

        if (resultSize <= 0) {
          diskCache.release(cacheEntry);
          pageIndex++;
          index = 0;
        } else {
          int entriesCount = 0;
          long startIndex = cacheEntry.getPageIndex() * OClusterPositionMapBucket.MAX_ENTRIES + index;

          result = new OClusterPosition[resultSize];
          for (int i = 0; i < resultSize; i++) {
            if (bucket.exists(i + index)) {
              result[entriesCount] = OClusterPositionFactory.INSTANCE.valueOf(startIndex + i);
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

        pageIndex = filledUpTo - 1;
        index = Integer.MIN_VALUE;
      }

      do {
        OCacheEntry cacheEntry = diskCache.load(fileId, pageIndex, false);
        OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, ODurablePage.TrackMode.NONE);
        if (index == Integer.MIN_VALUE)
          index = bucket.getSize() - 1;

        int resultSize = index + 1;
        int entriesCount = 0;

        long startPosition = cacheEntry.getPageIndex() * OClusterPositionMapBucket.MAX_ENTRIES;
        result = new OClusterPosition[resultSize];

        for (int i = 0; i < resultSize; i++) {
          if (bucket.exists(i)) {
            result[entriesCount] = OClusterPositionFactory.INSTANCE.valueOf(startPosition + i);
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

  public OClusterPosition getFirstPosition() throws IOException {
    acquireSharedLock();
    try {
      final long filledUpTo = diskCache.getFilledUpTo(fileId);
      for (long pageIndex = 0; pageIndex < filledUpTo; pageIndex++) {
        OCacheEntry cacheEntry = diskCache.load(fileId, pageIndex, false);
        try {
          OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, ODurablePage.TrackMode.NONE);
          int bucketSize = bucket.getSize();

          for (int index = 0; index < bucketSize; index++) {
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

  public OClusterPosition getLastPosition() throws IOException {
    acquireSharedLock();
    try {
      final long filledUpTo = diskCache.getFilledUpTo(fileId);
      for (long pageIndex = filledUpTo - 1; pageIndex >= 0; pageIndex--) {
        OCacheEntry cacheEntry = diskCache.load(fileId, pageIndex, false);
        try {
          OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, ODurablePage.TrackMode.NONE);
          final int bucketSize = bucket.getSize();

          for (int index = bucketSize - 1; index >= 0; index--) {
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

  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 {
      OClusterPage localPage = new OClusterPage(cacheEntry, true, ODurablePage.TrackMode.FULL);

      int freeSpace = localPage.getFreeSpace();
      Assert.assertEquals(localPage.getRecordsCount(), 0);
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

  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 {
      OClusterPage localPage = new OClusterPage(cacheEntry, true, ODurablePage.TrackMode.FULL);
      int freeSpace = localPage.getFreeSpace();

      Assert.assertEquals(localPage.getRecordsCount(), 0);
View Full Code Here

Examples of com.orientechnologies.orient.core.index.hashindex.local.cache.OCacheEntry

  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 {
      OClusterPage localPage = new OClusterPage(cacheEntry, true, ODurablePage.TrackMode.FULL);

      ORecordVersion recordVersion = OVersionFactory.instance().createVersion();
      recordVersion.increment();
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.