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

Expose batchSize parameter on various indexers #23

Merged
merged 6 commits into from
Jul 3, 2024

Conversation

chaosrealm
Copy link
Contributor

@chaosrealm chaosrealm commented Jul 3, 2024

Expose batchSize parameter on various indexers. Fixes #21

Summary by CodeRabbit

  • New Features
    • Introduced batchSize configuration for directory, Shopify, and TSV indexers to enhance control over file processing and indexing operations. This allows for more efficient handling of large datasets.

Copy link

coderabbitai bot commented Jul 3, 2024

Walkthrough

The recent changes introduce a configurable batch size option across multiple indexer classes (DirectoryIndexer, ShopifyIndexer, and TSVIndexer) to help avoid exceeding the maximum POST payload size. This batch size can now be set through options (opts) provided during the initialization of these indexers, offering greater flexibility and control over indexing operations.

Changes

File Change Summary
indexers/directory-indexer.ts Added batchSize property; initialized it in constructor; adjusted file processing for batch size
indexers/shopify-indexer.ts Introduced batchSize property; updated constructor and relevant methods to use batchSize
indexers/tsv-indexer.ts Included batchSize in TSVIndexerOpts; initialized and used batchSize in class constructor

Assessment against linked issues

Objective Addressed Explanation
Make batch size configurable via opts (#21)

Poem

In code forests deep, where indexers delve,
A batch of data in twenty-five cells,
Configurable now, to suit your needs,
So body size limits no longer impede,
Flexibility and control, the new creed!


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d7089a8 and 4efa90e.

Files selected for processing (4)
  • indexers/directory-indexer.ts (3 hunks)
  • indexers/json-indexer.ts (3 hunks)
  • indexers/shopify-indexer.ts (2 hunks)
  • indexers/tsv-indexer.ts (4 hunks)
Additional comments not posted (17)
indexers/tsv-indexer.ts (4)

9-9: LGTM! The batchSize parameter is introduced.

The batchSize parameter is optional and its introduction is consistent with the objective.


21-21: LGTM! The batchSize parameter is initialized.

The batchSize parameter is initialized in the constructor.


32-32: LGTM! The batchSize parameter is assigned.

The batchSize parameter is assigned from the options to the class property.


70-70: Verify the usage of the batchSize parameter in the jsonIndexer method call.

Ensure that the jsonIndexer method correctly utilizes the batchSize parameter.

indexers/json-indexer.ts (4)

8-8: LGTM! The batchSize parameter is introduced.

The batchSize parameter is optional and its introduction is consistent with the objective.


15-15: LGTM! The batchSize parameter is initialized.

The batchSize parameter is initialized in the constructor with a default value of 50.


26-26: LGTM! The batchSize parameter is assigned.

The batchSize parameter is assigned from the options to the class property.


79-79: Verify the batch processing logic updates.

Ensure that the batch processing logic correctly utilizes the batchSize parameter.

Verification successful

Batch processing logic correctly utilizes the batchSize parameter.

The batch processing logic in indexers/json-indexer.ts correctly uses the batchSize parameter to control the batch size.

  • indexers/json-indexer.ts: Lines where batchSize is defined, assigned, and used.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the batch processing logic updates.

# Test: Search for the batch processing logic. Expect: The logic should use the batchSize parameter.
rg --type javascript 'batchSize'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the batch processing logic updates.

# Test: Search for the batch processing logic. Expect: The logic should use the batchSize parameter.
rg 'batchSize' --glob '*.ts'

Length of output: 1230

indexers/shopify-indexer.ts (5)

18-18: LGTM! The batchSize parameter is introduced.

The batchSize parameter is optional and its introduction is consistent with the objective.


22-22: LGTM! The batchSize parameter is initialized.

The batchSize parameter is initialized in the constructor.


31-31: LGTM! The batchSize parameter is assigned.

The batchSize parameter is assigned from the options to the class property.


102-102: Verify the usage of the batchSize parameter in the jsonIndexer method call.

Ensure that the jsonIndexer method correctly utilizes the batchSize parameter.


108-108: Verify the usage of the batchSize parameter in the deleteProducts method.

Ensure that the deleteProducts method correctly utilizes the batchSize parameter.

Verification successful

The batchSize parameter is correctly utilized in the deleteProducts method.

The batchSize parameter is used to control the number of delete operations before awaiting their completion, ensuring batch processing of deletions.

  • indexers/shopify-indexer.ts:
    • Line 108: if (this.deletes.length >= this.batchSize)
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the batchSize parameter in the deleteProducts method.

# Test: Search for the deleteProducts method definition. Expect: The method should use the batchSize parameter.
rg --type javascript 'deleteProducts'

Length of output: 72


Script:

#!/bin/bash
# Description: Verify the usage of the batchSize parameter in the deleteProducts method.

# Corrected command to search for the deleteProducts method definition in JavaScript files.
rg 'deleteProducts' --glob '*.js' --glob '*.ts'

Length of output: 186


Script:

#!/bin/bash
# Description: Check the usage of the batchSize parameter within the deleteProducts method.

# Extract the deleteProducts method body and search for the batchSize keyword.
ast-grep --lang typescript --pattern $'private async deleteProducts(): Promise<void> {
  $$$
}' indexers/shopify-indexer.ts | rg 'batchSize'

Length of output: 484


Script:

#!/bin/bash
# Description: Check the usage of the batchSize parameter within the deleteProducts method.

# Refine the ast-grep pattern to match the deleteProducts method and search for the batchSize keyword within the method body.
ast-grep --lang typescript --pattern $'private async deleteProducts() {
  $$$
}' indexers/shopify-indexer.ts | rg 'batchSize'

Length of output: 587


Script:

#!/bin/bash
# Description: Check the usage of the batchSize parameter within the deleteProducts method.

# Search for the batchSize keyword within the indexers/shopify-indexer.ts file.
rg 'batchSize' indexers/shopify-indexer.ts -A 10 -B 10

Length of output: 1541

indexers/directory-indexer.ts (4)

8-8: LGTM! The batchSize parameter is introduced.

The batchSize parameter is optional and its introduction is consistent with the objective.


17-17: LGTM! The batchSize parameter is initialized.

The batchSize parameter is initialized in the constructor.


27-27: LGTM! The batchSize parameter is assigned.

The batchSize parameter is assigned from the options to the class property.


91-91: Verify the usage of the batchSize parameter in the processDocument method.

Ensure that the processDocument method correctly utilizes the batchSize parameter.

Verification successful

The batchSize parameter is correctly utilized in the processDocument method.

The batchSize parameter is used to check if the number of files has reached the batch size limit, and if so, it triggers the upsertDocuments method of the catalog and resets the files array.

  • indexers/directory-indexer.ts, lines 91-94:
    if (this.files.length >= this.batchSize) {
        await this.catalog.upsertDocuments(this.files);
        this.files = [];
    }
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the batchSize parameter in the processDocument method.

# Test: Search for the processDocument method definition. Expect: The method should use the batchSize parameter.
rg --type javascript 'processDocument'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the usage of the batchSize parameter in the processDocument method.

# Find the definition of the processDocument method in TypeScript files.
rg --type ts 'processDocument' --context 10

Length of output: 1750


Script:

#!/bin/bash
# Description: Extract the full implementation of the processDocument method.

# Extract the full method implementation from the indexers/directory-indexer.ts file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  private async processDocument($_, $_) {
    $$$
  }
  $$$  
}' 

Length of output: 6945

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4efa90e and c77ff05.

Files selected for processing (3)
  • indexers/directory-indexer.ts (3 hunks)
  • indexers/shopify-indexer.ts (2 hunks)
  • indexers/tsv-indexer.ts (4 hunks)
Files skipped from review as they are similar to previous changes (3)
  • indexers/directory-indexer.ts
  • indexers/shopify-indexer.ts
  • indexers/tsv-indexer.ts

@chaosrealm chaosrealm merged commit 5396765 into main Jul 3, 2024
3 checks passed
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.

Indexer batch sizes should be configurable through opts
2 participants