Class RadixTreeParser

  • All Implemented Interfaces:
    ByteBufferParser<SyslogMessage>

    public class RadixTreeParser
    extends java.lang.Object
    implements ByteBufferParser<SyslogMessage>

    This class uses a RadixTree to store a tree of parser stages. Each leaf node of the tree represents a complete parse of an incoming message. To parse incoming ByteBuffer messages, the RadixTree is traversed and each stage is added as a future processing step. When a leaf node is reached and returns a non-null result, ie. a complete parse, that result is returned as the parse result.

    You can teach the parser new ParserStage sequences by using the teach(ParserStage[]) method. This will add the stages to the RadixTree.

    TODO: Make the parser tree construction phased or asynchronous so that tree nodes are added as-needed to complete the parse. In many cases, the first several branches of the tree will result in a complete parse, making it unnecessary to add all possible branches to the execution tree.

    TODO: Allow cancellation of in-progress branches when the first non-null result is obtained.

    TODO: Score and sort parse branches based on successful parses. If a particular parse branch is successful, we should have a way to increment a score on the stages in that branch so that we can periodically sort the tree based on these scores. This will put heavily utilized parse branches near the front of the tree, making it faster to traverse the branches to a successful parse.

    Author:
    Seth
    • Constructor Detail

      • RadixTreeParser

        public RadixTreeParser()
    • Method Detail

      • size

        public int size()
        Returns:
        The number of nodes in the underlying radix tree.
      • teach

        public void teach​(ParserStage[] stages)
        Teach a new ParserStage sequence to this parser.
        Parameters:
        stages -
      • performEdgeCompression

        public void performEdgeCompression()