use of org.apache.solr.request.IntervalFacets.FacetInterval in project lucene-solr by apache.
the class TestIntervalFaceting method assertStringInterval.
private void assertStringInterval(String fieldName, String intervalStr, String expectedStart, String expectedEnd) throws SyntaxError {
SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
FacetInterval interval = new FacetInterval(f, intervalStr, new ModifiableSolrParams());
assertEquals("Expected start " + expectedStart + " but found " + f.getType().toObject(f, interval.start), interval.start, new BytesRef(f.getType().toInternal(expectedStart)));
assertEquals("Expected end " + expectedEnd + " but found " + f.getType().toObject(f, interval.end), interval.end, new BytesRef(f.getType().toInternal(expectedEnd)));
}
use of org.apache.solr.request.IntervalFacets.FacetInterval in project lucene-solr by apache.
the class TestIntervalFaceting method assertInterval.
private void assertInterval(String fieldName, String intervalStr, long[] included, long[] lowerThanStart, long[] graterThanEnd) throws SyntaxError {
SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
FacetInterval interval = new FacetInterval(f, intervalStr, new ModifiableSolrParams());
for (long l : included) {
assertEquals("Value " + l + " should be INCLUDED for interval" + interval, IntervalCompareResult.INCLUDED, interval.includes(l));
}
for (long l : lowerThanStart) {
assertEquals("Value " + l + " should be LOWER_THAN_START for inteval " + interval, IntervalCompareResult.LOWER_THAN_START, interval.includes(l));
}
for (long l : graterThanEnd) {
assertEquals("Value " + l + " should be GRATER_THAN_END for inteval " + interval, IntervalCompareResult.GREATER_THAN_END, interval.includes(l));
}
}
use of org.apache.solr.request.IntervalFacets.FacetInterval in project lucene-solr by apache.
the class IntervalFacets method accumIntervalsMulti.
private void accumIntervalsMulti(SortedSetDocValues ssdv, DocIdSetIterator disi, Bits bits) throws IOException {
// First update the ordinals in the intervals for this segment
for (FacetInterval interval : intervals) {
interval.updateContext(ssdv);
}
int doc;
while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
if (bits != null && bits.get(doc) == false) {
continue;
}
if (doc > ssdv.docID()) {
ssdv.advance(doc);
}
if (doc == ssdv.docID()) {
long currOrd;
int currentInterval = 0;
while ((currOrd = ssdv.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
boolean evaluateNextInterval = true;
while (evaluateNextInterval && currentInterval < intervals.length) {
IntervalCompareResult result = intervals[currentInterval].includes(currOrd);
switch(result) {
case INCLUDED:
/*
* Increment the current interval and move to the next one using
* the same value
*/
intervals[currentInterval].incCount();
currentInterval++;
break;
case LOWER_THAN_START:
/*
* None of the next intervals will match this value (all of them have
* higher start value). Move to the next value for this document.
*/
evaluateNextInterval = false;
break;
case GREATER_THAN_END:
/*
* Next interval may match this value
*/
currentInterval++;
break;
}
}
}
}
}
}
Aggregations