[
https://issues.apache.org/jira/browse/JENA-1862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17085148#comment-17085148
]
ASF subversion and git services commented on JENA-1862:
-------------------------------------------------------
Commit 40256a7944a8e1fb60998d0bbc0873193a4ed5a8 in jena's branch
refs/heads/master from Andy Seaborne
[ https://gitbox.apache.org/repos/asf?p=jena.git;h=40256a7 ]
Merge pull request #712 from Aklakan/JENA-1862
JENA-1862: Query.clone is slow
> 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
> Time Spent: 2h 50m
> Remaining Estimate: 0h
>
> 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)