[ 
https://issues.apache.org/jira/browse/JENA-1862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17085183#comment-17085183
 ] 

ASF subversion and git services commented on JENA-1862:
-------------------------------------------------------

Commit 03af50e8d47d9bd66c1b9a1095f197ea4d048879 in jena's branch 
refs/heads/master from Andy Seaborne
[ https://gitbox.apache.org/repos/asf?p=jena.git;h=03af50e ]

JENA-1862: Test fix due to improved query transform code


> 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
>            Assignee: Andy Seaborne
>            Priority: Major
>             Fix For: Jena 3.15.0
>
>          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)

Reply via email to