Skip to content
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

feat: drop use of MergeReverseRecordReader #1213

Closed
wants to merge 3 commits into from

Conversation

de-sh
Copy link
Contributor

@de-sh de-sh commented Feb 25, 2025

Fixes #XXXX.

Description


This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Summary by CodeRabbit

  • New Features

    • Introduced an enhanced batch iteration method for processing file records more efficiently.
  • Refactor

    • Streamlined record reading workflows by exclusively using the MergedRecordReader and removing legacy reverse processing.
    • Updated instantiation to simplify the creation of MergedRecordReader and improved error handling.
    • Simplified iteration over merged records by adjusting method parameters and removing unnecessary complexity.

Copy link

coderabbitai bot commented Feb 25, 2025

Walkthrough

The changes remove the MergedReverseRecordReader and its associated utilities, simplifying record reading. The MergedRecordReader is now streamlined with a modified try_new method that returns an instance directly, and a new merged_iter method has been introduced for batch processing. In addition, references to the reverse reader in the streams module have been replaced with the updated reader, and error handling is adjusted by removing unnecessary unwraps. Unused imports and old timestamp functions have been cleared to maintain a cleaner codebase.

Changes

File(s) Change Summary
src/parseable/staging/reader.rs Removed MergedReverseRecordReader and related timestamp functions; updated MergedRecordReader::try_new to return Self and added merged_iter for flat mapping record batches; removed unused imports and restructured merged_schema for simplicity.
src/parseable/streams.rs Replaced instances of MergedReverseRecordReader with MergedRecordReader in methods (convert_disk_files_to_parquet and updated_schema); removed the unwrap() call when calling try_new; adjusted the merged_iter invocation by removing redundant parameters.

Possibly related PRs

  • fix: capture time created from metadata not filename #1211: The changes in this PR are related to the modifications in the MergedRecordReader and its usage in the convert_disk_files_to_parquet method, which also appears in the retrieved PR, indicating a direct connection in how the record reading logic is handled.
  • feat: query parquet files still in staging #1199: The changes in the main PR, which involve significant modifications to the MergedRecordReader and the removal of the MergedReverseRecordReader, are directly related to the adjustments made in the retrieved PR where MergedReverseRecordReader is replaced with MergedRecordReader in the src/parseable/streams.rs file.
  • feat: merge finish .arrows and convert to .parquet #1200: The changes in the main PR, which involve significant modifications to the MergedRecordReader and the removal of the MergedReverseRecordReader, are directly related to the changes in the retrieved PR, as both involve the transition from using MergedReverseRecordReader to MergedRecordReader in the src/parseable/streams.rs file.

Suggested labels

for next release

Suggested reviewers

  • nikhilsinhaparseable

Poem

I'm a rabbit with a joyful heart,
Hopping through code with a brand-new start,
Merged readers now pave a simpler way,
Bugs get chased, and old methods stray,
In refactored lines, I proudly roam,
Coding like carrots—fresh and home! 🐰💻

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

Copy link

@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 (3)
src/parseable/streams.rs (2)

472-472: Revisit partial file handling.
Switching from MergedReverseRecordReader to MergedRecordReader works, but this try_new method silently logs invalid files without signaling the caller. Consider providing a way (e.g., returning a list of skipped files) to track which files were skipped for better observability.


532-532: Note on silent failures.
Removing the .unwrap() means the construction of MergedRecordReader no longer panics. However, the code will also quietly skip invalid files. If partial merges matter, consider a strategy to surface these issues to the caller.

src/parseable/staging/reader.rs (1)

40-40: Consider explicit error reporting.
Changing the signature to return Self discards file-level errors internally. If it's important to track or handle invalid files, returning a Result or a summary of skipped files might be more transparent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f209de6 and 1ca7b32.

📒 Files selected for processing (2)
  • src/parseable/staging/reader.rs (2 hunks)
  • src/parseable/streams.rs (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: coverage
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
🔇 Additional comments (8)
src/parseable/streams.rs (2)

60-60: Smooth import transition.
Replacing MergedReverseRecordReader with MergedRecordReader in the import list aligns with the updated code structure.


489-489: Confirm iteration order and transformations.
Using record_reader.merged_iter(schema) is straightforward. However, ensure that removing reverse iteration does not affect any desired ordering logic, and confirm that adapt_batch consistently applies all needed transformations.

src/parseable/staging/reader.rs (6)

22-22: Efficient buffering.
Using BufReader ensures efficiently buffered file reads.


27-27: Straightforward import.
Bringing in RecordBatch is necessary for the reading logic.


28-28: Correct reader import.
StreamReader from arrow_ipc is the proper choice to handle Arrow IPC streams.


32-32: Good reuse of utility.
Adopting adapt_batch centralizes the batch transformation logic for consistency.


72-72: Clear merging approach.
merged_iter provides a unified iterator of record batches across multiple streams, simplifying reading logic.


73-76: Check ordering requirements.
Flattening the readers and mapping each batch via adapt_batch is straightforward, but verify whether preserving any original ordering is necessary or if the new approach suffices for all use cases.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
Copy link

@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)
src/parseable/staging/reader.rs (1)

72-78: New merged_iter method replaces reverse reader functionality

This new method is the key implementation replacing MergeReverseRecordReader. It uses a flat mapping approach to iterate through all readers, appropriately reversing and adapting batches.

Consider adding documentation to this method explaining its purpose and behavior, especially since it's replacing functionality from the removed MergeReverseRecordReader. This would help future developers understand the design decisions.

+   /// Iterates through all readers, reversing and adapting each batch to the provided schema.
+   /// This method replaces the functionality previously provided by MergeReverseRecordReader.
    pub fn merged_iter(self, schema: Arc<Schema>) -> impl Iterator<Item = RecordBatch> {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0817e30 and 306e440.

📒 Files selected for processing (1)
  • src/parseable/staging/reader.rs (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
🔇 Additional comments (5)
src/parseable/staging/reader.rs (5)

20-33: Import updates aligned with PR goals

The import changes reflect the removal of MergeReverseRecordReader and the update of MergedRecordReader to handle the functionality directly. The addition of arrow_array::RecordBatch and streamlined imports support the new implementation.


124-126: Test helper function simplifies reader creation

The get_reverse_reader helper function provides a clean way to create readers for testing, improving test code clarity.

Consider adding a brief comment to explain why this function exists and what it does.

+   /// Creates a StreamReader for testing purposes, wrapping the provided reader with BufReader.
    fn get_reverse_reader<T: Read + Seek>(reader: T) -> StreamReader<BufReader<T>> {

154-162: Ensure tests validate expected behavior

Tests have been updated to work with the new implementation. The assertions are checking that records are being read in the expected order.


216-216: Test adapts to use new helper method

Test now uses the get_reverse_reader helper function and calls flatten() to convert to an iterator, matching the new implementation approach.


40-61:

❓ Verification inconclusive

Return type change impacts error handling strategy

The try_new method has been modified to return Self directly instead of Result<Self, ()>, which changes how errors are communicated to callers. The function now logs errors and continues rather than propagating them.

Consider documenting this error handling strategy change, as callers previously expecting errors to be propagated will need to be updated. They now need to check if any readers were actually created rather than handling an error result.


🏁 Script executed:

#!/bin/bash
# Check if there are any callers of try_new that expect a Result
rg "try_new\(.*\)\?\.(?:ok|unwrap|expect)" --type rust

Length of output: 56


Document Updated Error Handling Approach

The change in the try_new method now returns Self directly rather than propagating errors via a Result. This new approach logs error messages and skips problematic files instead of using error propagation. Given that no immediate caller patterns indicating an expectation of a Result were detected by the automated search, please manually verify that all call-sites are updated to check whether any valid readers have been created, rather than relying on explicit error handling.

  • Action: Update the function's documentation to highlight that errors during file processing are now handled by logging and omitting invalid files.
  • Recommendation: Ensure callers of try_new verify the returned instance (e.g., checking an empty readers list) to manage error scenarios appropriately.

@de-sh
Copy link
Contributor Author

de-sh commented Feb 27, 2025

We won't be proceeding this route because:

The order of records in response should be time ordered, and not in random order. With this PR we are responding to queries without considering the order.

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.

1 participant