Search in sources :

Example 16 with NodeDelegate

use of org.sirix.node.delegates.NodeDelegate in project sirix by sirixdb.

the class PageWriteTrxImpl method removeEntry.

@Override
public void removeEntry(final Long recordKey, @Nonnull final PageKind pageKind, final int index, final Optional<UnorderedKeyValuePage> keyValuePage) throws SirixIOException {
    mPageRtx.assertNotClosed();
    final long nodePageKey = mPageRtx.pageKey(recordKey);
    final PageContainer cont = prepareRecordPage(nodePageKey, index, pageKind);
    final Optional<Record> node = getRecord(recordKey, pageKind, index);
    if (node.isPresent()) {
        final Record nodeToDel = node.get();
        final Node delNode = new DeletedNode(new NodeDelegate(nodeToDel.getNodeKey(), -1, -1, -1, Optional.<SirixDeweyID>empty()));
        ((UnorderedKeyValuePage) cont.getModified()).setEntry(delNode.getNodeKey(), delNode);
        ((UnorderedKeyValuePage) cont.getComplete()).setEntry(delNode.getNodeKey(), delNode);
    } else {
        throw new IllegalStateException("Node not found!");
    }
}
Also used : PageContainer(org.sirix.cache.PageContainer) Node(org.sirix.node.interfaces.Node) DeletedNode(org.sirix.node.DeletedNode) Record(org.sirix.node.interfaces.Record) DeletedNode(org.sirix.node.DeletedNode) UnorderedKeyValuePage(org.sirix.page.UnorderedKeyValuePage) SirixDeweyID(org.sirix.node.SirixDeweyID) NodeDelegate(org.sirix.node.delegates.NodeDelegate)

Aggregations

NodeDelegate (org.sirix.node.delegates.NodeDelegate)16 StructNodeDelegate (org.sirix.node.delegates.StructNodeDelegate)12 NameNodeDelegate (org.sirix.node.delegates.NameNodeDelegate)11 ValNodeDelegate (org.sirix.node.delegates.ValNodeDelegate)9 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)9 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DataInputStream (java.io.DataInputStream)6 DataOutputStream (java.io.DataOutputStream)6 Test (org.junit.Test)6 QNm (org.brackit.xquery.atomic.QNm)4 SirixDeweyID (org.sirix.node.SirixDeweyID)3 PageContainer (org.sirix.cache.PageContainer)2 DocumentRootNode (org.sirix.node.DocumentRootNode)2 ElementNode (org.sirix.node.ElementNode)2 PathNode (org.sirix.index.path.summary.PathNode)1 AttributeNode (org.sirix.node.AttributeNode)1 CommentNode (org.sirix.node.CommentNode)1 DeletedNode (org.sirix.node.DeletedNode)1 NamespaceNode (org.sirix.node.NamespaceNode)1