public Iterable<Metric> loadMetrics( RetentionTable table, String name, Interval interval ) { if ( session == null ) { open(); } Clause cName = QueryBuilder.eq( COL_NAME, name ); Ordering order = QueryBuilder.desc( COL_TIME ); // start inclusive, end exclusive Clause cBtm = QueryBuilder.gte( COL_TIME, interval.start() ); Clause cTop = QueryBuilder.lt( COL_TIME, interval.end() ); Statement stm = QueryBuilder.select().all().from( table.tableName() ).where( cName ).and( cBtm ).and( cTop ).orderBy( order ); final Iterator<Row> iter = session.execute( stm ).iterator(); return new Iterable<Metric>() { @Override public Iterator<Metric> iterator() { return new Iterator<Metric>() { @Override public boolean hasNext() { return iter.hasNext(); } @Override public Metric next() { Row row = iter.next(); return new Metric( row.getString( COL_NAME ), row.getLong( COL_TIME ), row.getDouble( COL_VALUE ) ); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, Ordering ordering, TimePageLink pageLink) { return findPageWithTimeSearch(searchView, clauses, Collections.singletonList(ordering), pageLink); }
protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, List<Ordering> topLevelOrderings, TimePageLink pageLink) { return findPageWithTimeSearch(searchView, clauses, topLevelOrderings, pageLink, ModelConstants.ID_PROPERTY); }
protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, List<Ordering> topLevelOrderings, TimePageLink pageLink, String idColumn) { return findListByStatement(buildQuery(searchView, clauses, topLevelOrderings, pageLink, idColumn)); }
public static Where buildQuery(String searchView, List<Clause> clauses, Ordering order, TimePageLink pageLink, String idColumn) { return buildQuery(searchView, clauses, Collections.singletonList(order), pageLink, idColumn); }