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

Paul Elschot commented on LUCENE-7602:
--------------------------------------

The interesting pieces of code for ContextMap:

The class itself:
{code}
public class ContextMap extends HashMap<Object,Object> {
  public ContextMap() { // empty
  }

  public ContextMap(ContextMap source) { // new copy
    super(source);
  }

  public ContextMap(IdentityHashMap<?,?> source) { // for solr
    super(source);
  }
}
{code}


the way it is used in solr, in SlotAcc.java:
{code}
class SolrContextMap extends ContextMap {
  SolrContextMap(org.apache.solr.search.QueryContext context) {
    super((java.util.IdentityHashMap)context); // CHECKME: copy ok?
  }
}

// TODO: we should really have a decoupled value provider...
// This would enhance reuse and also prevent multiple lookups of same value 
across diff stats
abstract class FuncSlotAcc extends SlotAcc {
  protected final ValueSource valueSource;
  protected FunctionValues values;

  public FuncSlotAcc(ValueSource values, FacetContext fcontext, int numSlots) {
    super(fcontext);
    this.valueSource = values;
  }

  @Override
  public void setNextReader(LeafReaderContext readerContext) throws IOException 
{
    values = valueSource.getValues(new SolrContextMap(fcontext.qcontext), 
readerContext);
  }
}
{code}

and some unchanged code from solr's QueryContext.java:
{code}
/*
 * Bridge between old style context and a real class.
 * This is currently slightly more heavy weight than necessary because of the 
need to inherit from IdentityHashMap rather than
 * instantiate it on demand (and the need to put "searcher" in the map)
 * @lucene.experimental
 */
public class QueryContext extends IdentityHashMap implements Closeable {
   ...
}
{code}


> Fix compiler warnings for ant clean compile
> -------------------------------------------
>
>                 Key: LUCENE-7602
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7602
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Paul Elschot
>            Priority: Minor
>              Labels: build
>             Fix For: trunk
>
>         Attachments: LUCENE-7602-ContextMap-lucene.patch, 
> LUCENE-7602-ContextMap-solr.patch, LUCENE-7602.patch
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to