/** * Find all nodes that intersect with the given interval and accumulate the * node identifiers (cluster ids) in a provided list. * @param interval Interval that is requested * @param clusterIds List of cluster ids that match the given interval * @throws Exception */ @Override public void accumulateClusterIdsFromInterval( TimeInterval interval, List<Integer> clusterIds, NowReference now) throws Exception { if( this.interval.intersectsWith(interval, now) ){ clusterIds.add(this.clusterId); if( null != lowChildNode ){ lowChildNode.accumulateClusterIdsFromInterval(interval, clusterIds, now); } if( null != highChildNode ){ highChildNode.accumulateClusterIdsFromInterval(interval, clusterIds, now); } } }
/** * Find all nodes that intersect with the given interval and accumulate the * node identifiers (cluster ids) in a provided list. * @param interval Interval that is requested * @param clusterIds List of cluster ids that match the given interval * @throws Exception */ @Override public void accumulateClusterIdsFromInterval( TimeInterval interval, List<Integer> clusterIds, NowReference now) throws Exception { if( this.interval.intersectsWith(interval, now) ){ clusterIds.add(this.clusterId); if( null != lowChildNode ){ lowChildNode.accumulateClusterIdsFromInterval(interval, clusterIds, now); } if( null != highChildNode ){ highChildNode.accumulateClusterIdsFromInterval(interval, clusterIds, now); } } }
if( null != docId && null != jsonInterval ){ TimeInterval docInterval = TimeInterval.fromJson(jsonInterval); if( docInterval.intersectsWith(interval, now) ){ DocumentWithInterval docWithInt = new DocumentWithInterval(docId, docInterval); results.documentWithIntervals.add(docWithInt);
@Override public SearchResults getDateIntervalsIntersectingWith(TimeInterval range, NowReference now) throws Exception { SearchResults results = new SearchResults(); CouchQuery query = new CouchQuery(); query.setViewName("date-index"); query.setIncludeDocs(false); query.setReduce(false); CouchQueryResults queryResults = atlasDesignDocument.performQuery(query); results.documentWithIntervals = new ArrayList<DocumentWithInterval>(queryResults.getRows().size()); for(JSONObject row : queryResults.getRows()){ String docId = row.optString("id"); JSONObject jsonInterval = row.optJSONObject("value"); results.intervalCount++; if( null != docId && null != jsonInterval ){ TimeInterval interval = TimeInterval.fromJson(jsonInterval); if( interval.intersectsWith(range, now) ){ DocumentWithInterval docWithInt = new DocumentWithInterval(docId, interval); results.documentWithIntervals.add(docWithInt); results.intervalMatched++; } } } return results; } }
public TimeInterval getIntersection(TimeInterval interval, NowReference now) throws Exception { if( !this.intersectsWith(interval, now) ){ return null; }; if( this.isIncludedIn(interval, now) ) { return this; } else if(interval.isIncludedIn(this, now)) { return interval; } else { long min = this.min; long max = this.getMax(now); if( min < interval.min ){ min = interval.min; }; if( max > interval.getMax(now) ){ max = interval.max; }; return new TimeInterval(min,max); } }