Skip to content

Commit

Permalink
Calculate segments correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
abetomo committed Nov 29, 2024
1 parent e254993 commit 9dc4757
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/pat.c
Original file line number Diff line number Diff line change
Expand Up @@ -6280,10 +6280,10 @@ grn_pat_defrag(grn_ctx *ctx, grn_pat *pat)
for (size_t i = 0; i < n_targets; i++) {
pat_node *node = pat_get(ctx, pat, target_ids[i]);
uint32_t key_length = PAT_LEN(node);
uint32_t new_tail_segment =
(new_curr_key + key_length) >> W_OF_KEY_IN_A_SEGMENT;
if (new_curr_key >> W_OF_KEY_IN_A_SEGMENT != new_tail_segment) {
new_curr_key = new_tail_segment << W_OF_KEY_IN_A_SEGMENT;
uint32_t new_end_segment =
(new_curr_key + key_length - 1) >> W_OF_KEY_IN_A_SEGMENT;
if (new_curr_key >> W_OF_KEY_IN_A_SEGMENT != new_end_segment) {
new_curr_key = new_end_segment << W_OF_KEY_IN_A_SEGMENT;
}

uint8_t *key_position = NULL;
Expand Down

0 comments on commit 9dc4757

Please sign in to comment.