Date: 2005-02-17T23:27:07 Editor: EmmanuelLecharny Wiki: Apache Directory Project Wiki Page: TLVPageInfo URL: http://wiki.apache.org/directory/TLVPageInfo
no comment Change Log: ------------------------------------------------------------------------------ @@ -25,6 +25,10 @@ ''Looking at the automaton below it occurred to me that we can create two different Tag decoders. A stateless one for protocols that only requires a single byte Tag. You get whole bytes delivered in buffers so no need to keep state right? The stateless Tag really simplifies the automaton ;). For multibyte protocols we do collect bytes in a TagOctetCollector which is just a wrapper around a Java int. Do you think this needs to be revamped? In the case of a protocol where the number of Tag octets can be greater than 1 we can use a less efficient stateful Tag decoder which needs the full logic of the automaton. I know this is just some extra if-then-else logic but that adds up for every byte. So we can swap out the Tag decoder used based on the protocol. Most hopefully will take the simple tag decoder and not pay too much of a penalty.'' +''(Having two decoders will lead, I think, to more complexity than necessary. The idea, basically, is that we don't need to have a TagDecoder, a Length Decoder and a Value Decoder. All those decoder could perfectly be wrapped in a TLV decoder - I'm working on that, actually -, which will be really more efficient, even if the statefull decoder is much more complicated (ok, it's not that complex ;-). In a way, to discriminate between a single byte and a multibyte just need an 'if' test, wich is really fast. I perfectly agree that we could switch from a single/multi byte decoder depending on the protocol we are decoding, so why don't we keep it beside for further optimisations, if needed?)'' + +''(Note : the Tag decoder implanting this state automaton is somehow much fatser than the one which is used : 5 times. But this number has to be check again to be sure that it does not break the base code)'' + ''BTW note that if we have a protocol with more that 30 tags we only need one multibyte tag decoder per stream. This is a per connection setup cost paid once and not for every Tag that comes through.'' Decoding a Tag has to follow the finite state automaton showed on this picture :
