-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design: Range queries V1 support #55
Labels
type/design
Design documents for enhancements
Comments
raminqaf
changed the title
Design: Range queries support
Design: Range queries V1 support
Aug 16, 2022
Closed
This was referenced Sep 30, 2022
Closed
Merged
raminqaf
added a commit
that referenced
this issue
Oct 4, 2022
raminqaf
added a commit
that referenced
this issue
Oct 5, 2022
This was referenced Oct 6, 2022
raminqaf
added a commit
that referenced
this issue
Oct 11, 2022
raminqaf
added a commit
that referenced
this issue
Oct 12, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Desing: Range queries V1 support
Development: 0.8
last update: 06.10.2022
This issue describes our approach for the support of Range queries in Quick.
Goals
Out of scope
Implementation
1. Quick CLI
Goal: the user defines range mirrors that index the data for range queries
During topic creation, the user can pass a
--range-field <Fieled>
option. This option deploys a mirror with an extra state store containing the range query index.Example:
quick topic user-request-range --key integer --value schema --schema gateway.UserRequests --range-field timestamp
This command sends a request to the manager, and the manager prepares the deployment of a mirror called
user-request-range
. This mirror creates two indexes:userId
) andtimestamp
userId
)2. GraphQL Range Query
Goal: the user defines the range (from and to) in GraphQL Query type
The user needs to define the range query and arguments in the GraphQL schema. The GraphQL schema should contain the necessary information for the range data fetcher. For simplicity, we decided to extend the
@topic
directive. The@topic
directive gets two new arguments,rangeFrom
andrangeTo
. These two arguments define the range for a specific field.Example:
3. GraphQL Range Data Fetcher
Goal: extracts the range information and prepares the request to the mirror
Given the example below:
The range data fetcher gets the necessary information and prepares a range call to the mirror range endpoint:
GET /user-request-mirror/mirror/range/1?from=1&to=2
. It is important to notice that the range query is an exclusive range. In other words, the boundary point is not included in the range. For this specific example, so only the value of timestamp 1 is included in the returned value.4. Range Processor for Mirrors
Goal: the mirror builds a range index on a separated state store
The mirror needs a new processor to prepare a range index in a separate state store for range queries. Consider the following example. The topic contains the following information:
The range mirror will materialize the topic in RocksDB in two ways:
5. Range Index Structure
Goal: a flattened string key in the mirror
The mirror implements the processor API to create an index to support range queries. This index is a flattened string with a combination of the topic key and the value for which the range queries are requested. The index needs to pad the values (depending on the type
Int
10 digits orLong
19 digits) with zeros to keep the lexicographic order. So to generify the format of the key in the state store:<topicKeyValue>_<zero_paddings><rangeFieldValue>
. In our example, if we have a topic withuserId
as its key and want to create a range over thetimestamp
, the key in the state store would look like this:The flattened key approach will create unique keys for each user in a timestamp. Therefore all the values will be accessible when running a range query.
6. Range Query Service
Goal: a service that calls the Interactive Query API to fetch the data from the range state store
when the request
GET /user-request-mirror/mirror/range/<key>?from=<rangeFrom>&to=<rangeTo>
(e.gGET /user-request-mirror/mirror/range/1?from=1&to=2
) is received by the mirror. The mirror creates the range from argument (in the above example, this would be00000000001_00000000001
and range to (again in the example, this value would be00000000001_00000000002
) and passes these values to the range method of the IQ puts the values in a list and returns them to the requested gateway.The text was updated successfully, but these errors were encountered: