use of io.druid.query.search.search.SearchSortSpec in project druid by druid-io.
the class SearchQueryRunnerTest method testSearchSameValueInMultiDims2.
@Test
public void testSearchSameValueInMultiDims2() {
SearchQuery searchQuery = Druids.newSearchQueryBuilder().dataSource(QueryRunnerTestHelper.dataSource).granularity(QueryRunnerTestHelper.allGran).intervals(QueryRunnerTestHelper.fullOnInterval).dimensions(Arrays.asList(QueryRunnerTestHelper.placementDimension, QueryRunnerTestHelper.placementishDimension)).sortSpec(new SearchSortSpec(StringComparators.STRLEN)).query("e").build();
List<SearchHit> expectedHits = Lists.newLinkedList();
expectedHits.add(new SearchHit(QueryRunnerTestHelper.placementishDimension, "e", 93));
expectedHits.add(new SearchHit(QueryRunnerTestHelper.placementDimension, "preferred", 1209));
expectedHits.add(new SearchHit(QueryRunnerTestHelper.placementishDimension, "preferred", 1209));
checkSearchQuery(searchQuery, expectedHits);
}
use of io.druid.query.search.search.SearchSortSpec in project druid by druid-io.
the class SearchSortSpecTest method testAlphanumericComparator.
@Test
public void testAlphanumericComparator() {
SearchSortSpec spec = new SearchSortSpec(StringComparators.ALPHANUMERIC);
SearchHit hit1 = new SearchHit("test", "a100");
SearchHit hit2 = new SearchHit("test", "a9");
SearchHit hit3 = new SearchHit("test", "b0");
Assert.assertTrue(spec.getComparator().compare(hit1, hit2) > 0);
Assert.assertTrue(spec.getComparator().compare(hit3, hit1) > 0);
Assert.assertTrue(spec.getComparator().compare(hit3, hit2) > 0);
}
use of io.druid.query.search.search.SearchSortSpec in project druid by druid-io.
the class SearchSortSpecTest method testNumericComparator.
@Test
public void testNumericComparator() {
SearchSortSpec spec = new SearchSortSpec(StringComparators.NUMERIC);
SearchHit hit1 = new SearchHit("test", "1001001.12412");
SearchHit hit2 = new SearchHit("test", "-1421");
SearchHit hit3 = new SearchHit("test", "not-numeric-at-all");
SearchHit hit4 = new SearchHit("best", "1001001.12412");
Assert.assertTrue(spec.getComparator().compare(hit1, hit2) > 0);
Assert.assertTrue(spec.getComparator().compare(hit3, hit1) < 0);
Assert.assertTrue(spec.getComparator().compare(hit3, hit2) < 0);
Assert.assertTrue(spec.getComparator().compare(hit1, hit4) > 0);
}
use of io.druid.query.search.search.SearchSortSpec in project druid by druid-io.
the class SearchSortSpecTest method testStrlenComparator.
@Test
public void testStrlenComparator() {
SearchSortSpec spec = new SearchSortSpec(StringComparators.LEXICOGRAPHIC);
SearchHit hit1 = new SearchHit("test", "apple");
SearchHit hit2 = new SearchHit("test", "banana");
SearchHit hit3 = new SearchHit("test", "orange");
Assert.assertTrue(spec.getComparator().compare(hit1, hit2) < 0);
Assert.assertTrue(spec.getComparator().compare(hit3, hit1) > 0);
Assert.assertTrue(spec.getComparator().compare(hit3, hit2) > 0);
Assert.assertTrue(spec.getComparator().compare(hit1, hit1) == 0);
}
use of io.druid.query.search.search.SearchSortSpec in project druid by druid-io.
the class SearchBinaryFnTest method testAlphanumericMerge.
@Test
public void testAlphanumericMerge() {
SearchSortSpec searchSortSpec = new SearchSortSpec(StringComparators.ALPHANUMERIC);
Comparator<SearchHit> c = searchSortSpec.getComparator();
Result<SearchResultValue> r1 = new Result<SearchResultValue>(currTime, new SearchResultValue(toHits(c, "blah:a100", "blah:a9", "alah:a100")));
Result<SearchResultValue> r2 = new Result<SearchResultValue>(currTime, new SearchResultValue(toHits(c, "blah:b0", "alah:c3")));
Result<SearchResultValue> expected = new Result<SearchResultValue>(currTime, new SearchResultValue(toHits(c, "blah:a9", "alah:a100", "blah:a100", "blah:b0", "alah:c3")));
Result<SearchResultValue> actual = new SearchBinaryFn(searchSortSpec, Granularities.ALL, Integer.MAX_VALUE).apply(r1, r2);
Assert.assertEquals(expected.getTimestamp(), actual.getTimestamp());
assertSearchMergeResult(expected.getValue(), actual.getValue());
}
Aggregations