Compiles the TSQuery into an array of Query objects for execution. If the user has not set a down sampler explicitly, and they don't want millisecond resolution, then we set the down sampler to 1 second to handle situations where storage may have multiple data points per second. @param tsdb The tsdb
(final TSDB tsdb)
| 235 | * @since 2.2 |
| 236 | */ |
| 237 | public Deferred<Query[]> buildQueriesAsync(final TSDB tsdb) { |
| 238 | final Query[] tsdb_queries = new Query[queries.size()]; |
| 239 | |
| 240 | final List<Deferred<Object>> deferreds = |
| 241 | new ArrayList<Deferred<Object>>(queries.size()); |
| 242 | for (int i = 0; i < queries.size(); i++) { |
| 243 | Query query = tsdb.newQuery(); |
| 244 | Deferred<Object> resolution = query.configureFromQuery(this, i); |
| 245 | |
| 246 | if (query.needsSplitting() && (query instanceof TsdbQuery)) { |
| 247 | query = new SplitRollupQuery(tsdb, (TsdbQuery) query, resolution); |
| 248 | resolution = query.configureFromQuery(this, i); |
| 249 | } |
| 250 | deferreds.add(resolution); |
| 251 | |
| 252 | tsdb_queries[i] = query; |
| 253 | } |
| 254 | |
| 255 | class GroupFinished implements Callback<Query[], ArrayList<Object>> { |
| 256 | @Override |
| 257 | public Query[] call(final ArrayList<Object> deferreds) { |
| 258 | return tsdb_queries; |
| 259 | } |
| 260 | @Override |
| 261 | public String toString() { |
| 262 | return "Query compile group callback"; |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | return Deferred.group(deferreds).addCallback(new GroupFinished()); |
| 267 | } |
| 268 | |
| 269 | public String toString() { |
| 270 | final StringBuilder buf = new StringBuilder(); |