Skip to content

Conversation

@abhinvgpta
Copy link
Contributor

@abhinvgpta abhinvgpta commented Oct 13, 2025

Description

This pull request refactors the OnDemandBlockIndexInput class to create a more extensible AbstractBlockIndexInput class. The main changes are:

  1. Renaming and abstracting the class:

    • The OnDemandBlockIndexInput class has been renamed to AbstractBlockIndexInput.
    • AbstractBlockIndexInput is now an abstract class that serves as a generic base class for block-based index inputs.
    • This change allows the AbstractBlockIndexInput to be used as a parent class for any block-based index input implementation, not just the "on-demand" use case.
  2. Introducing utility methods:

    • Several static utility methods have been added to AbstractBlockIndexInput to handle common block-related operations, such as:
      • getBlockSize: Calculates the block size based on the provided block size shift.
      • getBlock: Calculates the block ID for a given file offset.
      • getBlockOffset: Calculates the offset within a block for a given file offset.
      • getBlockStart: Calculates the starting file offset of a given block.
      • getNumberOfBlocks: Calculates the total number of blocks for a given file size.
      • getActualBlockSize: Calculates the actual size of a given block.
      • getAllBlockIdsForFile: Returns a list of all block IDs for a given file.
      • isBlockFilename: Checks if a given file name follows the block file naming convention.
      • getBlockFileName: Generates a block file name based on the original file name and block ID.
      • getFileNameFromBlockFileName: Extracts the original file name from a block file name.
    • These utility methods provide a consistent and reusable set of operations for working with block-based index inputs, simplifying the implementation of specific index input classes.
  3. Updating the OnDemandBlockSnapshotIndexInput class:

    • The OnDemandBlockSnapshotIndexInput class, which was previously extending OnDemandBlockIndexInput, has been updated to extend the new AbstractBlockIndexInput class.
    • This change allows OnDemandBlockSnapshotIndexInput to leverage the new utility methods provided by AbstractBlockIndexInput, simplifying its implementation.
  4. Documentation updates:

    • Javadoc comments have been added to the new utility methods in AbstractBlockIndexInput to explain their purpose and usage.
    • The Javadoc comments for the OnDemandBlockSnapshotIndexInput class have been updated to reflect the changes.

The goal of these changes is to create a more extensible and reusable base class for handling block-based index inputs. By abstracting the common block-related functionality into the AbstractBlockIndexInput class, the changes pave the way for other block-based index input implementations to leverage this infrastructure, promoting code reuse and maintainability.

Related Issues

Check List

  • Functionality includes testing.
  • [ ] API changes companion pull request created, if applicable.
  • [ ] Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…BlockIndexInput is an abstract class containing all the common operations for block index inputs. Also added static utility methods for common block operations.

Signed-off-by: Abhinav Gupta <[email protected]>
@github-actions
Copy link
Contributor

❌ Gradle check result for 11e5a4f: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@ashking94 ashking94 changed the title Renamed OnDemandBlockIndexInput to AbstractBlockIndexInput and added utility methods to the same. Refactor OnDemandBlockIndexInput to AbstractBlockIndexInput for extensibility Oct 14, 2025
@github-actions
Copy link
Contributor

❌ Gradle check result for 11e5a4f: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@abhinvgpta abhinvgpta changed the title Refactor OnDemandBlockIndexInput to AbstractBlockIndexInput for extensibility Refactored OnDemandBlockIndexInput Oct 14, 2025
…e utility methods. Corrected test cases.

Signed-off-by: Abhinav Gupta <[email protected]>
@github-actions
Copy link
Contributor

✅ Gradle check result for 1e73dc4: SUCCESS

@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.10%. Comparing base (2695c93) to head (1e73dc4).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19613      +/-   ##
============================================
+ Coverage     73.06%   73.10%   +0.03%     
- Complexity    70630    70692      +62     
============================================
  Files          5723     5723              
  Lines        323513   323529      +16     
  Branches      46852    46853       +1     
============================================
+ Hits         236384   236517     +133     
+ Misses        68013    67982      -31     
+ Partials      19116    19030      -86     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ashking94 ashking94 changed the title Refactored OnDemandBlockIndexInput Refactor OnDemandBlockIndexInput to AbstractBlockIndexInput for extensibility Oct 15, 2025
@ashking94 ashking94 merged commit 5468936 into opensearch-project:main Oct 15, 2025
39 of 40 checks passed
peteralfonsi pushed a commit to peteralfonsi/OpenSearch that referenced this pull request Oct 15, 2025
…sibility (opensearch-project#19613)

* Renaming OnDemandBlockIndexInput to AbstractBlockIndexInput. AbstractBlockIndexInput is an abstract class containing all the common operations for block index inputs. Also added static utility methods for common block operations.

Signed-off-by: Abhinav Gupta <[email protected]>

* Added missing documentation for the utility methods. Removed duplicate utility methods. Corrected test cases.

Signed-off-by: Abhinav Gupta <[email protected]>

---------

Signed-off-by: Abhinav Gupta <[email protected]>
rgsriram pushed a commit to rgsriram/OpenSearch that referenced this pull request Oct 18, 2025
…sibility (opensearch-project#19613)

* Renaming OnDemandBlockIndexInput to AbstractBlockIndexInput. AbstractBlockIndexInput is an abstract class containing all the common operations for block index inputs. Also added static utility methods for common block operations.

Signed-off-by: Abhinav Gupta <[email protected]>

* Added missing documentation for the utility methods. Removed duplicate utility methods. Corrected test cases.

Signed-off-by: Abhinav Gupta <[email protected]>

---------

Signed-off-by: Abhinav Gupta <[email protected]>
kh3ra pushed a commit to kh3ra/OpenSearch that referenced this pull request Oct 23, 2025
…sibility (opensearch-project#19613)

* Renaming OnDemandBlockIndexInput to AbstractBlockIndexInput. AbstractBlockIndexInput is an abstract class containing all the common operations for block index inputs. Also added static utility methods for common block operations.

Signed-off-by: Abhinav Gupta <[email protected]>

* Added missing documentation for the utility methods. Removed duplicate utility methods. Corrected test cases.

Signed-off-by: Abhinav Gupta <[email protected]>

---------

Signed-off-by: Abhinav Gupta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants