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

ASF GitHub Bot commented on SOLR-10703:
---------------------------------------

Github user tflobbe commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/202#discussion_r137335651
  
    --- Diff: 
solr/core/src/test/org/apache/solr/response/TestCustomDocTransformer.java ---
    @@ -68,6 +69,51 @@ public void testCustomTransformer() throws Exception {
             "//str[.='xx#title_2#']",
             "//str[.='xx#title_3#']");
       }
    +
    +  @Test
    +  public void testFinishCallInCustomFinishTransformer() throws Exception {
    +    // Build a simple index
    +    int max = 10;
    +    for(int i=0; i<max; i++) {
    +      SolrInputDocument sdoc = new SolrInputDocument();
    +      sdoc.addField("id", i);
    +      sdoc.addField("subject", "xx");
    +      sdoc.addField("title", "title_"+i);
    +      updateJ(jsonAdd(sdoc), null);
    +    }
    +    assertU(commit());
    +    assertQ(req("q", "*:*"), "//*[@numFound='" + max + "']");
    +
    +    assertQ( req(
    +        "q", "*:*",
    +        "fl", "id,[customFinish]",
    +        "rows", String.valueOf(max)
    +        ),
    +        // Check that the concatenated fields make it in the results
    +        "//*[@numFound='" + max + "']");
    +
    +    // finish() will double the number of documents
    +    assertEquals(max*2, 
CustomFinishTransformerFactory.finishTrasformer.counter);
    +    CustomFinishTransformerFactory.finishTrasformer.counter = 0;
    +
    +    // test binary writer
    +    h.query(req(
    +        "q", "*:*",
    +        "fl", "id,[customFinish]",
    +        "rows", String.valueOf(max),
    +        "wt", "javabin"
    +    ));
    +    assertEquals(max*2, 
CustomFinishTransformerFactory.finishTrasformer.counter);
    +
    +    // test that a transformer that throws an exception doesn't affect the 
other transformers
    +    h.query(req(
    +        "q", "*:*",
    +        "fl", "id,[exceptionFinish],[customFinish]",
    +        "rows", String.valueOf(max),
    +        "wt", "javabin"
    +    ));
    +    assertEquals(max*2, 
CustomFinishTransformerFactory.finishTrasformer.counter);
    --- End diff --
    
    Suggestion: Assert that the exception was actually thrown, and add a 
"ignoreException" to not pollute the logs


> DocTransformer implements Closeable
> -----------------------------------
>
>                 Key: SOLR-10703
>                 URL: https://issues.apache.org/jira/browse/SOLR-10703
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Diego Ceccarelli
>            Priority: Minor
>             Fix For: 7.0
>
>
> This patch -adds a {{prepare}} and a {{finish}} method to the interface of 
> {{DocTransformer}}- allowing a developer to perform actions before/after a 
> doc transformer is applied to a result set. My use case was to benchmark the 
> performance of a transformer, since transformer time is not part of 
> {{QTime}}. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to