Class MsgPackTree

  • All Implemented Interfaces:
    MsgPackDiff

    public final class MsgPackTree
    extends Object
    implements MsgPackDiff
    Represents a tree data structure, for a msg pack document.

    The nodes of the tree can be either a real node, which has child's, or a leaf, which has a mapping in the corresponding msg pack document to his value.

    The message pack document tree can be created from scratch from a underlying document. This can be done with the MsgPackDocumentIndexer. It can also be constructed from only a port of a message pack document. This can be done with the MsgPackDocumentExtractor.

    The message pack tree can consist from two different message pack documents. The underlying document, from which the tree is completely build and the extract document, which can be a part of another message pack document. The tree representation of the extract document will be as well added to the current message pack tree object.

    Since the leafs contains a mapping, which consist of position and length, it is necessary that both documents are available for the message pack tree, so the leaf value can be resolved later. The leafs have to be distinguished, is it a leaf from the underlying document or is it from the extract document. For this distinction the MsgPackNodeType#EXISTING_LEAF_NODE and MsgPackNodeType#EXTRACTED_LEAF_NODE are used.

    • Constructor Detail

      • MsgPackTree

        public MsgPackTree()
    • Method Detail

      • size

        public int size()
      • clear

        public void clear()
      • getChildren

        public Set<String> getChildren​(String nodeId)
        Returns:
        the names (not IDs) of the child nodes
      • addDocument

        public int addDocument​(org.agrona.DirectBuffer document)
      • isValueNode

        public boolean isValueNode​(String nodeId)
      • isArrayNode

        public boolean isArrayNode​(String nodeId)
      • isMapNode

        public boolean isMapNode​(String nodeId)
      • mergeInto

        public void mergeInto​(MsgPackTree other)
        Always replaces containers (object/array), unless it is the root object
        Specified by:
        mergeInto in interface MsgPackDiff
      • convertToArrayNode

        public void convertToArrayNode​(String nodeId)
        Keeps any children, e.g. when converting MAP to ARRAY
      • convertToMapNode

        public void convertToMapNode​(String nodeId)
        Keeps any children, e.g. when converting ARRAY to MAP
      • appendToArray

        public String appendToArray​(String parentId,
                                    String arrayNodeName,
                                    int documentId,
                                    int elementOffset,
                                    int elementLength)
        Creates or converts the addressed node to an array and appends the value as a new element. Replaces a previously existing non-array node completely.
      • addValueNode

        public String addValueNode​(String parentId,
                                   String nodeName,
                                   int documentId,
                                   int valueOffset,
                                   int valueLength)
      • hasNode

        public boolean hasNode​(String id)
      • clearChildren

        public void clearChildren​(String nodeId)