You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Uri Boness (JIRA)" <ji...@apache.org> on 2009/12/13 19:13:18 UTC

[jira] Issue Comment Edited: (SOLR-1644) Provide a clean way to keep flags and helper objects in ResponseBuilder

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

Uri Boness edited comment on SOLR-1644 at 12/13/09 6:13 PM:
------------------------------------------------------------

bq. if (rb.store.get(HighlightingComponent.DO_HIGHLIGHTING) == Boolean.TRUE)

This is verbose... too verbose to my taste. I believe a Store interface can help here which provide access to data by a key and will also provide helper methods to keep the code clean. (a MapStore can be a simple implementation which wraps a Map<String, Object> instance):

{code}
public interface Store {

    Boolean getBoolean(String key);
    boolean getBoolean(String key, boolean defaultValue);
    
    Integer getInt(String key);
    int getInt(String key, int defaultValue);

    //other methods for all primitive types and dates.
}
{code}

so now you have:

{code}
if (rb.store.getBoolean(HighlightingComponent.DO_HIGHLIGHTING, false))
{code}

which is cleaner and is NPE-safe.

bq. I believe the public API's should have no dependency on components .
I agree. Basically avoid having circular dependencies. You don't want to change the platform API every time you introduce a new component.

      was (Author: uboness):
    bq. if (rb.store.get(HighlightingComponent.DO_HIGHLIGHTING) == Boolean.TRUE)

This is verbose... too verbose to my taste. I believe a Store interface can help here which provide access to data by a key and will also provide helper methods to keep the code clean. (a MapStore can be a simple implementation which wraps a Map<String, Object> instance):

{code}
public interface Context {

    Boolean getBoolean(String key);
    boolean getBoolean(String key, boolean defaultValue);
    
    Integer getInt(String key);
    int getInt(String key, int defaultValue);

    //other methods for all primitive types and dates.
}
{code}

so now you have:

{code}
if (rb.store.getBoolean(HighlightingComponent.DO_HIGHLIGHTING, false))
{code}

which is cleaner and is NPE-safe.

bq. I believe the public API's should have no dependency on components .
I agree. Basically avoid having circular dependencies. You don't want to change the platform API every time you introduce a new component.
  
> Provide a clean way to keep flags and helper objects in ResponseBuilder
> -----------------------------------------------------------------------
>
>                 Key: SOLR-1644
>                 URL: https://issues.apache.org/jira/browse/SOLR-1644
>             Project: Solr
>          Issue Type: Improvement
>          Components: search
>            Reporter: Shalin Shekhar Mangar
>            Assignee: Shalin Shekhar Mangar
>             Fix For: 1.5
>
>         Attachments: SOLR-1644.patch
>
>
> Many components such as StatsComponent, FacetComponent etc keep flags and helper objects in ResponseBuilder. Having to modify the ResponseBuilder for such things is a very kludgy solution.
> Let us provide a clean way for components to keep arbitrary objects for the duration of a (distributed) search request.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.