Search in sources :

Example 1 with NodeFullException

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();
        }
    }
}
Also used : RTreeException(rtree.RTreeException) Node(rtree.Node) NodeFullException(rtree.NodeFullException) RTreeException(rtree.RTreeException) NodeFullException(rtree.NodeFullException) IOException(java.io.IOException) NodeReadException(rtree.NodeReadException) FileNotFoundException(java.io.FileNotFoundException) IllegalValueException(rtree.IllegalValueException) NodeWriteException(rtree.NodeWriteException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 IllegalValueException (rtree.IllegalValueException)1 Node (rtree.Node)1 NodeFullException (rtree.NodeFullException)1 NodeReadException (rtree.NodeReadException)1 NodeWriteException (rtree.NodeWriteException)1 RTreeException (rtree.RTreeException)1