You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/10/23 00:05:23 UTC

[02/52] [abbrv] [partial] lucene-solr:jira/gradle: Add gradle support for Solr

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
deleted file mode 100644
index 1f9e2d5..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.grouping.SearchGroup;
-import org.apache.lucene.search.grouping.TopGroups;
-import org.apache.lucene.util.BytesRef;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.util.RTimer;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.request.SolrRequestInfo;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.CursorMark;
-import org.apache.solr.search.DocListAndSet;
-import org.apache.solr.search.QParser;
-import org.apache.solr.search.QueryCommand;
-import org.apache.solr.search.QueryResult;
-import org.apache.solr.search.SortSpec;
-import org.apache.solr.search.RankQuery;
-import org.apache.solr.search.grouping.GroupingSpecification;
-import org.apache.solr.search.grouping.distributed.command.QueryCommandResult;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class is experimental and will be changing in the future.
- *
- *
- * @since solr 1.3
- */
-public class ResponseBuilder
-{
-  public SolrQueryRequest req;
-  public SolrQueryResponse rsp;
-  public boolean doHighlights;
-  public boolean doFacets;
-  public boolean doExpand;
-  public boolean doStats;
-  public boolean doTerms;
-  public boolean doAnalytics;
-  public MergeStrategy mergeFieldHandler;
-
-  private boolean needDocList = false;
-  private boolean needDocSet = false;
-  private int fieldFlags = 0;
-  //private boolean debug = false;
-  private boolean debugTimings, debugQuery, debugResults, debugTrack;
-
-  private QParser qparser = null;
-  private String queryString = null;
-  private Query query = null;
-  private List<Query> filters = null;
-  private SortSpec sortSpec = null;
-  private GroupingSpecification groupingSpec;
-  private CursorMark cursorMark;
-  private CursorMark nextCursorMark;
-
-  private List<MergeStrategy> mergeStrategies;
-  private RankQuery rankQuery;
-
-
-  private DocListAndSet results = null;
-  private NamedList<Object> debugInfo = null;
-  private RTimer timer = null;
-
-  private Query highlightQuery = null;
-
-  public List<SearchComponent> components;
-
-  SolrRequestInfo requestInfo;
-
-  public ResponseBuilder(SolrQueryRequest req, SolrQueryResponse rsp, List<SearchComponent> components)
-  {
-    this.req = req;
-    this.rsp = rsp;
-    this.components = components;
-    this.requestInfo = SolrRequestInfo.getRequestInfo();
-  }
-
-  //////////////////////////////////////////////////////////
-  //////////////////////////////////////////////////////////
-  //// Distributed Search section
-  //////////////////////////////////////////////////////////
-  //////////////////////////////////////////////////////////
-
-  public static final String FIELD_SORT_VALUES = "fsv";
-  public static final String SHARDS = "shards";
-  public static final String IDS = "ids";
-
-  /**
-   * public static final String NUMDOCS = "nd";
-   * public static final String DOCFREQS = "tdf";
-   * public static final String TERMS = "terms";
-   * public static final String EXTRACT_QUERY_TERMS = "eqt";
-   * public static final String LOCAL_SHARD = "local";
-   * public static final String DOC_QUERY = "dq";
-   * *
-   */
-
-  public static int STAGE_START = 0;
-  public static int STAGE_PARSE_QUERY = 1000;
-  public static int STAGE_TOP_GROUPS = 1500;
-  public static int STAGE_EXECUTE_QUERY = 2000;
-  public static int STAGE_GET_FIELDS = 3000;
-  public static int STAGE_DONE = Integer.MAX_VALUE;
-
-  public int stage;  // What stage is this current request at?
-
-  //The address of the Shard
-  boolean isDistrib; // is this a distributed search?
-  public String[] shards;
-  public String[] slices; // the optional logical ids of the shards
-  public int shards_rows = -1;
-  public int shards_start = -1;
-  public List<ShardRequest> outgoing;  // requests to be sent
-  public List<ShardRequest> finished;  // requests that have received responses from all shards
-  public String shortCircuitedURL;
-
-  /**
-   * This function will return true if this was a distributed search request.
-   */
-  public boolean isDistributed() {
-    return this.isDistrib;
-  }
-
-  public int getShardNum(String shard) {
-    for (int i = 0; i < shards.length; i++) {
-      if (shards[i] == shard || shards[i].equals(shard)) return i;
-    }
-    return -1;
-  }
-
-  public void addRequest(SearchComponent me, ShardRequest sreq) {
-    outgoing.add(sreq);
-    if ((sreq.purpose & ShardRequest.PURPOSE_PRIVATE) == 0) {
-      // if this isn't a private request, let other components modify it.
-      for (SearchComponent component : components) {
-        if (component != me) {
-          component.modifyRequest(this, me, sreq);
-        }
-      }
-    }
-  }
-
-  public GlobalCollectionStat globalCollectionStat;
-
-  public Map<Object, ShardDoc> resultIds;
-  // Maps uniqueKeyValue to ShardDoc, which may be used to
-  // determine order of the doc or uniqueKey in the final
-  // returned sequence.
-  // Only valid after STAGE_EXECUTE_QUERY has completed.
-
-  public boolean onePassDistributedQuery;
-
-  public FacetComponent.FacetInfo _facetInfo;
-  /* private... components that don't own these shouldn't use them */
-  SolrDocumentList _responseDocs;
-  StatsInfo _statsInfo;
-  TermsComponent.TermsHelper _termsHelper;
-  SimpleOrderedMap<List<NamedList<Object>>> _pivots;
-  Object _analyticsRequestManager;
-  boolean _isOlapAnalytics;
-
-  // Context fields for grouping
-  public final Map<String, Collection<SearchGroup<BytesRef>>> mergedSearchGroups = new HashMap<>();
-  public final Map<String, Integer> mergedGroupCounts = new HashMap<>();
-  public final Map<String, Map<SearchGroup<BytesRef>, Set<String>>> searchGroupToShards = new HashMap<>();
-  public final Map<String, TopGroups<BytesRef>> mergedTopGroups = new HashMap<>();
-  public final Map<String, QueryCommandResult> mergedQueryCommandResults = new HashMap<>();
-  public final Map<Object, SolrDocument> retrievedDocuments = new HashMap<>();
-  public int totalHitCount; // Hit count used when distributed grouping is performed.
-  // Used for timeAllowed parameter. First phase elapsed time is subtracted from the time allowed for the second phase.
-  public int firstPhaseElapsedTime;
-
-  /**
-   * Utility function to add debugging info.  This will make sure a valid
-   * debugInfo exists before adding to it.
-   */
-  public void addDebugInfo( String name, Object val )
-  {
-    if( debugInfo == null ) {
-      debugInfo = new SimpleOrderedMap<>();
-    }
-    debugInfo.add( name, val );
-  }
-
-  public void addDebug(Object val, String... path) {
-    if( debugInfo == null ) {
-      debugInfo = new SimpleOrderedMap<>();
-    }
-
-    NamedList<Object> target = debugInfo;
-    for (int i=0; i<path.length-1; i++) {
-      String elem = path[i];
-      NamedList<Object> newTarget = (NamedList<Object>)debugInfo.get(elem);
-      if (newTarget == null) {
-        newTarget = new SimpleOrderedMap<>();
-        target.add(elem, newTarget);
-      }
-      target = newTarget;
-    }
-
-    target.add(path[path.length-1], val);
-  }
-
-  //-------------------------------------------------------------------------
-  //-------------------------------------------------------------------------
-
-  public boolean isDebug() {
-    return debugQuery || debugTimings || debugResults || debugTrack;
-  }
-
-  /**
-   *
-   * @return true if all debugging options are on
-   */
-  public boolean isDebugAll(){
-    return debugQuery && debugTimings && debugResults && debugTrack;
-  }
-
-  public void setDebug(boolean dbg){
-    debugQuery = dbg;
-    debugTimings = dbg;
-    debugResults = dbg;
-    debugTrack = dbg;
-  }
-
-  public void addMergeStrategy(MergeStrategy mergeStrategy) {
-    if(mergeStrategies == null) {
-      mergeStrategies = new ArrayList();
-    }
-
-    mergeStrategies.add(mergeStrategy);
-  }
-
-  public List<MergeStrategy> getMergeStrategies() {
-    return this.mergeStrategies;
-  }
-
-  public RankQuery getRankQuery() {
-    return rankQuery;
-  }
-
-  public void setRankQuery(RankQuery rankQuery) {
-    this.rankQuery = rankQuery;
-  }
-
-  public void setResponseDocs(SolrDocumentList _responseDocs) {
-    this._responseDocs = _responseDocs;
-  }
-  
-  public SolrDocumentList getResponseDocs() {
-    return this._responseDocs;
-  }
-
-  public boolean isDebugTrack() {
-    return debugTrack;
-  }
-
-  public void setDebugTrack(boolean debugTrack) {
-    this.debugTrack = debugTrack;
-  }
-
-  public boolean isDebugTimings() {
-    return debugTimings;
-  }
-
-  public void setDebugTimings(boolean debugTimings) {
-    this.debugTimings = debugTimings;
-  }
-
-  public boolean isDebugQuery() {
-    return debugQuery;
-  }
-
-  public void setDebugQuery(boolean debugQuery) {
-    this.debugQuery = debugQuery;
-  }
-
-  public boolean isDebugResults() {
-    return debugResults;
-  }
-
-  public void setDebugResults(boolean debugResults) {
-    this.debugResults = debugResults;
-  }
-
-  public NamedList<Object> getDebugInfo() {
-    return debugInfo;
-  }
-
-  public void setDebugInfo(NamedList<Object> debugInfo) {
-    this.debugInfo = debugInfo;
-  }
-
-  public int getFieldFlags() {
-    return fieldFlags;
-  }
-
-  public void setFieldFlags(int fieldFlags) {
-    this.fieldFlags = fieldFlags;
-  }
-
-  public List<Query> getFilters() {
-    return filters;
-  }
-
-  public void setFilters(List<Query> filters) {
-    this.filters = filters;
-  }
-
-  public Query getHighlightQuery() {
-    return highlightQuery;
-  }
-
-  public void setHighlightQuery(Query highlightQuery) {
-    this.highlightQuery = highlightQuery;
-  }
-
-  public boolean isNeedDocList() {
-    return needDocList;
-  }
-
-  public void setNeedDocList(boolean needDocList) {
-    this.needDocList = needDocList;
-  }
-
-  public boolean isNeedDocSet() {
-    return needDocSet;
-  }
-
-  public void setNeedDocSet(boolean needDocSet) {
-    this.needDocSet = needDocSet;
-  }
-
-  public QParser getQparser() {
-    return qparser;
-  }
-
-  public void setQparser(QParser qparser) {
-    this.qparser = qparser;
-  }
-
-  public String getQueryString() {
-    return queryString;
-  }
-
-  public void setQueryString(String qstr) {
-    this.queryString = qstr;
-  }
-
-  public Query getQuery() {
-    return query;
-  }
-
-  public void setQuery(Query query) {
-    this.query = query;
-  }
-
-  public DocListAndSet getResults() {
-    return results;
-  }
-
-  public void setResults(DocListAndSet results) {
-    this.results = results;
-  }
-
-  public SortSpec getSortSpec() {
-    return sortSpec;
-  }
-
-  public void setSortSpec(SortSpec sortSpec) {
-    this.sortSpec = sortSpec;
-  }
-
-  public GroupingSpecification getGroupingSpec() {
-    return groupingSpec;
-  }
-
-  public void setGroupingSpec(GroupingSpecification groupingSpec) {
-    this.groupingSpec = groupingSpec;
-  }
-
-  public boolean grouping() {
-    return groupingSpec != null;
-  }
-
-  public RTimer getTimer() {
-    return timer;
-  }
-
-  public void setTimer(RTimer timer) {
-    this.timer = timer;
-  }
-
-
-  public static class GlobalCollectionStat {
-    public final long numDocs;
-
-    public final Map<String, Long> dfMap;
-
-    public GlobalCollectionStat(int numDocs, Map<String, Long> dfMap) {
-      this.numDocs = numDocs;
-      this.dfMap = dfMap;
-    }
-  }
-
-  /**
-   * Creates a SolrIndexSearcher.QueryCommand from this
-   * ResponseBuilder.  TimeAllowed is left unset.
-   */
-  public QueryCommand createQueryCommand() {
-    QueryCommand cmd = new QueryCommand();
-    cmd.setQuery(wrap(getQuery()))
-            .setFilterList(getFilters())
-            .setSort(getSortSpec().getSort())
-            .setOffset(getSortSpec().getOffset())
-            .setLen(getSortSpec().getCount())
-            .setFlags(getFieldFlags())
-            .setNeedDocSet(isNeedDocSet())
-            .setCursorMark(getCursorMark());
-    return cmd;
-  }
-
-  /** Calls {@link RankQuery#wrap(Query)} if there's a rank query, otherwise just returns the query. */
-  public Query wrap(Query q) {
-    if(this.rankQuery != null) {
-      return this.rankQuery.wrap(q);
-    } else {
-      return q;
-    }
-  }
-
-  /**
-   * Sets results from a SolrIndexSearcher.QueryResult.
-   */
-  public void setResult(QueryResult result) {
-    setResults(result.getDocListAndSet());
-    if (result.isPartialResults()) {
-      rsp.getResponseHeader().add(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, Boolean.TRUE);
-    }
-    final Boolean segmentTerminatedEarly = result.getSegmentTerminatedEarly();
-    if (segmentTerminatedEarly != null) {
-      rsp.getResponseHeader().add(SolrQueryResponse.RESPONSE_HEADER_SEGMENT_TERMINATED_EARLY_KEY, segmentTerminatedEarly);
-    }
-    if (null != cursorMark) {
-      assert null != result.getNextCursorMark() : "using cursor but no next cursor set";
-      this.setNextCursorMark(result.getNextCursorMark());
-    }
-  }
-  
-  public long getNumberDocumentsFound() {
-    if (_responseDocs == null) {
-      return 0;
-    }
-    return _responseDocs.getNumFound();
-  }
-
-  public CursorMark getCursorMark() {
-    return cursorMark;
-  }
-  public void setCursorMark(CursorMark cursorMark) {
-    this.cursorMark = cursorMark;
-  }
-
-  public CursorMark getNextCursorMark() {
-    return nextCursorMark;
-  }
-  public void setNextCursorMark(CursorMark nextCursorMark) {
-    this.nextCursorMark = nextCursorMark;
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java b/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java
deleted file mode 100644
index 9bbfb81..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ResponseLogComponent.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.response.ResultContext;
-import org.apache.solr.schema.IndexSchema;
-import org.apache.solr.search.DocIterator;
-import org.apache.solr.search.DocList;
-import org.apache.solr.search.SolrIndexSearcher;
-
-/**
- * Adds to the log file the document IDs that are sent in the query response.
- * If document scores are available in the response (by adding the pseudo-
- * column 'score' to the field list) then each document ID will be followed
- * by its score, as in:
- * <pre>
- * "... hits=55 responseLog=22:0.71231794,44:0.61231794 status=0 ..."
- * </pre>
- * 
- * Add it to a requestHandler in solrconfig.xml like this:
- * <pre class="prettyprint">
- * &lt;searchComponent name="responselog" class="solr.ResponseLogComponent"/&gt;
- * 
- * &lt;requestHandler name="/select" class="solr.SearchHandler"&gt;
- *   &lt;lst name="defaults"&gt;
- *   
- *     ...
- *     
- *   &lt;/lst&gt;
- *   &lt;arr name="components"&gt;
- *     &lt;str&gt;responselog&lt;/str&gt;
- *   &lt;/arr&gt;
- * &lt;/requestHandler&gt;</pre>
- *  
- *  It can then be enabled at query time by supplying <pre>responseLog=true</pre>
- *  query parameter.
- */
-public class ResponseLogComponent extends SearchComponent {
-
-  public static final String COMPONENT_NAME = "responseLog";
-
-  @Override
-  public void prepare(ResponseBuilder rb) throws IOException {}
-
-  @Override
-  public void process(ResponseBuilder rb) throws IOException {
-    SolrParams params = rb.req.getParams();
-    if (!params.getBool(COMPONENT_NAME, false)) return;
-    
-    SolrIndexSearcher searcher = rb.req.getSearcher();
-    IndexSchema schema = searcher.getSchema();
-    if (schema.getUniqueKeyField() == null) return;
-
-    ResultContext rc = (ResultContext) rb.rsp.getResponse();
-
-    DocList docs = rc.getDocList();
-    if (docs.hasScores()) {
-      processScores(rb, docs, schema, searcher);
-    } else {
-      processIds(rb, docs, schema, searcher);
-    }
-  }
-
-  protected void processIds(ResponseBuilder rb, DocList dl, IndexSchema schema,
-      SolrIndexSearcher searcher) throws IOException {
-    
-    StringBuilder sb = new StringBuilder();
-
-    Set<String> fields = Collections.singleton(schema.getUniqueKeyField().getName());
-    for(DocIterator iter = dl.iterator(); iter.hasNext();) {
-
-      sb.append(schema.printableUniqueKey(searcher.doc(iter.nextDoc(), fields)))
-        .append(',');
-    }
-    if (sb.length() > 0) {
-      rb.rsp.addToLog("responseLog", sb.substring(0, sb.length() - 1));
-    }  
-  }
-  
-  protected void processScores(ResponseBuilder rb, DocList dl, IndexSchema schema,
-      SolrIndexSearcher searcher) throws IOException {
-    
-    StringBuilder sb = new StringBuilder();
-    Set<String> fields = Collections.singleton(schema.getUniqueKeyField().getName());
-    for(DocIterator iter = dl.iterator(); iter.hasNext();) {
-      sb.append(schema.printableUniqueKey(searcher.doc(iter.nextDoc(), fields)))
-        .append(':')
-        .append(iter.score())
-        .append(',');
-    }
-    if (sb.length() > 0) {
-      rb.rsp.addToLog("responseLog", sb.substring(0, sb.length() - 1));
-    }  
-  }
-  
-  @Override
-  public String getDescription() {
-    return "A component that inserts the retrieved documents (and optionally scores) into the response log entry";
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java b/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java
deleted file mode 100644
index d923306..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchComponent.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import com.codahale.metrics.MetricRegistry;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.core.SolrInfoBean;
-import org.apache.solr.search.facet.FacetModule;
-import org.apache.solr.util.plugin.NamedListInitializedPlugin;
-
-/**
- * TODO!
- * 
- *
- * @since solr 1.3
- */
-public abstract class SearchComponent implements SolrInfoBean, NamedListInitializedPlugin
-{
-  /**
-   * The name given to this component in solrconfig.xml file
-   */
-  private String name = this.getClass().getName();
-
-  protected Set<String> metricNames = ConcurrentHashMap.newKeySet();
-  protected MetricRegistry registry;
-
-  /**
-   * Prepare the response.  Guaranteed to be called before any SearchComponent {@link #process(org.apache.solr.handler.component.ResponseBuilder)} method.
-   * Called for every incoming request.
-   *
-   * The place to do initialization that is request dependent.
-   * @param rb The {@link org.apache.solr.handler.component.ResponseBuilder}
-   * @throws IOException If there is a low-level I/O error.
-   */
-  public abstract void prepare(ResponseBuilder rb) throws IOException;
-
-  /**
-   * Process the request for this component 
-   * @param rb The {@link ResponseBuilder}
-   * @throws IOException If there is a low-level I/O error.
-   */
-  public abstract void process(ResponseBuilder rb) throws IOException;
-
-  /**
-   * Process for a distributed search.
-   * @return the next stage for this component
-   */
-  public int distributedProcess(ResponseBuilder rb) throws IOException {
-    return ResponseBuilder.STAGE_DONE;
-  }
-
-  /** Called after another component adds a request */
-  public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
-  }
-
-  /** Called after all responses for a single request were received */
-  public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
-  }
-
-  /** Called after all responses have been received for this stage.
-   * Useful when different requests are sent to each shard.
-   */
-  public void finishStage(ResponseBuilder rb) {
-  }
-  
-  /**
-   * Sets the name of the SearchComponent. The name of the component is usually
-   * the name defined for it in the configuration.
-   */
-  public void setName(String name) {
-    this.name = name;
-  }
-
-
-  //////////////////////// NamedListInitializedPlugin methods //////////////////////
-  @Override
-  public void init( NamedList args )
-  {
-    // By default do nothing
-  }
-
-  //////////////////////// SolrInfoMBeans methods //////////////////////
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public abstract String getDescription();
-
-  @Override
-  public Category getCategory() {
-    return Category.OTHER;
-  }
-
-  @Override
-  public Set<String> getMetricNames() {
-    return metricNames;
-  }
-
-  @Override
-  public MetricRegistry getMetricRegistry() {
-    return registry;
-  }
-
-  public static final Map<String, Class<? extends SearchComponent>> standard_components;
-
-
-  static {
-    HashMap<String, Class<? extends SearchComponent>> map = new HashMap<>();
-    map.put(HighlightComponent.COMPONENT_NAME, HighlightComponent.class);
-    map.put(QueryComponent.COMPONENT_NAME, QueryComponent.class);
-    map.put(FacetComponent.COMPONENT_NAME, FacetComponent.class);
-    map.put(FacetModule.COMPONENT_NAME, FacetModule.class);
-    map.put(MoreLikeThisComponent.COMPONENT_NAME, MoreLikeThisComponent.class);
-    map.put(StatsComponent.COMPONENT_NAME, StatsComponent.class);
-    map.put(DebugComponent.COMPONENT_NAME, DebugComponent.class);
-    map.put(RealTimeGetComponent.COMPONENT_NAME, RealTimeGetComponent.class);
-    map.put(ExpandComponent.COMPONENT_NAME, ExpandComponent.class);
-    map.put(TermsComponent.COMPONENT_NAME, TermsComponent.class);
-
-    standard_components = Collections.unmodifiableMap(map);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
deleted file mode 100644
index d4c680c..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.invoke.MethodHandles;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.lucene.index.ExitableDirectoryReader;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.cloud.ZkController;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.ShardParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.core.CloseHook;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.core.PluginInfo;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.handler.RequestHandlerBase;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.search.SolrQueryTimeoutImpl;
-import org.apache.solr.search.facet.FacetModule;
-import org.apache.solr.security.AuthorizationContext;
-import org.apache.solr.security.PermissionNameProvider;
-import org.apache.solr.util.RTimerTree;
-import org.apache.solr.util.SolrPluginUtils;
-import org.apache.solr.util.plugin.PluginInfoInitialized;
-import org.apache.solr.util.plugin.SolrCoreAware;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.solr.common.params.CommonParams.DISTRIB;
-import static org.apache.solr.common.params.CommonParams.PATH;
-
-
-/**
- *
- * Refer SOLR-281
- *
- */
-public class SearchHandler extends RequestHandlerBase implements SolrCoreAware , PluginInfoInitialized, PermissionNameProvider {
-  static final String INIT_COMPONENTS = "components";
-  static final String INIT_FIRST_COMPONENTS = "first-components";
-  static final String INIT_LAST_COMPONENTS = "last-components";
-
-  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
-  protected volatile List<SearchComponent> components;
-  private ShardHandlerFactory shardHandlerFactory ;
-  private PluginInfo shfInfo;
-  private SolrCore core;
-
-  protected List<String> getDefaultComponents()
-  {
-    ArrayList<String> names = new ArrayList<>(8);
-    names.add( QueryComponent.COMPONENT_NAME );
-    names.add( FacetComponent.COMPONENT_NAME );
-    names.add( FacetModule.COMPONENT_NAME );
-    names.add( MoreLikeThisComponent.COMPONENT_NAME );
-    names.add( HighlightComponent.COMPONENT_NAME );
-    names.add( StatsComponent.COMPONENT_NAME );
-    names.add( DebugComponent.COMPONENT_NAME );
-    names.add( ExpandComponent.COMPONENT_NAME);
-    names.add( TermsComponent.COMPONENT_NAME);
-
-    return names;
-  }
-
-  @Override
-  public void init(PluginInfo info) {
-    init(info.initArgs);
-    for (PluginInfo child : info.children) {
-      if("shardHandlerFactory".equals(child.type)){
-        this.shfInfo = child;
-        break;
-      }
-    }
-  }
-
-  @Override
-  public PermissionNameProvider.Name getPermissionName(AuthorizationContext ctx) {
-    return PermissionNameProvider.Name.READ_PERM;
-  }
-
-  /**
-   * Initialize the components based on name.  Note, if using <code>INIT_FIRST_COMPONENTS</code> or <code>INIT_LAST_COMPONENTS</code>,
-   * then the {@link DebugComponent} will always occur last.  If this is not desired, then one must explicitly declare all components using
-   * the <code>INIT_COMPONENTS</code> syntax.
-   */
-  @Override
-  @SuppressWarnings("unchecked")
-  public void inform(SolrCore core)
-  {
-    this.core = core;
-    Set<String> missing = new HashSet<>();
-    List<String> c = (List<String>) initArgs.get(INIT_COMPONENTS);
-    missing.addAll(core.getSearchComponents().checkContains(c));
-    List<String> first = (List<String>) initArgs.get(INIT_FIRST_COMPONENTS);
-    missing.addAll(core.getSearchComponents().checkContains(first));
-    List<String> last = (List<String>) initArgs.get(INIT_LAST_COMPONENTS);
-    missing.addAll(core.getSearchComponents().checkContains(last));
-    if (!missing.isEmpty()) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-        "Missing SearchComponents named : " + missing);
-    if (c != null && (first != null || last != null)) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-        "First/Last components only valid if you do not declare 'components'");
-
-    if (shfInfo == null) {
-      shardHandlerFactory = core.getCoreContainer().getShardHandlerFactory();
-    } else {
-      shardHandlerFactory = core.createInitInstance(shfInfo, ShardHandlerFactory.class, null, null);
-      core.addCloseHook(new CloseHook() {
-        @Override
-        public void preClose(SolrCore core) {
-          shardHandlerFactory.close();
-        }
-
-        @Override
-        public void postClose(SolrCore core) {
-        }
-      });
-    }
-
-  }
-
-  private void initComponents() {
-    Object declaredComponents = initArgs.get(INIT_COMPONENTS);
-    List<String> first = (List<String>) initArgs.get(INIT_FIRST_COMPONENTS);
-    List<String> last  = (List<String>) initArgs.get(INIT_LAST_COMPONENTS);
-
-    List<String> list = null;
-    boolean makeDebugLast = true;
-    if( declaredComponents == null ) {
-      // Use the default component list
-      list = getDefaultComponents();
-
-      if( first != null ) {
-        List<String> clist = first;
-        clist.addAll( list );
-        list = clist;
-      }
-
-      if( last != null ) {
-        list.addAll( last );
-      }
-    }
-    else {
-      list = (List<String>)declaredComponents;
-      if( first != null || last != null ) {
-        throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
-            "First/Last components only valid if you do not declare 'components'");
-      }
-      makeDebugLast = false;
-    }
-
-    // Build the component list
-    List<SearchComponent> components = new ArrayList<>(list.size());
-    DebugComponent dbgCmp = null;
-    for(String c : list){
-      SearchComponent comp = core.getSearchComponent( c );
-      if (comp instanceof DebugComponent && makeDebugLast == true){
-        dbgCmp = (DebugComponent) comp;
-      } else {
-        components.add(comp);
-        log.debug("Adding  component:{}", comp);
-      }
-    }
-    if (makeDebugLast == true && dbgCmp != null){
-      components.add(dbgCmp);
-      log.debug("Adding  debug component:{}", dbgCmp);
-    }
-    this.components = components;
-  }
-
-  public List<SearchComponent> getComponents() {
-    List<SearchComponent> result = components;  // volatile read
-    if (result == null) {
-      synchronized (this) {
-        if (components == null) {
-          initComponents();
-        }
-        result = components;
-      }
-    }
-    return result;
-  }
-
-  private ShardHandler getAndPrepShardHandler(SolrQueryRequest req, ResponseBuilder rb) {
-    ShardHandler shardHandler = null;
-
-    CoreContainer cc = req.getCore().getCoreContainer();
-    boolean isZkAware = cc.isZooKeeperAware();
-    rb.isDistrib = req.getParams().getBool(DISTRIB, isZkAware);
-    if (!rb.isDistrib) {
-      // for back compat, a shards param with URLs like localhost:8983/solr will mean that this
-      // search is distributed.
-      final String shards = req.getParams().get(ShardParams.SHARDS);
-      rb.isDistrib = ((shards != null) && (shards.indexOf('/') > 0));
-    }
-    
-    if (rb.isDistrib) {
-      shardHandler = shardHandlerFactory.getShardHandler();
-      shardHandler.prepDistributed(rb);
-      if (!rb.isDistrib) {
-        shardHandler = null; // request is not distributed after all and so the shard handler is not needed
-      }
-    }
-
-    if (isZkAware) {
-      String shardsTolerant = req.getParams().get(ShardParams.SHARDS_TOLERANT);
-      boolean requireZkConnected = shardsTolerant != null && shardsTolerant.equals(ShardParams.REQUIRE_ZK_CONNECTED);
-      ZkController zkController = cc.getZkController();
-      boolean zkConnected = zkController != null && ! zkController.getZkClient().getConnectionManager().isLikelyExpired();
-      if (requireZkConnected && false == zkConnected) {
-        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "ZooKeeper is not connected");
-      } else {
-        NamedList<Object> headers = rb.rsp.getResponseHeader();
-        if (headers != null) {
-          headers.add("zkConnected", zkConnected);
-        }
-      }
-    }
-
-    return shardHandler;
-  }
-  
-  @Override
-  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
-  {
-    List<SearchComponent> components  = getComponents();
-    ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
-    if (rb.requestInfo != null) {
-      rb.requestInfo.setResponseBuilder(rb);
-    }
-
-    boolean dbg = req.getParams().getBool(CommonParams.DEBUG_QUERY, false);
-    rb.setDebug(dbg);
-    if (dbg == false){//if it's true, we are doing everything anyway.
-      SolrPluginUtils.getDebugInterests(req.getParams().getParams(CommonParams.DEBUG), rb);
-    }
-
-    final RTimerTree timer = rb.isDebug() ? req.getRequestTimer() : null;
-
-    final ShardHandler shardHandler1 = getAndPrepShardHandler(req, rb); // creates a ShardHandler object only if it's needed
-    
-    if (timer == null) {
-      // non-debugging prepare phase
-      for( SearchComponent c : components ) {
-        c.prepare(rb);
-      }
-    } else {
-      // debugging prepare phase
-      RTimerTree subt = timer.sub( "prepare" );
-      for( SearchComponent c : components ) {
-        rb.setTimer( subt.sub( c.getName() ) );
-        c.prepare(rb);
-        rb.getTimer().stop();
-      }
-      subt.stop();
-    }
-
-    if (!rb.isDistrib) {
-      // a normal non-distributed request
-
-      long timeAllowed = req.getParams().getLong(CommonParams.TIME_ALLOWED, -1L);
-      if (timeAllowed > 0L) {
-        SolrQueryTimeoutImpl.set(timeAllowed);
-      }
-      try {
-        // The semantics of debugging vs not debugging are different enough that
-        // it makes sense to have two control loops
-        if(!rb.isDebug()) {
-          // Process
-          for( SearchComponent c : components ) {
-            c.process(rb);
-          }
-        }
-        else {
-          // Process
-          RTimerTree subt = timer.sub( "process" );
-          for( SearchComponent c : components ) {
-            rb.setTimer( subt.sub( c.getName() ) );
-            c.process(rb);
-            rb.getTimer().stop();
-          }
-          subt.stop();
-
-          // add the timing info
-          if (rb.isDebugTimings()) {
-            rb.addDebugInfo("timing", timer.asNamedList() );
-          }
-        }
-      } catch (ExitableDirectoryReader.ExitingReaderException ex) {
-        log.warn( "Query: " + req.getParamString() + "; " + ex.getMessage());
-        SolrDocumentList r = (SolrDocumentList) rb.rsp.getResponse();
-        if(r == null)
-          r = new SolrDocumentList();
-        r.setNumFound(0);
-        rb.rsp.addResponse(r);
-        if(rb.isDebug()) {
-          NamedList debug = new NamedList();
-          debug.add("explain", new NamedList());
-          rb.rsp.add("debug", debug);
-        }
-        rb.rsp.getResponseHeader().add(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, Boolean.TRUE);
-      } finally {
-        SolrQueryTimeoutImpl.reset();
-      }
-    } else {
-      // a distributed request
-
-      if (rb.outgoing == null) {
-        rb.outgoing = new LinkedList<>();
-      }
-      rb.finished = new ArrayList<>();
-
-      int nextStage = 0;
-      do {
-        rb.stage = nextStage;
-        nextStage = ResponseBuilder.STAGE_DONE;
-
-        // call all components
-        for( SearchComponent c : components ) {
-          // the next stage is the minimum of what all components report
-          nextStage = Math.min(nextStage, c.distributedProcess(rb));
-        }
-
-
-        // check the outgoing queue and send requests
-        while (rb.outgoing.size() > 0) {
-
-          // submit all current request tasks at once
-          while (rb.outgoing.size() > 0) {
-            ShardRequest sreq = rb.outgoing.remove(0);
-            sreq.actualShards = sreq.shards;
-            if (sreq.actualShards==ShardRequest.ALL_SHARDS) {
-              sreq.actualShards = rb.shards;
-            }
-            sreq.responses = new ArrayList<>(sreq.actualShards.length); // presume we'll get a response from each shard we send to
-
-            // TODO: map from shard to address[]
-            for (String shard : sreq.actualShards) {
-              ModifiableSolrParams params = new ModifiableSolrParams(sreq.params);
-              params.remove(ShardParams.SHARDS);      // not a top-level request
-              params.set(DISTRIB, "false");               // not a top-level request
-              params.remove("indent");
-              params.remove(CommonParams.HEADER_ECHO_PARAMS);
-              params.set(ShardParams.IS_SHARD, true);  // a sub (shard) request
-              params.set(ShardParams.SHARDS_PURPOSE, sreq.purpose);
-              params.set(ShardParams.SHARD_URL, shard); // so the shard knows what was asked
-              if (rb.requestInfo != null) {
-                // we could try and detect when this is needed, but it could be tricky
-                params.set("NOW", Long.toString(rb.requestInfo.getNOW().getTime()));
-              }
-              String shardQt = params.get(ShardParams.SHARDS_QT);
-              if (shardQt != null) {
-                params.set(CommonParams.QT, shardQt);
-              } else {
-                // for distributed queries that don't include shards.qt, use the original path
-                // as the default but operators need to update their luceneMatchVersion to enable
-                // this behavior since it did not work this way prior to 5.1
-                String reqPath = (String) req.getContext().get(PATH);
-                if (!"/select".equals(reqPath)) {
-                  params.set(CommonParams.QT, reqPath);
-                } // else if path is /select, then the qt gets passed thru if set
-              }
-              shardHandler1.submit(sreq, shard, params);
-            }
-          }
-
-
-          // now wait for replies, but if anyone puts more requests on
-          // the outgoing queue, send them out immediately (by exiting
-          // this loop)
-          boolean tolerant = ShardParams.getShardsTolerantAsBool(rb.req.getParams());
-          while (rb.outgoing.size() == 0) {
-            ShardResponse srsp = tolerant ? 
-                shardHandler1.takeCompletedIncludingErrors():
-                shardHandler1.takeCompletedOrError();
-            if (srsp == null) break;  // no more requests to wait for
-
-            // Was there an exception?  
-            if (srsp.getException() != null) {
-              // If things are not tolerant, abort everything and rethrow
-              if(!tolerant) {
-                shardHandler1.cancelAll();
-                if (srsp.getException() instanceof SolrException) {
-                  throw (SolrException)srsp.getException();
-                } else {
-                  throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, srsp.getException());
-                }
-              } else {
-                if(rsp.getResponseHeader().get(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY) == null) {
-                  rsp.getResponseHeader().add(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY, Boolean.TRUE);
-                }
-              }
-            }
-
-            rb.finished.add(srsp.getShardRequest());
-
-            // let the components see the responses to the request
-            for(SearchComponent c : components) {
-              c.handleResponses(rb, srsp.getShardRequest());
-            }
-          }
-        }
-
-        for(SearchComponent c : components) {
-          c.finishStage(rb);
-        }
-
-        // we are done when the next stage is MAX_VALUE
-      } while (nextStage != Integer.MAX_VALUE);
-    }
-    
-    // SOLR-5550: still provide shards.info if requested even for a short circuited distrib request
-    if(!rb.isDistrib && req.getParams().getBool(ShardParams.SHARDS_INFO, false) && rb.shortCircuitedURL != null) {  
-      NamedList<Object> shardInfo = new SimpleOrderedMap<Object>();
-      SimpleOrderedMap<Object> nl = new SimpleOrderedMap<Object>();        
-      if (rsp.getException() != null) {
-        Throwable cause = rsp.getException();
-        if (cause instanceof SolrServerException) {
-          cause = ((SolrServerException)cause).getRootCause();
-        } else {
-          if (cause.getCause() != null) {
-            cause = cause.getCause();
-          }          
-        }
-        nl.add("error", cause.toString() );
-        StringWriter trace = new StringWriter();
-        cause.printStackTrace(new PrintWriter(trace));
-        nl.add("trace", trace.toString() );
-      }
-      else {
-        nl.add("numFound", rb.getResults().docList.matches());
-        nl.add("maxScore", rb.getResults().docList.maxScore());
-      }
-      nl.add("shardAddress", rb.shortCircuitedURL);
-      nl.add("time", req.getRequestTimer().getTime()); // elapsed time of this request so far
-      
-      int pos = rb.shortCircuitedURL.indexOf("://");        
-      String shardInfoName = pos != -1 ? rb.shortCircuitedURL.substring(pos+3) : rb.shortCircuitedURL;
-      shardInfo.add(shardInfoName, nl);   
-      rsp.getValues().add(ShardParams.SHARDS_INFO,shardInfo);            
-    }
-  }
-
-  //////////////////////// SolrInfoMBeans methods //////////////////////
-
-  @Override
-  public String getDescription() {
-    StringBuilder sb = new StringBuilder();
-    sb.append("Search using components: ");
-    if( components != null ) {
-      for(SearchComponent c : components){
-        sb.append(c.getName());
-        sb.append(",");
-      }
-    }
-    return sb.toString();
-  }
-
-  @Override
-  public Boolean registerV2() {
-    return Boolean.TRUE;
-  }
-}
-
-
-// TODO: generalize how a comm component can fit into search component framework
-// TODO: statics should be per-core singletons
-
-

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java b/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java
deleted file mode 100644
index 2935aa1..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardDoc.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import org.apache.lucene.search.FieldDoc;
-import org.apache.solr.common.util.NamedList;
-
-public class ShardDoc extends FieldDoc {
-  public String shard;
-  public String shardAddress;  // TODO
-  
-  public int orderInShard;
-    // the position of this doc within the shard... this can be used
-    // to short-circuit comparisons if the shard is equal, and can
-    // also be used to break ties within the same shard.
-
-  public Object id;
-    // this is currently the uniqueKeyField but
-    // may be replaced with internal docid in a future release.
-
-  public NamedList sortFieldValues;
-  // sort field values for *all* docs in a particular shard.
-  // this doc's values are in position orderInShard
-
-  // TODO: store the SolrDocument here?
-  // Store the order in the merged list for lookup when getting stored fields?
-  // (other components need this ordering to store data in order, like highlighting)
-  // but we shouldn't expose uniqueKey (have a map by it) until the stored-field
-  // retrieval stage.
-
-  public int positionInResponse;
-  // the ordinal position in the merged response arraylist  
-
-  public ShardDoc(float score, Object[] fields, Object uniqueId, String shard) {
-      super(-1, score, fields);
-      this.id = uniqueId;
-      this.shard = shard;
-  }
-
-  public ShardDoc() {
-    super(-1, Float.NaN);
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-
-    ShardDoc shardDoc = (ShardDoc) o;
-
-    if (id != null ? !id.equals(shardDoc.id) : shardDoc.id != null) return false;
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    return id != null ? id.hashCode() : 0;
-  }
-
-  @Override
-  public String toString(){
-    return "id="+id
-            +" ,score="+score
-            +" ,shard="+shard
-            +" ,orderInShard="+orderInShard
-            +" ,positionInResponse="+positionInResponse
-            +" ,sortFieldValues="+sortFieldValues;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShardFieldSortedHitQueue.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardFieldSortedHitQueue.java b/solr/core/src/java/org/apache/solr/handler/component/ShardFieldSortedHitQueue.java
deleted file mode 100644
index ef0e624..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardFieldSortedHitQueue.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-import org.apache.lucene.search.FieldComparator;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.SortField;
-import org.apache.lucene.util.PriorityQueue;
-import org.apache.solr.common.SolrException;
-
-import static org.apache.solr.common.SolrException.ErrorCode.SERVER_ERROR;
-
-// used by distributed search to merge results.
-public class ShardFieldSortedHitQueue extends PriorityQueue<ShardDoc> {
-
-  /** Stores a comparator corresponding to each field being sorted by */
-  protected Comparator<ShardDoc>[] comparators;
-
-  /** Stores the sort criteria being used. */
-  protected SortField[] fields;
-
-  /** The order of these fieldNames should correspond to the order of sort field values retrieved from the shard */
-  protected List<String> fieldNames = new ArrayList<>();
-
-  public ShardFieldSortedHitQueue(SortField[] fields, int size, IndexSearcher searcher) {
-    super(size);
-    final int n = fields.length;
-    //noinspection unchecked
-    comparators = new Comparator[n];
-    this.fields = new SortField[n];
-    for (int i = 0; i < n; ++i) {
-
-      // keep track of the named fields
-      SortField.Type type = fields[i].getType();
-      if (type!=SortField.Type.SCORE && type!=SortField.Type.DOC) {
-        fieldNames.add(fields[i].getField());
-      }
-
-      String fieldname = fields[i].getField();
-      comparators[i] = getCachedComparator(fields[i], searcher);
-
-     if (fields[i].getType() == SortField.Type.STRING) {
-        this.fields[i] = new SortField(fieldname, SortField.Type.STRING,
-            fields[i].getReverse());
-      } else {
-        this.fields[i] = new SortField(fieldname, fields[i].getType(),
-            fields[i].getReverse());
-      }
-
-      //System.out.println("%%%%%%%%%%%%%%%%%% got "+fields[i].getType() +"   for "+ fieldname +"  fields[i].getReverse(): "+fields[i].getReverse());
-    }
-  }
-
-  @Override
-  protected boolean lessThan(ShardDoc docA, ShardDoc docB) {
-    // If these docs are from the same shard, then the relative order
-    // is how they appeared in the response from that shard.    
-    if (docA.shard == docB.shard) {
-      // if docA has a smaller position, it should be "larger" so it
-      // comes before docB.
-      // This will handle sorting by docid within the same shard
-
-      // comment this out to test comparators.
-      return !(docA.orderInShard < docB.orderInShard);
-    }
-
-
-    // run comparators
-    final int n = comparators.length;
-    int c = 0;
-    for (int i = 0; i < n && c == 0; i++) {
-      c = (fields[i].getReverse()) ? comparators[i].compare(docB, docA)
-          : comparators[i].compare(docA, docB);
-    }
-
-    // solve tiebreaks by comparing shards (similar to using docid)
-    // smaller docid's beat larger ids, so reverse the natural ordering
-    if (c == 0) {
-      c = -docA.shard.compareTo(docB.shard);
-    }
-
-    return c < 0;
-  }
-
-  Comparator<ShardDoc> getCachedComparator(SortField sortField, IndexSearcher searcher) {
-    SortField.Type type = sortField.getType();
-    if (type == SortField.Type.SCORE) {
-      return (o1, o2) -> {
-        final float f1 = o1.score;
-        final float f2 = o2.score;
-        if (f1 < f2)
-          return -1;
-        if (f1 > f2)
-          return 1;
-        return 0;
-      };
-    } else if (type == SortField.Type.REWRITEABLE) {
-      try {
-        sortField = sortField.rewrite(searcher);
-      } catch (IOException e) {
-        throw new SolrException(SERVER_ERROR, "Exception rewriting sort field " + sortField, e);
-      }
-    }
-    return comparatorFieldComparator(sortField);
-  }
-
-  abstract class ShardComparator implements Comparator<ShardDoc> {
-    final SortField sortField;
-    final String fieldName;
-    final int fieldNum;
-
-    public ShardComparator(SortField sortField) {
-      this.sortField = sortField;
-      this.fieldName = sortField.getField();
-      int fieldNum = 0;
-      for (int i=0; i<fieldNames.size(); i++) {
-        if (fieldNames.get(i).equals(fieldName)) {
-          fieldNum = i;
-          break;
-        }
-      }
-      this.fieldNum = fieldNum;
-    }
-
-    Object sortVal(ShardDoc shardDoc) {
-      assert(shardDoc.sortFieldValues.getName(fieldNum).equals(fieldName));
-      List lst = (List)shardDoc.sortFieldValues.getVal(fieldNum);
-      return lst.get(shardDoc.orderInShard);
-    }
-  }
-
-  Comparator<ShardDoc> comparatorFieldComparator(SortField sortField) {
-    final FieldComparator fieldComparator = sortField.getComparator(0, 0);
-    return new ShardComparator(sortField) {
-      // Since the PriorityQueue keeps the biggest elements by default,
-      // we need to reverse the field compare ordering so that the
-      // smallest elements are kept instead of the largest... hence
-      // the negative sign.
-      @Override
-      public int compare(final ShardDoc o1, final ShardDoc o2) {
-        //noinspection unchecked
-        return -fieldComparator.compareValues(sortVal(o1), sortVal(o2));
-      }
-    };
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShardHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/ShardHandler.java
deleted file mode 100644
index 4c89806..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-import org.apache.solr.common.params.ModifiableSolrParams;
-
-public abstract class ShardHandler {
-  public abstract void prepDistributed(ResponseBuilder rb);
-  public abstract void submit(ShardRequest sreq, String shard, ModifiableSolrParams params);
-  public abstract ShardResponse takeCompletedIncludingErrors();
-  public abstract ShardResponse takeCompletedOrError();
-  public abstract void cancelAll();
-  public abstract ShardHandlerFactory getShardHandlerFactory();
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
deleted file mode 100644
index 49b7679..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardHandlerFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-import com.google.common.collect.ImmutableMap;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.core.PluginInfo;
-import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.util.plugin.PluginInfoInitialized;
-
-import java.util.Collections;
-import java.util.Locale;
-
-public abstract class ShardHandlerFactory {
-
-  public abstract ShardHandler getShardHandler();
-
-  public abstract void close();
-
-  /**
-   * Create a new ShardHandlerFactory instance
-   * @param info    a PluginInfo object defining which type to create.  If null,
-   *                the default {@link HttpShardHandlerFactory} will be used
-   * @param loader  a SolrResourceLoader used to find the ShardHandlerFactory classes
-   * @return a new, initialized ShardHandlerFactory instance
-   */
-  public static ShardHandlerFactory newInstance(PluginInfo info, SolrResourceLoader loader) {
-    if (info == null)
-      info = DEFAULT_SHARDHANDLER_INFO;
-
-    try {
-      ShardHandlerFactory shf = loader.findClass(info.className, ShardHandlerFactory.class).newInstance();
-      if (PluginInfoInitialized.class.isAssignableFrom(shf.getClass()))
-        PluginInfoInitialized.class.cast(shf).init(info);
-      return shf;
-    }
-    catch (Exception e) {
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-          String.format(Locale.ROOT, "Error instantiating shardHandlerFactory class [%s]: %s",
-                        info.className, e.getMessage()), e);
-    }
-
-  }
-
-  public static final PluginInfo DEFAULT_SHARDHANDLER_INFO =
-      new PluginInfo("shardHandlerFactory", ImmutableMap.of("class", HttpShardHandlerFactory.class.getName()),
-          null, Collections.<PluginInfo>emptyList());
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShardRequest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardRequest.java b/solr/core/src/java/org/apache/solr/handler/component/ShardRequest.java
deleted file mode 100644
index f7c05d2..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardRequest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import org.apache.solr.common.params.ModifiableSolrParams;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-// todo... when finalized make accessors
-public class ShardRequest {
-  public final static String[] ALL_SHARDS = null;
-
-  public final static int PURPOSE_PRIVATE         = 0x01;
-  public final static int PURPOSE_GET_TERM_DFS    = 0x02;
-  public final static int PURPOSE_GET_TOP_IDS     = 0x04;
-  public final static int PURPOSE_REFINE_TOP_IDS  = 0x08;
-  public final static int PURPOSE_GET_FACETS      = 0x10;
-  public final static int PURPOSE_REFINE_FACETS   = 0x20;
-  public final static int PURPOSE_GET_FIELDS      = 0x40;
-  public final static int PURPOSE_GET_HIGHLIGHTS  = 0x80;
-  public final static int PURPOSE_GET_DEBUG       =0x100;
-  public final static int PURPOSE_GET_STATS       =0x200;
-  public final static int PURPOSE_GET_TERMS       =0x400;
-  public final static int PURPOSE_GET_TOP_GROUPS  =0x800;
-  public final static int PURPOSE_GET_MLT_RESULTS =0x1000;
-  public final static int PURPOSE_REFINE_PIVOT_FACETS =0x2000;
-  public final static int PURPOSE_SET_TERM_STATS  =0x4000;
-  public final static int PURPOSE_GET_TERM_STATS  = 0x8000;
-
-  public int purpose;  // the purpose of this request
-
-  public String[] shards;  // the shards this request should be sent to, null for all
-
-  public ModifiableSolrParams params;
-
-
-  /** list of responses... filled out by framework */
-  public List<ShardResponse> responses = new ArrayList<>();
-
-  /** actual shards to send the request to, filled out by framework */
-  public String[] actualShards;
-
-  /** may be null */
-  public String nodeName;
-
-  // TODO: one could store a list of numbers to correlate where returned docs
-  // go in the top-level response rather than looking up by id...
-  // this would work well if we ever transitioned to using internal ids and
-  // didn't require a uniqueId
-
-  @Override
-  public String toString() {
-    return "ShardRequest:{params=" + params
-            + ", purpose=" + Integer.toHexString(purpose)
-            + ", nResponses =" + responses.size()
-            + "}";
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java b/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java
deleted file mode 100644
index 5da721c..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShardResponse.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-import org.apache.solr.client.solrj.SolrResponse;
-import org.apache.solr.common.SolrException;
-
-public final class ShardResponse {
-  private ShardRequest req;
-  private String shard;
-  private String nodeName;
-  private String shardAddress;  // the specific shard that this response was received from
-  private int rspCode;
-  private Throwable exception;
-  private SolrResponse rsp;
-
-  @Override
-  public String toString() {
-    return "ShardResponse:{shard="+shard+",shardAddress="+shardAddress
-            +"\n\trequest=" + req
-            +"\n\tresponse=" + rsp
-            + (exception==null ? "" : "\n\texception="+ SolrException.toStr(exception))
-            +"\n}";
-  }
-
-  public Throwable getException()
-  {
-    return exception;
-  }
-
-  public ShardRequest getShardRequest()
-  {
-    return req;
-  }
-
-  public SolrResponse getSolrResponse()
-  {
-    return rsp;
-  }
-
-  public String getShard()
-  {
-    return shard;
-  }
-
-  public String getNodeName()
-  {
-    return nodeName;
-  }
-  
-  public void setShardRequest(ShardRequest rsp)
-  {
-    this.req = rsp;
-  }
-
-  public void setSolrResponse(SolrResponse rsp)
-  {
-    this.rsp = rsp;
-  }
-
-  void setShard(String shard)
-  {
-    this.shard = shard;
-  }
-
-  void setException(Throwable exception)
-  {
-    this.exception = exception;
-  }
-
-  void setResponseCode(int rspCode)
-  {
-    this.rspCode = rspCode;
-  }
-  
-  void setNodeName(String nodeName) 
-  {
-    this.nodeName = nodeName;
-  }
-
-  /** What was the shard address that returned this response.  Example:  "http://localhost:8983/solr" */
-  public String getShardAddress() { return this.shardAddress; }
-
-  void setShardAddress(String addr) { this.shardAddress = addr; }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/ShufflingReplicaListTransformer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ShufflingReplicaListTransformer.java b/solr/core/src/java/org/apache/solr/handler/component/ShufflingReplicaListTransformer.java
deleted file mode 100644
index 428e348..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/ShufflingReplicaListTransformer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-
-class ShufflingReplicaListTransformer implements ReplicaListTransformer {
-
-  private final Random r;
-
-  public ShufflingReplicaListTransformer(Random r)
-  {
-    this.r = r;
-  }
-
-  public void transform(List<?> choices)
-  {
-    if (choices.size() > 1) {
-      Collections.shuffle(choices, r);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/SortedDateStatsValues.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SortedDateStatsValues.java b/solr/core/src/java/org/apache/solr/handler/component/SortedDateStatsValues.java
deleted file mode 100644
index 0df45c7..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/SortedDateStatsValues.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.handler.component;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.index.SortedNumericDocValues;
-import org.apache.lucene.util.BytesRef;
-import org.apache.solr.common.util.NamedList;
-
-public class SortedDateStatsValues implements StatsValues {
-
-  private final DateStatsValues dsv;
-  private final String fieldName;
-  private SortedNumericDocValues sndv;
-
-
-  public SortedDateStatsValues(DateStatsValues dsv, StatsField field) {
-    this.dsv = dsv;
-    this.fieldName = field.getSchemaField().getName();
-  }
-
-  @Override
-  public void accumulate(NamedList stv) {
-    dsv.accumulate(stv);
-  }
-
-  @Override
-  public void accumulate(int docId) throws IOException {
-    if (!sndv.advanceExact(docId)) {
-      missing();
-    } else {
-      for (int i = 0 ; i < sndv.docValueCount(); i++) {
-        dsv.accumulate(new Date(sndv.nextValue()), 1);
-      }
-    }
-
-  }
-
-  @Override
-  public void accumulate(BytesRef value, int count) {
-    dsv.accumulate(value, count);
-  }
-
-  @Override
-  public void missing() {
-    dsv.missing();
-  }
-
-  @Override
-  public void addMissing(int count) {
-    dsv.addMissing(count);
-  }
-
-  @Override
-  public void addFacet(String facetName, Map<String,StatsValues> facetValues) {
-    dsv.addFacet(facetName, facetValues);
-  }
-
-  @Override
-  public NamedList<?> getStatsValues() {
-    return dsv.getStatsValues();
-  }
-
-  @Override
-  public void setNextReader(LeafReaderContext ctx) throws IOException {
-    sndv = DocValues.getSortedNumeric(ctx.reader(), fieldName);
-    assert sndv != null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/SortedNumericStatsValues.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SortedNumericStatsValues.java b/solr/core/src/java/org/apache/solr/handler/component/SortedNumericStatsValues.java
deleted file mode 100644
index 007fb28..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/SortedNumericStatsValues.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.LeafReaderContext;
-import org.apache.lucene.index.SortedNumericDocValues;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NumericUtils;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.schema.NumberType;
-
-public class SortedNumericStatsValues implements StatsValues {
-  
-  private final NumericStatsValues nsv;
-  private final String fieldName;
-  private final NumberType numberType;
-  private SortedNumericDocValues sndv;
-  
-  
-  public SortedNumericStatsValues(NumericStatsValues nsv, StatsField field) {
-    this.nsv = nsv;
-    this.fieldName = field.getSchemaField().getName();
-    this.numberType = field.getSchemaField().getType().getNumberType();
-  }
-
-  @Override
-  public void accumulate(NamedList stv) {
-    nsv.accumulate(stv);
-  }
-  
-  @Override
-  public void accumulate(int docId) throws IOException {
-    if (!sndv.advanceExact(docId)) {
-      missing();
-    } else {
-      for (int i = 0 ; i < sndv.docValueCount(); i++) {
-        nsv.accumulate(toCorrectType(sndv.nextValue()), 1);
-      }
-    }
-    
-  }
-
-  private Number toCorrectType(long value) {
-    switch (numberType) {
-      case INTEGER:
-      case LONG:
-        return value;
-      case FLOAT:
-        return NumericUtils.sortableIntToFloat((int)value);
-      case DOUBLE:
-        return NumericUtils.sortableLongToDouble(value);
-      default:
-        throw new AssertionError("Unsupported number type");
-    }
-  }
-
-  @Override
-  public void accumulate(BytesRef value, int count) {
-    nsv.accumulate(value, count);
-  }
-
-  @Override
-  public void missing() {
-    nsv.missing();
-  }
-
-  @Override
-  public void addMissing(int count) {
-    nsv.addMissing(count);
-  }
-
-  @Override
-  public void addFacet(String facetName, Map<String,StatsValues> facetValues) {
-    nsv.addFacet(facetName, facetValues);
-  }
-
-  @Override
-  public NamedList<?> getStatsValues() {
-    return nsv.getStatsValues();
-  }
-
-  @Override
-  public void setNextReader(LeafReaderContext ctx) throws IOException {
-    sndv = DocValues.getSortedNumeric(ctx.reader(), fieldName);
-    assert sndv != null;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0ae21ad0/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java b/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
deleted file mode 100644
index 8814953..0000000
--- a/solr/core/src/java/org/apache/solr/handler/component/SpatialHeatmapFacets.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.handler.component;
-
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.apache.solr.common.params.FacetParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.search.DocSet;
-import org.apache.solr.search.facet.FacetHeatmap;
-import org.apache.solr.search.facet.FacetMerger;
-import org.apache.solr.search.facet.FacetRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** A 2D spatial faceting summary of a rectangular region. Used by {@link org.apache.solr.handler.component.FacetComponent}
- * and {@link org.apache.solr.request.SimpleFacets}.
- * @see FacetHeatmap
- */
-public class SpatialHeatmapFacets {
-  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
-  //underneath facet_counts we put this here:
-  public static final String RESPONSE_KEY = "facet_heatmaps";
-
-  /** Called by {@link org.apache.solr.request.SimpleFacets} to compute heatmap facets. */
-  public static NamedList<Object> getHeatmapForField(String fieldKey, String fieldName, ResponseBuilder rb, SolrParams params, DocSet docSet) throws IOException {
-    final FacetRequest facetRequest = createHeatmapRequest(fieldKey, fieldName, rb, params);
-    return (NamedList) facetRequest.process(rb.req, docSet);
-  }
-
-  private static FacetRequest createHeatmapRequest(String fieldKey, String fieldName, ResponseBuilder rb, SolrParams params) {
-    Map<String, Object> jsonFacet = new HashMap<>();
-    jsonFacet.put("type", "heatmap");
-    jsonFacet.put("field", fieldName);
-    // jsonFacets has typed values, unlike SolrParams which is all string
-    jsonFacet.put(FacetHeatmap.GEOM_PARAM, params.getFieldParam(fieldKey, FacetParams.FACET_HEATMAP_GEOM));
-    jsonFacet.put(FacetHeatmap.LEVEL_PARAM, params.getFieldInt(fieldKey, FacetParams.FACET_HEATMAP_LEVEL));
-    jsonFacet.put(FacetHeatmap.DIST_ERR_PCT_PARAM, params.getFieldDouble(fieldKey, FacetParams.FACET_HEATMAP_DIST_ERR_PCT));
-    jsonFacet.put(FacetHeatmap.DIST_ERR_PARAM, params.getFieldDouble(fieldKey, FacetParams.FACET_HEATMAP_DIST_ERR));
-    jsonFacet.put(FacetHeatmap.MAX_CELLS_PARAM, params.getFieldInt(fieldKey, FacetParams.FACET_HEATMAP_MAX_CELLS));
-    jsonFacet.put(FacetHeatmap.FORMAT_PARAM, params.getFieldParam(fieldKey, FacetParams.FACET_HEATMAP_FORMAT));
-
-    return FacetRequest.parseOneFacetReq(rb.req, jsonFacet);
-  }
-
-  //
-  // Distributed Support
-  //
-
-  /** Parses request to "HeatmapFacet" instances. */
-  public static LinkedHashMap<String,HeatmapFacet> distribParse(SolrParams params, ResponseBuilder rb) {
-    final LinkedHashMap<String, HeatmapFacet> heatmapFacets = new LinkedHashMap<>();
-    final String[] heatmapFields = params.getParams(FacetParams.FACET_HEATMAP);
-    if (heatmapFields != null) {
-      for (String heatmapField : heatmapFields) {
-        HeatmapFacet facet = new HeatmapFacet(rb, heatmapField);
-        heatmapFacets.put(facet.getKey(), facet);
-      }
-    }
-    return heatmapFacets;
-  }
-
-  /** Called by FacetComponent's impl of
-   * {@link org.apache.solr.handler.component.SearchComponent#modifyRequest(ResponseBuilder, SearchComponent, ShardRequest)}. */
-  public static void distribModifyRequest(ShardRequest sreq, LinkedHashMap<String, HeatmapFacet> heatmapFacets) {
-    // Set the format to PNG because it's compressed and it's the only format we have code to read at the moment.
-    // We re-write the facet.heatmap list with PNG format in local-params where it has highest precedence.
-
-    //Remove existing heatmap field param vals; we will rewrite
-    sreq.params.remove(FacetParams.FACET_HEATMAP);
-    for (HeatmapFacet facet : heatmapFacets.values()) {
-      //add heatmap field param
-      ModifiableSolrParams newLocalParams = new ModifiableSolrParams();
-      if (facet.localParams != null) {
-        newLocalParams.add(facet.localParams);
-      }
-      // Set format to PNG; it's the only one we parse
-      newLocalParams.set(FacetParams.FACET_HEATMAP_FORMAT, FacetHeatmap.FORMAT_PNG);
-      sreq.params.add(FacetParams.FACET_HEATMAP,
-          newLocalParams.toLocalParamsString() + facet.facetOn);
-    }
-  }
-
-  /** Called by FacetComponent.countFacets which is in turn called by FC's impl of
-   * {@link org.apache.solr.handler.component.SearchComponent#handleResponses(ResponseBuilder, ShardRequest)}. */
-  @SuppressWarnings("unchecked")
-  public static void distribHandleResponse(LinkedHashMap<String, HeatmapFacet> heatmapFacets, NamedList srsp_facet_counts) {
-    NamedList<NamedList<Object>> facet_heatmaps = (NamedList<NamedList<Object>>) srsp_facet_counts.get(RESPONSE_KEY);
-    if (facet_heatmaps == null) {
-      return;
-    }
-    // (should the caller handle the above logic?  Arguably yes.)
-    for (Map.Entry<String, NamedList<Object>> entry : facet_heatmaps) {
-      String fieldKey = entry.getKey();
-      NamedList<Object> shardNamedList = entry.getValue();
-      final HeatmapFacet facet = heatmapFacets.get(fieldKey);
-      if (facet == null) {
-        log.error("received heatmap for field/key {} that we weren't expecting", fieldKey);
-        continue;
-      }
-      facet.jsonFacetMerger.merge(shardNamedList, null);//merge context not needed (null)
-    }
-  }
-
-
-  /** Called by FacetComponent's impl of
-   * {@link org.apache.solr.handler.component.SearchComponent#finishStage(ResponseBuilder)}. */
-  public static NamedList distribFinish(LinkedHashMap<String, HeatmapFacet> heatmapInfos, ResponseBuilder rb) {
-    NamedList<NamedList<Object>> result = new SimpleOrderedMap<>();
-    for (Map.Entry<String, HeatmapFacet> entry : heatmapInfos.entrySet()) {
-      final HeatmapFacet facet = entry.getValue();
-      result.add(entry.getKey(), (NamedList<Object>) facet.jsonFacetMerger.getMergedResult());
-    }
-    return result;
-  }
-
-  /** Goes in {@link org.apache.solr.handler.component.FacetComponent.FacetInfo#heatmapFacets}, created by
-   * {@link #distribParse(org.apache.solr.common.params.SolrParams, ResponseBuilder)}. */
-  public static class HeatmapFacet extends FacetComponent.FacetBase {
-    //note: 'public' following-suit with FacetBase & existing subclasses... though should this really be?
-
-    public FacetMerger jsonFacetMerger;
-
-    public HeatmapFacet(ResponseBuilder rb, String facetStr) {
-      super(rb, FacetParams.FACET_HEATMAP, facetStr);
-      //note: logic in super (FacetBase) is partially redundant with SimpleFacet.parseParams :-(
-      final SolrParams params = SolrParams.wrapDefaults(localParams, rb.req.getParams());
-      final FacetRequest heatmapRequest = createHeatmapRequest(getKey(), facetOn, rb, params);
-      jsonFacetMerger = heatmapRequest.createFacetMerger(null);
-    }
-  }
-
-  // Note: originally there was a lot more code here but it migrated to the JSON Facet API as "FacetHeatmap"
-
-}