Implement generalized btree push, note the boundary conditions when id=weight

This really just required care around calculating the expected B-tree id
and rbyd id (which are different!).

B-tree append, aka B-tree push with id=weight, is actually the outlier.
We need a B-tree id that can identify the rbyd we're appending to, but
this id itself doesn't exist in the tree yet, which can be a bit tricky.
This commit is contained in:
Christopher Haster
2023-03-07 13:04:57 -06:00
parent d6a2666614
commit 0a3c6b39c1
4 changed files with 276 additions and 36 deletions
+18 -2
View File
@@ -114,6 +114,22 @@ static inline uint32_t lfs_min(uint32_t a, uint32_t b) {
return (a < b) ? a : b;
}
static inline uint32_t lfs_max32(uint32_t a, uint32_t b) {
return (a > b) ? a : b;
}
static inline uint32_t lfs_min32(uint32_t a, uint32_t b) {
return (a < b) ? a : b;
}
static inline int32_t lfs_smax32(int32_t a, int32_t b) {
return (a > b) ? a : b;
}
static inline int32_t lfs_smin32(int32_t a, int32_t b) {
return (a < b) ? a : b;
}
// TODO how many of these do we actually need
// Swap two 16-bit numbers
static inline void lfs_swap16(uint16_t *a, uint16_t *b) {
@@ -122,7 +138,7 @@ static inline void lfs_swap16(uint16_t *a, uint16_t *b) {
*b = t;
}
static inline void lfs_swaps16(int16_t *a, int16_t *b) {
static inline void lfs_sswap16(int16_t *a, int16_t *b) {
int16_t t = *a;
*a = *b;
*b = t;
@@ -135,7 +151,7 @@ static inline void lfs_swap32(uint32_t *a, uint32_t *b) {
*b = t;
}
static inline void lfs_swaps32(int32_t *a, int32_t *b) {
static inline void lfs_sswap32(int32_t *a, int32_t *b) {
int32_t t = *a;
*a = *b;
*b = t;