本文整理汇总了Java中io.druid.query.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于io.druid.query包,在下文中一共展示了Result类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTimeseries
import io.druid.query.Result; //导入依赖的package包/类
@Test
public void testTimeseries() throws Exception {
Query query = TestHelper.getTimeseriesQuery();
List<Result> results = client.timeseries(query);
Assert.assertEquals(results.size(), 1);
@SuppressWarnings("unchecked")
Map<String, Object> value = (Map<String, Object>) results.get(0).getValue();
Assert.assertEquals(value.get("agg_sum"), 370.0);
Assert.assertEquals(value.get("agg_min"), 0.0);
Assert.assertEquals(value.get("agg_max"), 124.0);
Assert.assertEquals(value.get("agg_count"), 15);
}
示例2: topNQuery
import io.druid.query.Result; //导入依赖的package包/类
@Test
public void topNQuery() throws IOException {
QueryableIndex index = createDruidSegments();
List<DimFilter> filters = new ArrayList<DimFilter>();
filters.add(DimFilters.dimEquals("report", "URLTransaction"));
filters.add(DimFilters.dimEquals("pool", "r1cart"));
filters.add(DimFilters.dimEquals("metric", "Duration"));
TopNQuery query =
new TopNQueryBuilder()
.threshold(5)
.metric("agg_count")
.dataSource("test")
.intervals(QuerySegmentSpecs.create(new Interval(0, new DateTime().getMillis())))
.granularity(QueryGranularity.fromString("NONE"))
.dimension("colo")
.aggregators(
Arrays.<AggregatorFactory>asList(
new LongSumAggregatorFactory("agg_count", "agg_count"),
new LongMaxAggregatorFactory("agg_max", "agg_max"),
new LongMinAggregatorFactory("agg_min", "agg_min"),
new DoubleSumAggregatorFactory("agg_sum", "agg_sum"))
)
.filters(DimFilters.and(filters)).build();
@SuppressWarnings("unchecked")
Sequence<Result> sequence = QueryHelper.run(query, index);
ArrayList<Result> results = Sequences.toList(sequence, Lists.<Result>newArrayList());
Assert.assertEquals(results.size(), 1);
}
示例3: main
import io.druid.query.Result; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
final String host = args.length == 0 ? "localhost:8082" : args[0];
try (final DruidClient druidClient = DruidClient.create(host)) {
// Create a simple select query using the Druids query builder.
final int threshold = 50;
final SelectQuery selectQuery = Druids
.newSelectQueryBuilder()
.dataSource("wikiticker")
.intervals(ImmutableList.of(new Interval("1000/3000")))
.filters(
new AndDimFilter(
ImmutableList.<DimFilter>of(
new SelectorDimFilter("countryName", "United States", null),
new SelectorDimFilter("cityName", "San Francisco", null)
)
)
)
.dimensions(ImmutableList.of("page", "user"))
.pagingSpec(new PagingSpec(null, threshold))
.build();
// Fetch the results.
final long startTime = System.currentTimeMillis();
final Sequence<Result<SelectResultValue>> resultSequence = druidClient.execute(selectQuery);
final List<Result<SelectResultValue>> resultList = Sequences.toList(
resultSequence,
Lists.<Result<SelectResultValue>>newArrayList()
);
final long fetchTime = System.currentTimeMillis() - startTime;
// Print the results.
int resultCount = 0;
for (final Result<SelectResultValue> result : resultList) {
for (EventHolder eventHolder : result.getValue().getEvents()) {
System.out.println(eventHolder.getEvent());
resultCount++;
}
}
// Print statistics.
System.out.println(
String.format(
"Fetched %,d rows in %,dms.",
resultCount,
fetchTime
)
);
}
}
示例4: timeseries
import io.druid.query.Result; //导入依赖的package包/类
@POST(".")
Call<List<Result>> timeseries(@Body Query query);
示例5: topN
import io.druid.query.Result; //导入依赖的package包/类
@POST(".")
Call<List<Result>> topN(@Body Query query);
示例6: testTopN
import io.druid.query.Result; //导入依赖的package包/类
@Test
public void testTopN() throws Exception {
Query query = TestHelper.getTopNQuery();
List<Result> results = client.topN(query);
Assert.assertEquals(results.size(), 1);
}