public void onValue(int docId, long value) { long time = tzRounding.calc(value); FacetedDateHistogramFacet.Entry entry; entry = getOrCreateEntry(value, time); try { entry.collector.collect(docId); } catch (Exception e) { throw new RuntimeException("Error creating an internal collector",e); } }
/** * Get the next timestamp, i.e. the rounded value of the next available datetime. * * @return the timestamp */ protected long nextTimestamp() { if(_keyFieldValues instanceof WithOrdinals) { // We can bypass getting the raw datetime value, and go from ord to timestamp directly (well, directly-ish) final long ts = _timestamps.get(_ordToTimestampPointers.get(_docOrds.ints[_docOrdPointer])); _docOrdPointer++; return ts; } else { // Get the next raw datetime, and if necessary, round it final long datetime = _docIter.next(); // If this datetime is less than a second after the previously-seen timestamp, it will have the same timestamp // (true because we don't support granularity less than 1 sec) if(datetime == _lastNonOrdDatetime || (datetime > _lastNonOrdTimestamp && datetime - _lastNonOrdTimestamp < 1000)) { _lastNonOrdDatetime = datetime; // _lastNonOrdTimestamp already contains right value } else { // Get and save new timestamp _lastNonOrdDatetime = datetime; _lastNonOrdTimestamp = _tzRounding.calc(datetime); } return _lastNonOrdTimestamp; } }
} else { final long newTimestamp = _tzRounding.calc(datetime); if(newTimestamp != lastTimestamp) {