apoorvprecisely commented on a change in pull request #597: [SOLR-13272] feat(facet/interval): support json facet requests for interval facet URL: https://github.com/apache/lucene-solr/pull/597#discussion_r263012361
########## File path: solr/core/src/java/org/apache/solr/search/facet/FacetIntervalProcessor.java ########## @@ -0,0 +1,154 @@ +/* + * 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.search.facet; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.apache.solr.common.SolrException; + +class FacetIntervalsProcessor extends FacetRangeProcessor { + final Object interval; + + FacetIntervalsProcessor(FacetContext fcontext, FacetIntervals freq) { + super(fcontext, freq); + if (freq.interval == null) { + throw new SolrException + (SolrException.ErrorCode.BAD_REQUEST, "Interval param is mandatory"); + } + interval = freq.interval; + } + + @Override + public void process() throws IOException { + handleDomainChanges(); + if (fcontext.facetInfo != null) { // refinement? + response = refineFacets(); + } else { + // phase#1: build list of all buckets and return full facets... + if (freq.gap != null) { + throw new SolrException + (SolrException.ErrorCode.BAD_REQUEST, "Cannot set gap and interval param together"); + } + createIntervalRangeList(); + response = getRangeCountsIndexed(); + } + } + + private void createIntervalRangeList() throws IOException { + rangeList = new ArrayList<>(); + otherList = new ArrayList<>(3); + + Comparable low = start; + Comparable loop_end = this.end; + List<Range> ranges = parseInterval(interval); + for (Range range : ranges) { + rangeList.add(range); + } + createOtherList(loop_end); Review comment: the code block that populates `otherList` doesn't use `start` and `end` I just refactored it, I can change it to what it was earlier ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
