use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.
the class OHashTableDirectory method setMaxLeftChildDepth.
public void setMaxLeftChildDepth(int nodeIndex, byte maxLeftChildDepth) throws IOException {
startOperation();
try {
OAtomicOperation atomicOperation = startAtomicOperation(true);
acquireExclusiveLock();
try {
final ODirectoryPage page = loadPage(nodeIndex, true, atomicOperation);
try {
page.setMaxLeftChildDepth(getLocalNodeIndex(nodeIndex), maxLeftChildDepth);
} finally {
releasePage(page, true, atomicOperation);
}
endAtomicOperation(false, null);
} catch (IOException e) {
endAtomicOperation(true, e);
throw e;
} catch (Exception e) {
endAtomicOperation(true, e);
throw OException.wrapException(new OHashTableDirectoryException("Error during setting of max left child depth", this), e);
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.
the class OHashTableDirectory method getMaxLeftChildDepth.
public byte getMaxLeftChildDepth(int nodeIndex) throws IOException {
startOperation();
try {
atomicOperationsManager.acquireReadLock(this);
try {
acquireSharedLock();
try {
final OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation();
final ODirectoryPage page = loadPage(nodeIndex, false, atomicOperation);
try {
return page.getMaxLeftChildDepth(getLocalNodeIndex(nodeIndex));
} finally {
releasePage(page, false, atomicOperation);
}
} finally {
releaseSharedLock();
}
} finally {
atomicOperationsManager.releaseReadLock(this);
}
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.
the class OHashTableDirectory method addNewNode.
public int addNewNode(byte maxLeftChildDepth, byte maxRightChildDepth, byte nodeLocalDepth, long[] newNode) throws IOException {
startOperation();
try {
int nodeIndex;
OAtomicOperation atomicOperation = startAtomicOperation(true);
acquireExclusiveLock();
try {
OCacheEntry firstEntry = loadPage(atomicOperation, fileId, firstEntryIndex, true);
firstEntry.acquireExclusiveLock();
try {
ODirectoryFirstPage firstPage = new ODirectoryFirstPage(firstEntry, getChanges(atomicOperation, firstEntry), firstEntry);
final int tombstone = firstPage.getTombstone();
if (tombstone >= 0)
nodeIndex = tombstone;
else {
nodeIndex = firstPage.getTreeSize();
firstPage.setTreeSize(nodeIndex + 1);
}
if (nodeIndex < ODirectoryFirstPage.NODES_PER_PAGE) {
final int localNodeIndex = nodeIndex;
firstPage.setMaxLeftChildDepth(localNodeIndex, maxLeftChildDepth);
firstPage.setMaxRightChildDepth(localNodeIndex, maxRightChildDepth);
firstPage.setNodeLocalDepth(localNodeIndex, nodeLocalDepth);
if (tombstone >= 0)
firstPage.setTombstone((int) firstPage.getPointer(nodeIndex, 0));
for (int i = 0; i < newNode.length; i++) firstPage.setPointer(localNodeIndex, i, newNode[i]);
} else {
final int pageIndex = nodeIndex / ODirectoryPage.NODES_PER_PAGE;
final int localLevel = nodeIndex % ODirectoryPage.NODES_PER_PAGE;
OCacheEntry cacheEntry = loadPage(atomicOperation, fileId, pageIndex, true);
while (cacheEntry == null || cacheEntry.getPageIndex() < pageIndex) {
if (cacheEntry != null)
releasePage(atomicOperation, cacheEntry);
cacheEntry = addPage(atomicOperation, fileId);
}
cacheEntry.acquireExclusiveLock();
try {
ODirectoryPage page = new ODirectoryPage(cacheEntry, getChanges(atomicOperation, cacheEntry), cacheEntry);
page.setMaxLeftChildDepth(localLevel, maxLeftChildDepth);
page.setMaxRightChildDepth(localLevel, maxRightChildDepth);
page.setNodeLocalDepth(localLevel, nodeLocalDepth);
if (tombstone >= 0)
firstPage.setTombstone((int) page.getPointer(localLevel, 0));
for (int i = 0; i < newNode.length; i++) page.setPointer(localLevel, i, newNode[i]);
} finally {
cacheEntry.releaseExclusiveLock();
releasePage(atomicOperation, cacheEntry);
}
}
} finally {
firstEntry.releaseExclusiveLock();
releasePage(atomicOperation, firstEntry);
}
endAtomicOperation(false, null);
} catch (IOException e) {
endAtomicOperation(true, e);
throw e;
} catch (RuntimeException e) {
endAtomicOperation(true, e);
throw e;
} finally {
releaseExclusiveLock();
}
return nodeIndex;
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.
the class OHashTableDirectory method setNodePointer.
public void setNodePointer(int nodeIndex, int index, long pointer) throws IOException {
startOperation();
try {
OAtomicOperation atomicOperation = startAtomicOperation(true);
acquireExclusiveLock();
try {
final ODirectoryPage page = loadPage(nodeIndex, true, atomicOperation);
try {
page.setPointer(getLocalNodeIndex(nodeIndex), index, pointer);
} finally {
releasePage(page, true, atomicOperation);
}
endAtomicOperation(false, null);
} catch (IOException e) {
endAtomicOperation(true, e);
throw e;
} catch (Exception e) {
endAtomicOperation(true, e);
throw OException.wrapException(new OHashTableDirectoryException("Error during setting of node pointer", this), e);
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
use of com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation in project orientdb by orientechnologies.
the class OHashTableDirectory method open.
public void open() throws IOException {
startOperation();
try {
acquireExclusiveLock();
try {
OAtomicOperation atomicOperation = atomicOperationsManager.getCurrentOperation();
fileId = openFile(atomicOperation, getFullName());
final int filledUpTo = (int) getFilledUpTo(atomicOperation, fileId);
for (int i = 0; i < filledUpTo; i++) {
final OCacheEntry entry = loadPage(atomicOperation, fileId, i, true);
assert entry != null;
pinPage(atomicOperation, entry);
releasePage(atomicOperation, entry);
}
} finally {
releaseExclusiveLock();
}
} finally {
completeOperation();
}
}
Aggregations