Class RadixTreeParser
- java.lang.Object
-
- org.opennms.netmgt.syslogd.RadixTreeParser
-
- All Implemented Interfaces:
ByteBufferParser<SyslogMessage>
public class RadixTreeParser extends 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 incomingByteBuffer
messages, theRadixTree
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 theteach(ParserStage[])
method. This will add the stages to theRadixTree
.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 Summary
Constructors Constructor Description RadixTreeParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
compressNode(RadixTreeNode<ParserStage> node)
CompletableFuture<SyslogMessage>
parse(ByteBuffer incoming)
void
performEdgeCompression()
int
size()
void
teach(ParserStage[] stages)
Teach a newParserStage
sequence to this parser.
-
-
-
Method Detail
-
size
public int size()
- Returns:
- The number of nodes in the underlying radix tree.
-
teach
public void teach(ParserStage[] stages)
Teach a newParserStage
sequence to this parser.- Parameters:
stages
-
-
performEdgeCompression
public void performEdgeCompression()
-
compressNode
public static void compressNode(RadixTreeNode<ParserStage> node)
-
parse
public CompletableFuture<SyslogMessage> parse(ByteBuffer incoming)
- Specified by:
parse
in interfaceByteBufferParser<SyslogMessage>
-
-