Re: LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-09-14 Thread Mike Beckerle
On Thu, Sep 14, 2023 at 1:06 PM Steve Lawrence wrote: > ... > > And with changes to the API, we could maybe even avoid #1 without > ThreadLocals. For example, instead of using a LayerTransformerFactory to > create new LayerTransformer instances, maybe we just directly create new > instances of

Re: LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-09-14 Thread Steve Lawrence
All fair points. After becoming a bit more familiar with how layers work, I have some additional thoughts. Currently the way layers work is we create a single LayerTransformerFactory during schema compilation, and each time parse/unparse comes across this layer it calls factory.newInstance()

Re: LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-09-13 Thread Mike Beckerle
(Reviving this discussion thread - it went quiet last few weeks, and I forgot to hit 'send' on this reply) I would suggest that layer transformers, UDFs, and charset definitions are not very much like NiFi processors. They're generally embedded in DFDL "component" schemas that are used by

Re: LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-08-16 Thread Steve Lawrence
I'm thinking the layer framework needs to allocate the layer transformer instance in a thread-local manner so that if it constructs mutable state that will be thread local also One downside to this is layer transformers that are thread-safe unnecessarily incur some amount of overhead, both in

Re: LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-08-16 Thread Mike Beckerle
In the CRC32 layer, the "optimization" was really just laziness. The use case we have only needs constant known explicit lengths, so we wanted to hard wire that, and not bother to support nor test any other cases. But, had that worked, I would bet we would have made the mistake and pre-allocated

Re: LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-08-16 Thread Steve Lawrence
I don't remember why NoCacheEvluatable was used, but you're I suspect you're right that it was done so implementations are less likely to mess things up. Note that NoCacheEvaluatable is also used for ImplicitLengthEv. I'm not sure why it's used there either. Maybe LayerLengthEv just copied

LayerLengthEv and NoCacheEvaluatable - Layer API issue

2023-08-15 Thread Mike Beckerle
Lola Kilo and I were debugging a layer for CRC32 and found that the LayerLengthEv is a NoCacheEvaluatable, so even if the schema does dfdlx:layerLength="1240" a constant, the the layerLengthEv.optConstant is None, which is because it is a NoCacheEvaluatable, which insists optConstant is false to