Skip to content

Conversation

@jeltsch
Copy link
Collaborator

@jeltsch jeltsch commented Nov 13, 2024

This pull request moves Append and append out of Database.LSMTree.Internal.IndexCompact. The reason is that Append is not specific to the compact index and append will not be either once the class of index types is introduced. The target of this move is a new module for indexes in general, situated in the extras package, as only tests and benchmarks are using Append and append.

Comment on lines -129 to -148
-- | Min\/max key-info for pages
data Append =
-- | One or more keys are in this page, and their values fit within a single
-- page.
AppendSinglePage SerialisedKey SerialisedKey
-- | There is only one key in this page, and it's value does not fit within
-- a single page.
| AppendMultiPage SerialisedKey Word32 -- ^ Number of overflow pages

instance NFData Append where
rnf (AppendSinglePage kmin kmax) = rnf kmin `seq` rnf kmax
rnf (AppendMultiPage k nOverflow) = rnf k `seq` rnf nOverflow

-- | Append a new page entry to a mutable compact index.
--
-- INVARIANTS: see [construction invariants](#construction-invariants).
append :: Append -> IndexCompactAcc s -> ST s [Chunk]
append (AppendSinglePage kmin kmax) ica = toList <$> appendSingle (kmin, kmax) ica
append (AppendMultiPage k n) ica = appendMulti (k, n) ica

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small suggestion for PR review ergonomics: when code is moved to a different module and subsequently changed as well, it's hard to see from the diff what the interesting code changes are. My usual approach is to move the code in one commit, and do the interesting changes in a different commit.

Right now we're only talking about a small bit of code, so it's fine and doesn't have to change in this PR, but it might be good to keep in mind for future PRs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My usual approach is to move the code in one commit, and do the interesting changes in a different commit.

Sounds very reasonable to me. I’ll try to remember this approach and use it in future pull requests of mine. Sadly, Git essentially doesn’t track file movement. Well, its manual page calls it right at the beginning “the stupid content tracker”. 😉

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One scenario where Git is smart enough is when a file is first moved and then its contents are changed. The diff will show that the file is renamed, instead of showing that one file was deleted and one new file was created. And the diff of the renamed file just shows the changed lines, not the unchanged lines. But that's about as smart as it gets in my experience

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it’s only based on heuristics: as soon as the old and the new content differ too much, Git will treat the old and the new file as unrelated, which according to my experience can happen even if they are morally the same file and you as a human can easily see the similarities of the old and the new content.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, now I wonder whether this mishap might have been because of me not actually moving the file but only moving its contents. Does Git perhaps track inode numbers? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the answer: Git does not track inode numbers. It detects renames based on content only. See the documentation of the -M option in the git-diff(1) man page.

Copy link
Collaborator

@jorisdral jorisdral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Let's squash and then press merge

@jeltsch jeltsch force-pushed the jeltsch/append-separation branch from 0bf6c30 to 114c2c9 Compare November 15, 2024 17:40
@jeltsch jeltsch force-pushed the jeltsch/append-separation branch from 114c2c9 to 3dbb4e3 Compare November 15, 2024 17:41
@jeltsch jeltsch enabled auto-merge November 15, 2024 17:52
@jeltsch jeltsch added this pull request to the merge queue Nov 15, 2024
Merged via the queue into main with commit 7c90cd7 Nov 15, 2024
24 checks passed
@jeltsch jeltsch deleted the jeltsch/append-separation branch November 15, 2024 18:44
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.

3 participants