@Override public DBQuery.Query buildQuery(String key, Object value) { return DBQuery.greaterThanEquals(key, value); } }
@Override public List<Alert> loadRecentOfStreams(List<String> streamIds, DateTime since, int limit) { if (streamIds == null || streamIds.isEmpty()) { return Collections.emptyList(); } final DateTime effectiveSince = (since == null ? new DateTime(0L, DateTimeZone.UTC) : since); final DBQuery.Query query = DBQuery.and( getFindAnyStreamQuery(streamIds), DBQuery.greaterThanEquals(AlertImpl.FIELD_TRIGGERED_AT, effectiveSince) ); return Collections.unmodifiableList(this.coll.find(query) .limit(limit) .sort(DBSort.desc(AlertImpl.FIELD_TRIGGERED_AT)) .toArray()); }
@Override public SortedSet<IndexRange> find(DateTime begin, DateTime end) { final DBQuery.Query query = DBQuery.or( DBQuery.and( DBQuery.notExists("start"), // "start" has been used by the old index ranges in MongoDB DBQuery.lessThanEquals(IndexRange.FIELD_BEGIN, end.getMillis()), DBQuery.greaterThanEquals(IndexRange.FIELD_END, begin.getMillis()) ), DBQuery.and( DBQuery.notExists("start"), // "start" has been used by the old index ranges in MongoDB DBQuery.lessThanEquals(IndexRange.FIELD_BEGIN, 0L), DBQuery.greaterThanEquals(IndexRange.FIELD_END, 0L) ) ); try (DBCursor<MongoIndexRange> indexRanges = collection.find(query)) { return ImmutableSortedSet.copyOf(IndexRange.COMPARATOR, (Iterator<? extends IndexRange>) indexRanges); } }
@Override public DBQuery.Query buildQuery(String key, Object value) { return DBQuery.greaterThanEquals(key, value); } }
@Override public SortedSet<IndexRange> find(DateTime begin, DateTime end) { final DBCursor<MongoIndexRange> indexRanges = collection.find( DBQuery.or( DBQuery.and( DBQuery.notExists("start"), // "start" has been used by the old index ranges in MongoDB DBQuery.lessThanEquals(IndexRange.FIELD_BEGIN, end.getMillis()), DBQuery.greaterThanEquals(IndexRange.FIELD_END, begin.getMillis()) ), DBQuery.and( DBQuery.notExists("start"), // "start" has been used by the old index ranges in MongoDB DBQuery.lessThanEquals(IndexRange.FIELD_BEGIN, 0L), DBQuery.greaterThanEquals(IndexRange.FIELD_END, 0L) ) ) ); return ImmutableSortedSet.copyOf(IndexRange.COMPARATOR, (Iterator<? extends IndexRange>) indexRanges); }
@Override public List<Alert> loadRecentOfStreams(List<String> streamIds, DateTime since, int limit) { if (streamIds == null || streamIds.isEmpty()) { return Collections.emptyList(); } final DateTime effectiveSince = (since == null ? new DateTime(0L, DateTimeZone.UTC) : since); final DBQuery.Query query = DBQuery.and( getFindAnyStreamQuery(streamIds), DBQuery.greaterThanEquals(AlertImpl.FIELD_TRIGGERED_AT, effectiveSince) ); return Collections.unmodifiableList(this.coll.find(query) .limit(limit) .sort(DBSort.desc(AlertImpl.FIELD_TRIGGERED_AT)) .toArray()); }