On 10/24/2018 11:33 AM, Lukas Eder wrote:
On Wed, Oct 24, 2018 at 7:27 PM Marshall Pierce <[email protected]
<mailto:[email protected]>> wrote:
Perhaps a
.cachedSomethingOrOther() that returns another Result -- that transient
object would be convenient to GC if it's only used in a loop, for
instance.
But how would that work? By the time this caching mechanism has
identified the cache key (e.g. composed of all the fields of the source
record type and all the fields of the target record type), the actual
mapping would have executed many times...
I'm not sure I follow, but I'm also not sure my proposal was thought
through very well. :)
What about this? Instead of:
result.map { SomeTuple(it.into(BOOKS), it.into(AUTHORS)) }
something more like:
val metadataCache = result.helpfulCommunicativeNameForThisMethod()
result.map {
SomeTuple(metadataCache.into(it, BOOKS),
metadataCache.into(it, AUTHORS))
}
Since the cache is explicitly re-used, presumably the work to map BOOKS
columns into a BooksRecord would only be done once.
That could be cleaned up some to make mis-use harder (provide the
transient cache and allow iteration via some callback perhaps to make
accidental leakage of the cache harder?), but hopefully that gets the
idea across.
--
You received this message because you are subscribed to the Google Groups "jOOQ User
Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.