druid/docs/content/querying
Gian Merlino ffa25b7832
Query vectorization. (#6794)
* Benchmarks: New SqlBenchmark, add caching & vectorization to some others.

- Introduce a new SqlBenchmark geared towards benchmarking a wide
  variety of SQL queries. Rename the old SqlBenchmark to
  SqlVsNativeBenchmark.
- Add (optional) caching to SegmentGenerator to enable easier
  benchmarking of larger segments.
- Add vectorization to FilteredAggregatorBenchmark and GroupByBenchmark.

* Query vectorization.

This patch includes vectorized timeseries and groupBy engines, as well
as some analogs of your favorite Druid classes:

- VectorCursor is like Cursor. (It comes from StorageAdapter.makeVectorCursor.)
- VectorColumnSelectorFactory is like ColumnSelectorFactory, and it has
  methods to create analogs of the column selectors you know and love.
- VectorOffset and ReadableVectorOffset are like Offset and ReadableOffset.
- VectorAggregator is like BufferAggregator.
- VectorValueMatcher is like ValueMatcher.

There are some noticeable differences between vectorized and regular
execution:

- Unlike regular cursors, vector cursors do not understand time
  granularity. They expect query engines to handle this on their own,
  which a new VectorCursorGranularizer class helps with. This is to
  avoid too much batch-splitting and to respect the fact that vector
  selectors are somewhat more heavyweight than regular selectors.
- Unlike FilteredOffset, FilteredVectorOffset does not leverage indexes
  for filters that might partially support them (like an OR of one
  filter that supports indexing and another that doesn't). I'm not sure
  that this behavior is desirable anyway (it is potentially too eager)
  but, at any rate, it'd be better to harmonize it between the two
  classes. Potentially they should both do some different thing that
  is smarter than what either of them is doing right now.
- When vector cursors are created by QueryableIndexCursorSequenceBuilder,
  they use a morphing binary-then-linear search to find their start and
  end rows, rather than linear search.

Limitations in this patch are:

- Only timeseries and groupBy have vectorized engines.
- GroupBy doesn't handle multi-value dimensions yet.
- Vector cursors cannot handle virtual columns or descending order.
- Only some filters have vectorized matchers: "selector", "bound", "in",
  "like", "regex", "search", "and", "or", and "not".
- Only some aggregators have vectorized implementations: "count",
  "doubleSum", "floatSum", "longSum", "hyperUnique", and "filtered".
- Dimension specs other than "default" don't work yet (no extraction
  functions or filtered dimension specs).

Currently, the testing strategy includes adding vectorization-enabled
tests to TimeseriesQueryRunnerTest, GroupByQueryRunnerTest,
GroupByTimeseriesQueryRunnerTest, CalciteQueryTest, and all of the
filtering tests that extend BaseFilterTest. In all of those classes,
there are some test cases that don't support vectorization. They are
marked by special function calls like "cannotVectorize" or "skipVectorize"
that tell the test harness to either expect an exception or to skip the
test case.

Testing should be expanded in the future -- a project in and of itself.

Related to #3011.

* WIP

* Adjustments for unused things.

* Adjust javadocs.

* DimensionDictionarySelector adjustments.

* Add "clone" to BatchIteratorAdapter.

* ValueMatcher javadocs.

* Fix benchmark.

* Fixups post-merge.

* Expect exception on testGroupByWithStringVirtualColumn for IncrementalIndex.

* BloomDimFilterSqlTest: Tag two non-vectorizable tests.

* Minor adjustments.

* Update surefire, bump up Xmx in Travis.

* Some more adjustments.

* Javadoc adjustments

* AggregatorAdapters adjustments.

* Additional comments.

* Remove switching search.

* Only missiles.
2019-07-12 12:54:07 -07:00
..
aggregations.md Upgrade various build and doc links to https. (#7722) 2019-05-21 11:30:14 -07:00
caching.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
datasource.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
datasourcemetadataquery.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
dimensionspecs.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
filters.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
granularities.md clarify granularity docs (#7977) 2019-06-27 08:51:22 -07:00
groupbyquery.md Fix performance-faq and remove insert-segment-to-db redirects (#7759) 2019-05-24 13:20:02 -07:00
having.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
hll-old.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
joins.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
limitspec.md Front Matter header needs to be on the first line for md to be rendered properly by jekyll (#6733) 2018-12-13 11:47:20 -08:00
lookups.md endpoint to delete lookup tier and remove tier on last lookup deletion (#7852) 2019-06-15 17:55:50 -07:00
multi-value-dimensions.md add SQL docs for multi-value string dimensions (#8011) 2019-07-03 08:22:33 -07:00
multitenancy.md Fix broken links in docs, add broken link checker. (#7658) 2019-05-15 14:49:50 -07:00
post-aggregations.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
query-context.md Query vectorization. (#6794) 2019-07-12 12:54:07 -07:00
querying.md Fix broken links in docs, add broken link checker. (#7658) 2019-05-15 14:49:50 -07:00
scan-query.md Scan Doc Change (#7903) 2019-06-15 01:21:34 -07:00
searchquery.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
searchqueryspec.md Front Matter header needs to be on the first line for md to be rendered properly by jekyll (#6733) 2018-12-13 11:47:20 -08:00
segmentmetadataquery.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
select-query.md Remove SQL experimental banner and other doc adjustments. (#7591) 2019-05-06 12:31:51 -07:00
sorting-orders.md add version comparator for StringComparator (#6745) 2019-01-08 17:17:03 -08:00
sql.md SQL: Add TIME_CEIL function. (#8027) 2019-07-04 15:40:03 -07:00
timeboundaryquery.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
timeseriesquery.md Add limit to timeseries docs (#7750) 2019-05-23 19:41:52 -07:00
topnmetricspec.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
topnquery.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00
virtual-columns.md Add more Apache branding to docs (#7515) 2019-04-19 15:52:26 -07:00