use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class BaseTimeSyncedIteratorTest method runQueries.
/**
* Executes the queries against MockBase through the regular pipeline and stores
* the results in {@linke #results}
* @param subs The queries to execute
*/
protected void runQueries(final ArrayList<TSSubQuery> subs) throws Exception {
query = new TSQuery();
query.setStart(Long.toString(START_TS));
query.setQueries(subs);
query.validateAndSetQuery();
final Query[] compiled = query.buildQueries(tsdb);
results = new HashMap<String, Pair<TSSubQuery, DataPoints[]>>(compiled.length);
iterators = new HashMap<String, ITimeSyncedIterator>(compiled.length);
int index = 0;
for (final Query q : compiled) {
final DataPoints[] dps = q.runAsync().join();
results.put(Integer.toString(index), new Pair<TSSubQuery, DataPoints[]>(query.getQueries().get(index), dps));
final ITimeSyncedIterator it = new TimeSyncedIterator(Integer.toString(index), query.getQueries().get(index).getFilterTagKs(), dps);
it.setFillPolicy(new NumericFillPolicy(FillPolicy.NOT_A_NUMBER));
iterators.put(Integer.toString(index), it);
index++;
}
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestHttpJsonSerializer method getTestQuery.
/** @return Returns a test TSQuery object to pass on to the serializer */
private TSQuery getTestQuery(final boolean show_stats, final boolean show_summary) {
final TSQuery data_query = new TSQuery();
data_query.setStart("1356998400");
data_query.setEnd("1388534400");
data_query.setShowStats(show_stats);
data_query.setShowSummary(show_summary);
final TSSubQuery sub_query = new TSSubQuery();
sub_query.setMetric("sys.cpu.user");
sub_query.setAggregator("sum");
final ArrayList<TSSubQuery> sub_queries = new ArrayList<TSSubQuery>(1);
sub_queries.add(sub_query);
data_query.setQueries(sub_queries);
return data_query;
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQueryMTypeWGroupByWildcardExplicit.
@Test
public void parseQueryMTypeWGroupByWildcardExplicit() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=" + TagVWildcardFilter.FILTER_NAME + "(*quirm)}");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
TSSubQuery sub = tsq.getQueries().get(0);
sub.validateAndSetQuery();
assertEquals(1, sub.getFilters().size());
assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQueryMTypeWEmptyFilterBrackets.
@Test
public void parseQueryMTypeWEmptyFilterBrackets() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{}{}");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
TSSubQuery sub = tsq.getQueries().get(0);
sub.validateAndSetQuery();
assertEquals(0, sub.getFilters().size());
}
use of net.opentsdb.core.TSSubQuery in project opentsdb by OpenTSDB.
the class TestQueryRpc method parseQueryMTypeWGroupByAndWildcardFilterSameTagK.
@Test
public void parseQueryMTypeWGroupByAndWildcardFilterSameTagK() throws Exception {
HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=quirm|tsort}" + "{host=wildcard(*quirm)}");
TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
TSSubQuery sub = tsq.getQueries().get(0);
sub.validateAndSetQuery();
assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
assertTrue(sub.getFilters().get(1) instanceof TagVLiteralOrFilter);
}
Aggregations