So the objective here is to create another Query cloning method that is fast? Why not just replace the original Query.clone() with the new implementation?
On Fri, Mar 13, 2020 at 10:42 PM Andy Seaborne (Jira) <[email protected]> wrote: > > [ > https://issues.apache.org/jira/browse/JENA-1862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17059116#comment-17059116 > ] > > Andy Seaborne commented on JENA-1862: > ------------------------------------- > > Sounds like a good plan. > > The print-parse form of {{clone()}} hasn't changed in many versions and > the comment in the code ("A little crude.") is certainly true! > > Please do send a pull request. > > > > Query.cloneQuery is slow > > ------------------------ > > > > Key: JENA-1862 > > URL: https://issues.apache.org/jira/browse/JENA-1862 > > Project: Apache Jena > > Issue Type: Improvement > > Components: ARQ > > Affects Versions: Jena 3.14.0 > > Reporter: Claus Stadler > > Priority: Major > > > > This is a follow up to JENA-1861 which is about the thread safety of > Query objects. As sharing a Query object across threads may introduce race > conditions, the obvious workaround would be to just clone it. However, the > current implementation serializes the query to string and then re-parses it > which causes a very high overhead (for my use case it became the top entry > in the VisualVM profiler). > > Proposal: > > * Extend ElementTransformCopyBase with a 'alwaysCopy' flag analogous to > ExprTransformCopy > > * Add a new constructor to > ExprTransformApplyElementTransform(ElementTransform transform, boolean > alwaysCopy) so that the alwayCopy flag of the underlying ExprTransformCopy > can be set to true > > * Implement clone using syntatic transforms as below > > {code:java} > > public static Query fastClone(Query query) { > > ElementTransform eltXform = new ElementTransformCopyBase2(true); > > ExprTransform exprXform = new > ExprTransformApplyElementTransform2(eltXform, true); > > Query result = QueryTransformOps.transform(query, eltXform, > exprXform); > > return result; > > } > > {code} > > This approach 'works-for-me' and I can create a pull request for this, > but maybe there are more subtleties to the outlined approach that need to > be considered? > > > > -- > This message was sent by Atlassian Jira > (v8.3.4#803005) > -- I like: Like Like - The likeliest place on the web <http://like-like.xenei.com> LinkedIn: http://www.linkedin.com/in/claudewarren
