use of rtree.NodeFullException in project OsmAnd-tools by osmandapp.
the class SdTree method growLeaf.
public void growLeaf(Element elmt) throws RTreeException {
if (slotLvl == Node.NOT_DEFINED) {
try {
insert(elmt);
} catch (Exception e) {
throw new RTreeException(e.getMessage());
}
} else {
fileHdr.lockWrite();
try {
long root = fileHdr.getRootIndex();
// Long slotIndex = null;
LongWraper slotIndex = new LongWraper();
// sd
Node node = this.chooseLeaf(elmt, slotIndex);
if (slotIndex == null)
throw new NullPointerException();
long nodeParent = node.getParent();
Node[] newNodes = new Node[2];
try {
// if another insert is possible
node.insertElement(elmt);
newNodes[0] = node;
newNodes[1] = null;
} catch (NodeFullException e) {
// if another insert is not possible
newNodes = node.splitNode(elmt, slotIndex.val);
}
Node newRoot = adjustTree(newNodes, slotIndex.val);
// if we got a new root node then we have to set the slot's child to point to this new root
if (newRoot != null) {
// sd
Node slot = chdNodes.getNode(fileHdr.getFile(), fileName, newRoot.getParent(), fileHdr);
slot.modifyElement(0, newRoot.getNodeIndex());
}
} catch (Exception e) {
e.printStackTrace();
throw new RTreeException(e.getMessage());
} finally {
fileHdr.unlock();
}
}
}
Aggregations