wjhypo opened a new pull request #9810:
URL: https://github.com/apache/druid/pull/9810


   Fixes #9809.
   
   ### Description
   Currently segment pruning uses the time interval. For further filtering on 
secondary partitions, only single dimension ShardSpec is supported (done in 
#2982). For hash based partitioning (`HashBasedNumberedShardSpec`), we can also 
apply pruning by rehash the `partitionDimensions` in the query filter to locate 
segments. 
   
   This PR addresses this by rehashing the `partitionDimensions` values in 
`HashBasedNumberedShardSpec` from the query filter using the same hashing 
mechanism used during ingestion, and use the hashed value mod `partitions` to 
determine if it equals `partitionNum` of a segment. We only attempt pruning if 
1) all `partitionDimensions` present in the query filter and 2) the values of 
`partitionDimensions` are discrete values not range values because we can't 
hash range values and 3) during ingestion time, `partitionDimensions` are 
explicitly set because otherwise the hash during ingestion is based on all 
dimensions plus the truncated input timestamp according to QueryGranularity 
instead of just `partitionDimensions` and we don't record timestamp in shard 
spec. Then we enumerate all combinations of the values of the dimensions in 
`partitionDimensions` drawn from the filter and check if the hashed value mod 
`partitions` matches the `partitionNum` of a segment. E.g., if the query 
contains filter "dim1 = v1 and dim2 in (v2, v3, v4)", then the hash values we 
will check are: hash(v1, v2), hash(v1, v3), hash(v1, v4).
   
   
   This PR has:
   - [x] been self-reviewed.
      - [ ] using the [concurrency 
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
 (Remove this item if the PR doesn't have any relation to concurrency.)
   - [x] added documentation for new or modified features or behaviors.
   - [x] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
   - [x] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths.
   - [ ] added integration tests.
   - [x] been tested in a test Druid cluster.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to