Skip to content

Conversation

@piyush-zlai
Copy link
Contributor

@piyush-zlai piyush-zlai commented Mar 31, 2025

Summary

In the old implementation we do see a decent amount of RejectedExecutionExceptions. This seems to be due to us making n individual query / get requests (result transform backed by a Scala future) and then sequencing them together into one Future for return upstream. As the fetchJoin/groupBy batch size increases along with a higher rps we end up with a lot of these Futures at a time and end up hitting limits of the KV store thread pool. This PR reworks things to make one bulkGet request where we look up all the relevant RowKeys and the appropriate range within them.

Item to call out:
We currently request the n RowKeys (depending on whether streaming data spans just current day or multiple if batch was delayed) as well as the time range we're interested in (per dataset). We could instead just issue the n RowKeys we're interested in and then filter on the client side (where we pick the relevant tiles per Row) - this means a simpler query to BT but means more data over the wire. We could test this out in a subsequent pass / check with Google folks on what they recommend.

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Optimized time series data queries by grouping requests per dataset to reduce query overhead and provide consolidated error responses.
  • Tests

    • Expanded test coverage with new cases for handling multiple keys and datasets, ensuring consistent data retrieval across various time ranges.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

Walkthrough

This PR refactors the multiGet method in the BigTable key-value store implementation to group requests by dataset and reduce the number of BigTable queries. It also updates the setQueryTimeSeriesFilters method signature to return row keys alongside the query. Additional tests have been added to validate time series data handling across multiple keys and datasets using new test cases and a helper method.

Changes

File Path Summary
cloud_gcp/.../BigTableKVStoreImpl.scala Refactored multiGet to group requests by dataset, created a mapping of requests to row keys, and updated error handling. Modified setQueryTimeSeriesFilters to return a tuple.
cloud_gcp/.../BigTableKVStoreTest.scala Added new test cases for multiple key time series queries and streaming tiled queries across datasets. Introduced helper method generateAndWriteTimeSeriesData.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant B as BigTableKVStoreImpl
    participant DB as BigTable

    C->>B: Call multiGet(requests)
    B->>B: Group requests by dataset
    B->>B: Generate query & row key map via setQueryTimeSeriesFilters
    B->>DB: Execute single query per dataset
    DB-->>B: Return aggregated results
    B->>B: Lookup results by row keys
    B-->>C: Return responses for each request
Loading

Possibly related PRs

Suggested reviewers

  • tchow-zlai
  • nikhil-zlai

Poem

In lines of code we trust,
Grouping keys without a fuss,
Datasets dance in a single beat,
Aggregated queries neat and sweet,
Cheers to tests that now complete!
🚀 Keep coding, stay elite!

Warning

Review ran into problems

🔥 Problems

GitHub Actions and Pipeline Checks: Resource not accessible by integration - https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository.

Please grant the required permissions to the CodeRabbit GitHub App under the organization or repository settings.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 7de3f74 and 27f2f3e.

📒 Files selected for processing (1)
  • cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreTest.scala (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: non_spark_tests
  • GitHub Check: non_spark_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (5)
cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreTest.scala (5)

31-31: Appropriate import added.

Import for NumericRange supports the new helper method parameter type.


387-412: Good test case for multiple keys.

This test effectively validates that the refactored multiGet method correctly handles time series queries across multiple keys, ensuring that each key returns appropriate data.


476-509: Well-structured test for multiple keys across days.

Test properly validates the new multiGet functionality when processing multiple keys with identical time ranges.


511-559: Great test for different batch end times.

This test thoroughly validates an important edge case - when different keys are queried with different time ranges - ensuring the refactored multiGet method handles these scenarios correctly.


671-680: Good helper method for test simplification.

This helper method adheres to DRY principles by extracting common test setup code, making tests more maintainable.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@piyush-zlai piyush-zlai force-pushed the piyush/bt_bulk_get_reads branch from 6163585 to 7de3f74 Compare March 31, 2025 15:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreImpl.scala (1)

172-213: Watch concurrency if many datasets.

Would you like help adding a safety check or concurrency-limiting mechanism?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 221353f and 7de3f74.

📒 Files selected for processing (2)
  • cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreImpl.scala (2 hunks)
  • cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreTest.scala (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: non_spark_tests
  • GitHub Check: non_spark_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (10)
cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreImpl.scala (3)

47-47: No concerns.


124-168: Good grouping approach.


221-242: Returning row keys is neat.

cloud_gcp/src/test/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreTest.scala (7)

31-31: No issue importing NumericRange.


51-51: Accessor looks fine.


58-58: EmulatorWrapper usage is okay.


387-412: Test coverage for multiple keys is good.


476-509: Excellent streaming tile coverage.


511-553: Well tested for separate batch times.


665-674: Helper method is concise.

@piyush-zlai piyush-zlai merged commit 53af9e8 into main Mar 31, 2025
7 checks passed
@piyush-zlai piyush-zlai deleted the piyush/bt_bulk_get_reads branch March 31, 2025 18:40
kumar-zlai pushed a commit that referenced this pull request Apr 25, 2025
…n n query calls (#562)

## Summary
In the old implementation we do see a decent amount of
RejectedExecutionExceptions. This seems to be due to us making n
individual query / get requests (result transform backed by a Scala
future) and then sequencing them together into one Future for return
upstream. As the fetchJoin/groupBy batch size increases along with a
higher rps we end up with a lot of these Futures at a time and end up
hitting limits of the KV store thread pool. This PR reworks things to
make one bulkGet request where we look up all the relevant RowKeys and
the appropriate range within them.

Item to call out:
We currently request the n RowKeys (depending on whether streaming data
spans just current day or multiple if batch was delayed) as well as the
time range we're interested in (per dataset). We could instead just
issue the n RowKeys we're interested in and then filter on the client
side (where we pick the relevant tiles per Row) - this means a simpler
query to BT but means more data over the wire. We could test this out in
a subsequent pass / check with Google folks on what they recommend.

## Checklist
- [X] Added Unit Tests
- [ ] Covered by existing CI
- [X] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Optimized time series data queries by grouping requests per dataset to
reduce query overhead and provide consolidated error responses.

- **Tests**
- Expanded test coverage with new cases for handling multiple keys and
datasets, ensuring consistent data retrieval across various time ranges.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
kumar-zlai pushed a commit that referenced this pull request Apr 29, 2025
…n n query calls (#562)

## Summary
In the old implementation we do see a decent amount of
RejectedExecutionExceptions. This seems to be due to us making n
individual query / get requests (result transform backed by a Scala
future) and then sequencing them together into one Future for return
upstream. As the fetchJoin/groupBy batch size increases along with a
higher rps we end up with a lot of these Futures at a time and end up
hitting limits of the KV store thread pool. This PR reworks things to
make one bulkGet request where we look up all the relevant RowKeys and
the appropriate range within them.

Item to call out:
We currently request the n RowKeys (depending on whether streaming data
spans just current day or multiple if batch was delayed) as well as the
time range we're interested in (per dataset). We could instead just
issue the n RowKeys we're interested in and then filter on the client
side (where we pick the relevant tiles per Row) - this means a simpler
query to BT but means more data over the wire. We could test this out in
a subsequent pass / check with Google folks on what they recommend.

## Checklist
- [X] Added Unit Tests
- [ ] Covered by existing CI
- [X] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Optimized time series data queries by grouping requests per dataset to
reduce query overhead and provide consolidated error responses.

- **Tests**
- Expanded test coverage with new cases for handling multiple keys and
datasets, ensuring consistent data retrieval across various time ranges.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
…n n query calls (#562)

## Summary
In the old implementation we do see a decent amount of
RejectedExecutionExceptions. This seems to be due to us making n
individual query / get requests (result transform backed by a Scala
future) and then sequencing them together into one Future for return
upstream. As the fetchJoin/groupBy batch size increases along with a
higher rps we end up with a lot of these Futures at a time and end up
hitting limits of the KV store thread pool. This PR reworks things to
make one bulkGet request where we look up all the relevant RowKeys and
the appropriate range within them.

Item to call out:
We currently request the n RowKeys (depending on whether streaming data
spans just current day or multiple if batch was delayed) as well as the
time range we're interested in (per dataset). We could instead just
issue the n RowKeys we're interested in and then filter on the client
side (where we pick the relevant tiles per Row) - this means a simpler
query to BT but means more data over the wire. We could test this out in
a subsequent pass / check with Google folks on what they recommend.

## Checklist
- [X] Added Unit Tests
- [ ] Covered by existing CI
- [X] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Optimized time series data queries by grouping requests per dataset to
reduce query overhead and provide consolidated error responses.

- **Tests**
- Expanded test coverage with new cases for handling multiple keys and
datasets, ensuring consistent data retrieval across various time ranges.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 15, 2025
…n n query calls (#562)

## Summary
In the old implementation we do see a decent amount of
RejectedExecutionExceptions. This seems to be due to us making n
individual query / get requests (result transform backed by a Scala
future) and then sequencing them together into one Future for return
upstream. As the fetchJoin/groupBy batch size increases along with a
higher rps we end up with a lot of these Futures at a time and end up
hitting limits of the KV store thread pool. This PR reworks things to
make one bulkGet request where we look up all the relevant RowKeys and
the appropriate range within them.

Item to call out:
We currently request the n RowKeys (depending on whether streaming data
spans just current day or multiple if batch was delayed) as well as the
time range we're interested in (per dataset). We could instead just
issue the n RowKeys we're interested in and then filter on the client
side (where we pick the relevant tiles per Row) - this means a simpler
query to BT but means more data over the wire. We could test this out in
a subsequent pass / check with Google folks on what they recommend.

## Checklist
- [X] Added Unit Tests
- [ ] Covered by existing CI
- [X] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Optimized time series data queries by grouping requests per dataset to
reduce query overhead and provide consolidated error responses.

- **Tests**
- Expanded test coverage with new cases for handling multiple keys and
datasets, ensuring consistent data retrieval across various time ranges.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
chewy-zlai pushed a commit that referenced this pull request May 16, 2025
…n n query calls (#562)

## Summary
In the old implementation we do see a decent amount of
RejectedExecutionExceptions. This seems to be due to us making n
individual query / get requests (result transform baour clientsed by a Scala
future) and then sequencing them together into one Future for return
upstream. As the fetchJoin/groupBy batch size increases along with a
higher rps we end up with a lot of these Futures at a time and end up
hitting limits of the KV store thread pool. This PR reworks things to
make one bulkGet request where we look up all the relevant RowKeys and
the appropriate range within them.

Item to call out:
We currently request the n RowKeys (depending on whether streaming data
spans just current day or multiple if batch was delayed) as well as the
time range we're interested in (per dataset). We could instead just
issue the n RowKeys we're interested in and then filter on the client
side (where we piour clients the relevant tiles per Row) - this means a simpler
query to BT but means more data over the wire. We could test this out in
a subsequent pass / cheour clients with Google folks on what they recommend.

## Cheour clientslist
- [X] Added Unit Tests
- [ ] Covered by existing CI
- [X] Integration tested
- [ ] Documentation update



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Optimized time series data queries by grouping requests per dataset to
reduce query overhead and provide consolidated error responses.

- **Tests**
- Expanded test coverage with new cases for handling multiple keys and
datasets, ensuring consistent data retrieval across various time ranges.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants