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

LabelsReader & LabelsWriter are less performant and more complex than necessary #197

Open
fasmat opened this issue Jul 21, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers performance

Comments

@fasmat
Copy link
Member

fasmat commented Jul 21, 2023

Reader

LabelsReader should implement the io.ReadSeekCloser interface and only ever open one file on the disk at a time. NewLabelsReader should receive the directory of containing the PoST data, do some basic checks of the existing files against the postmeta_data.json and then abstract the directory for the user of the object to treat it as if it was a single file.

Read and Seek should only ever open one file and if the file cannot be found or is smaller then expected return io.ErrUnexpectedEOF.

Writer

Similar to the Reader LabelsWriter should implement the io.WriteSeekCloser interface and transparently handle the writing of data to multiple files.

This would among others remove the need to handle individual files by the initializer.

Additional note

At the moment Diskstate does not stat files to get their file size but rather uses fs.DirEntry::Info() which reports an incorrect size if the PoST data directory contains soft-links to the files (e.g. on other disks). On linux this problem can be solved by instead stating the files with os.Stat to get their correct size. On other OSes this might work differently and needs to be tested.

@fasmat fasmat added enhancement New feature or request good first issue Good for newcomers performance labels Jul 21, 2023
@fasmat fasmat self-assigned this Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers performance
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant