use of org.apache.hyracks.storage.am.rtree.frames.RTreeNSMInteriorFrame in project asterixdb by apache.
the class RTree method printTree.
@SuppressWarnings("rawtypes")
public void printTree(int pageId, ICachedPage parent, boolean unpin, IRTreeLeafFrame leafFrame, IRTreeInteriorFrame interiorFrame, byte treeHeight, ISerializerDeserializer[] keySerdes, StringBuilder strBuilder, MultiComparator cmp) throws Exception {
ICachedPage node = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, pageId), false);
node.acquireReadLatch();
try {
if (parent != null && unpin == true) {
parent.releaseReadLatch();
bufferCache.unpin(parent);
}
interiorFrame.setPage(node);
int level = interiorFrame.getLevel();
strBuilder.append(String.format("%1d ", level));
strBuilder.append(String.format("%3d ", pageId) + ": ");
for (int i = 0; i < treeHeight - level; i++) {
strBuilder.append(" ");
}
String keyString;
long LSN, NSN;
int rightPage;
if (interiorFrame.isLeaf()) {
leafFrame.setPage(node);
keyString = TreeIndexUtils.printFrameTuples(leafFrame, keySerdes);
LSN = leafFrame.getPageLsn();
NSN = leafFrame.getPageNsn();
rightPage = leafFrame.getRightPage();
} else {
keyString = TreeIndexUtils.printFrameTuples(interiorFrame, keySerdes);
LSN = interiorFrame.getPageLsn();
NSN = interiorFrame.getPageNsn();
rightPage = interiorFrame.getRightPage();
}
strBuilder.append(keyString + "\n" + "pageId: " + pageId + " LSN: " + LSN + " NSN: " + NSN + " rightPage: " + rightPage + "\n");
if (!interiorFrame.isLeaf()) {
ArrayList<Integer> children = ((RTreeNSMInteriorFrame) (interiorFrame)).getChildren(cmp);
for (int i = 0; i < children.size(); i++) {
printTree(children.get(i), node, i == children.size() - 1, leafFrame, interiorFrame, treeHeight, keySerdes, strBuilder, cmp);
}
} else {
node.releaseReadLatch();
bufferCache.unpin(node);
}
} catch (Exception e) {
node.releaseReadLatch();
bufferCache.unpin(node);
e.printStackTrace();
}
}
Aggregations