You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Lucene/Solr QA (JIRA)" <ji...@apache.org> on 2018/05/23 19:09:01 UTC

[jira] [Commented] (SOLR-12374) Add SolrCore.withSearcher(lambda accepting SolrIndexSearcher)

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

Lucene/Solr QA commented on SOLR-12374:
---------------------------------------

| (x) *{color:red}-1 overall{color}* |
\\
\\
|| Vote || Subsystem || Runtime || Comment ||
|| || || || {color:brown} Prechecks {color} ||
| {color:green}+1{color} | {color:green} test4tests {color} | {color:green}  0m  0s{color} | {color:green} The patch appears to include 19 new or modified test files. {color} |
|| || || || {color:brown} master Compile Tests {color} ||
| {color:green}+1{color} | {color:green} compile {color} | {color:green}  3m  6s{color} | {color:green} master passed {color} |
|| || || || {color:brown} Patch Compile Tests {color} ||
| {color:green}+1{color} | {color:green} compile {color} | {color:green}  2m 58s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} javac {color} | {color:green}  2m 58s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Release audit (RAT) {color} | {color:green}  1m 52s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Check forbidden APIs {color} | {color:green}  1m 47s{color} | {color:green} the patch passed {color} |
| {color:green}+1{color} | {color:green} Validate source patterns {color} | {color:green}  1m 47s{color} | {color:green} the patch passed {color} |
|| || || || {color:brown} Other Tests {color} ||
| {color:green}+1{color} | {color:green} unit {color} | {color:green}  1m  9s{color} | {color:green} clustering in the patch passed. {color} |
| {color:red}-1{color} | {color:red} unit {color} | {color:red} 74m 49s{color} | {color:red} core in the patch failed. {color} |
| {color:black}{color} | {color:black} {color} | {color:black} 85m 42s{color} | {color:black} {color} |
\\
\\
|| Reason || Tests ||
| Failed junit tests | solr.cloud.autoscaling.sim.TestTriggerIntegration |
|   | solr.cloud.autoscaling.IndexSizeTriggerTest |
|   | solr.cloud.autoscaling.SearchRateTriggerTest |
|   | solr.cloud.autoscaling.sim.TestLargeCluster |
\\
\\
|| Subsystem || Report/Notes ||
| JIRA Issue | SOLR-12374 |
| JIRA Patch URL | https://issues.apache.org/jira/secure/attachment/12924607/SOLR-12374.patch |
| Optional Tests |  compile  javac  unit  ratsources  checkforbiddenapis  validatesourcepatterns  |
| uname | Linux lucene1-us-west 3.13.0-88-generic #135-Ubuntu SMP Wed Jun 8 21:10:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux |
| Build tool | ant |
| Personality | /home/jenkins/jenkins-slave/workspace/PreCommit-SOLR-Build/sourcedir/dev-tools/test-patch/lucene-solr-yetus-personality.sh |
| git revision | master / d32ce81 |
| ant | version: Apache Ant(TM) version 1.9.3 compiled on April 8 2014 |
| Default Java | 1.8.0_172 |
| unit | https://builds.apache.org/job/PreCommit-SOLR-Build/103/artifact/out/patch-unit-solr_core.txt |
|  Test Results | https://builds.apache.org/job/PreCommit-SOLR-Build/103/testReport/ |
| modules | C: solr/contrib/clustering solr/core U: solr |
| Console output | https://builds.apache.org/job/PreCommit-SOLR-Build/103/console |
| Powered by | Apache Yetus 0.7.0   http://yetus.apache.org |


This message was automatically generated.



> Add SolrCore.withSearcher(lambda accepting SolrIndexSearcher)
> -------------------------------------------------------------
>
>                 Key: SOLR-12374
>                 URL: https://issues.apache.org/jira/browse/SOLR-12374
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: David Smiley
>            Assignee: David Smiley
>            Priority: Minor
>             Fix For: 7.4
>
>         Attachments: SOLR-12374.patch
>
>
> I propose adding the following to SolrCore:
> {code:java}
>   /**
>    * Executes the lambda with the {@link SolrIndexSearcher}.  This is more convenience than using
>    * {@link #getSearcher()} since there is no ref-counting business to worry about.
>    * Example:
>    * <pre class="prettyprint">
>    *   IndexReader reader = h.getCore().withSearcher(SolrIndexSearcher::getIndexReader);
>    * </pre>
>    */
>   @SuppressWarnings("unchecked")
>   public <R> R withSearcher(Function<SolrIndexSearcher,R> lambda) {
>     final RefCounted<SolrIndexSearcher> refCounted = getSearcher();
>     try {
>       return lambda.apply(refCounted.get());
>     } finally {
>       refCounted.decref();
>     }
>   }
> {code}
> This is a nice tight convenience method, avoiding the clumsy RefCounted API which is easy to accidentally incorrectly use – see https://issues.apache.org/jira/browse/SOLR-11616?focusedCommentId=16477719&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16477719
> I guess my only (small) concern is if hypothetically you might make the lambda short because it's easy to do that (see the one-liner example above) but the object you return that you're interested in  (say IndexReader) could potentially become invalid if the SolrIndexSearcher closes.  But I think/hope that's impossible normally based on when this getSearcher() used?  I could at least add a warning to the docs.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org