Skip to content

fileservice: remove LocalFS/S3FS.allocator - #16170

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
reusee:fsalloc
May 16, 2024
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
reusee:fsalloc

Conversation

@reusee

@reusee reusee commented May 16, 2024

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #15508

What this PR does / why we need it:

cache codes clean-up

@reusee
reusee requested a review from zhangxu19830126 May 16, 2024 04:08
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label May 16, 2024
@matrix-meow

Copy link
Copy Markdown
Contributor

@reusee Thanks for your contributions!

Pull Request Review:

Title:

The title of the pull request is clear and concise, indicating the removal of LocalFS/S3FS.allocator.

Body:

The body of the pull request provides information about the type of PR, the specific issue it fixes, and the reason for the changes, which is to clean up cache codes.

Changes:

  1. DiskCache:

    • The ReadFromOSFile method in disk_cache.go has been modified to call the readFromOSFile function instead of directly invoking entry.ReadFromOSFile.
    • The setCachedData method in io_entry.go has been refactored to accept a generic type for the allocator parameter.
    • The readFromOSFile function in io_entry.go has been refactored to accept a generic type for the allocator parameter.
  2. LocalETLFS:

    • The Read method in local_etl_fs.go now calls the setCachedData function with the entry passed as a reference.
  3. LocalFS:

    • The LocalFS struct in local_fs.go no longer contains the allocator field.
    • The NewLocalFS function in local_fs.go has been modified to remove the assignment of fs.allocator.
    • The read method in local_fs.go has been updated to call the setCachedData function with the entry passed as a reference.
  4. MemoryFS:

    • The Read method in memory_fs.go now calls the setCachedData function with the entry passed as a reference.
  5. S3FS:

    • The S3FS struct in s3_fs.go no longer contains the allocator field.
    • The NewS3FS function in s3_fs.go has been modified to remove the assignment of fs.allocator.
    • The read method in s3_fs.go has been updated to call the setCachedData function with the entry passed as a reference.

Feedback and Suggestions:

  1. Generic Type for Allocator:

    • The refactoring of the setCachedData and readFromOSFile functions to accept a generic type for the allocator parameter is a good improvement.
    • However, the generic type declaration setCachedData[P interface {...}] and readFromOSFile[P interface {...}] seems to be incorrect syntax. It should be corrected to a valid Go syntax for generics if applicable.
    • Consider revisiting the generic type implementation to ensure it follows the correct syntax and usage for Go generics.
  2. Redundant Code Removal:

    • The removal of the LocalFS/S3FS.allocator field from the LocalFS and S3FS structs is a positive change as it eliminates redundant code.
    • Ensure that all references to the removed allocator field are updated and no functionality is affected by its removal.
  3. Consistency:

    • Ensure that the changes made in different files are consistent and follow the same pattern to maintain code readability and maintainability.
    • Check if there are any other areas in the codebase where similar improvements can be applied for consistency.
  4. Testing:

    • It is important to ensure that the changes do not introduce any regressions or break existing functionality.
    • Consider adding or updating unit tests to cover the modified functions and methods to validate the changes thoroughly.
  5. Optimization:

    • Look for opportunities to optimize the code further, such as improving performance or reducing complexity where possible.
    • Consider reviewing other parts of the codebase for potential optimizations or enhancements.
  6. Documentation:

    • Ensure that the code changes are well-documented, especially regarding the refactored functions and methods.
    • Update any relevant documentation to reflect the changes made in this pull request.

By addressing the feedback provided and ensuring the correctness and consistency of the changes, the codebase can be improved in terms of maintainability and readability.

@mergify
mergify Bot merged commit 9571a73 into matrixorigin:main May 16, 2024
reusee added a commit to reusee/matrixone that referenced this pull request May 17, 2024
reusee added a commit to reusee/matrixone that referenced this pull request Jun 6, 2024
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants