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

pat: Fix the calculation for the target segment #2104

Merged
merged 4 commits into from
Nov 28, 2024

Conversation

abetomo
Copy link
Contributor

@abetomo abetomo commented Nov 27, 2024

When the next length to be added equals GRN_PAT_SEGMENT_SIZE, move on to the next segment.
But, if the size is the equal, it can be written to the current segment, so it was fixed so that it can be calculated correctly.

The grn_io layer allocates an space of GRN_PAT_SEGMENT_SIZE.

@@ -1036,7 +1036,7 @@ key_put(grn_ctx *ctx, grn_pat *pat, const uint8_t *key, uint32_t len)
return 0;
}

ts = (res + len) >> W_OF_KEY_IN_A_SEGMENT;
ts = (res + len - 1) >> W_OF_KEY_IN_A_SEGMENT;
Copy link
Member

Choose a reason for hiding this comment

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

テストを追加できる?

後で変数名もtail_segmentに変更しよう。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GRN_PAT_SEGMENT_SIZE ぴったり、-1、+1のデータを登録して、どのセグメントを使っているかのテストを追加しようと思ってるのですが、PATが今使っているセグメントの情報って取得できますか?
object_inspect とか check を見ていたのですが、欲しい情報が取得できなさそうに見えました。

そもそものテストの方針が良くない?

Copy link
Member

Choose a reason for hiding this comment

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

total_sizeでわからないんだっけ?

ピッタリ使っているならキーサイズと同じサイズがtotal_sizeになって、無駄使いしていたらキーサイズよりも大きくならない?

Copy link
Member

Choose a reason for hiding this comment

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

tail_segmentよりend_segmentとかの方がいいかな。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

total_size でわかりました。あざます。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ts って tail_segment の略だったのか!気づかなかった…。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

変数名の変更は別のPRにします。

abetomo added a commit to abetomo/groonga that referenced this pull request Nov 27, 2024
# 15 bytes per key.
# 4,194,304 / 15 = 279,620 with a remainder of 4.
# The data is a bit over from the first segment.
#@timeout 30
Copy link
Member

Choose a reason for hiding this comment

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

WindowsのCIで失敗しているからもう少し伸ばそうか。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

timeoutを増やしつつ、#2090 でも失敗してたのでrebaseした。

When the next length to be added equals `GRN_PAT_SEGMENT_SIZE`, move on to the next segment.
But, if the size is the equal, it can be written to the current segment, so it was fixed so that it can be calculated correctly.

The io layer allocates an space of `GRN_PAT_SEGMENT_SIZE`.
@abetomo abetomo force-pushed the fix-calculation-for-target-segment branch from c2a6ba3 to 49186d0 Compare November 27, 2024 06:32
@kou
Copy link
Member

kou commented Nov 28, 2024

rebaseしてみて。

@kou
Copy link
Member

kou commented Nov 28, 2024

あぁ、rebaseしても失敗したのか。

#2090 じゃダメだったかぁ。

@abetomo
Copy link
Contributor Author

abetomo commented Nov 28, 2024

re-runしてみる。

abetomo added a commit to abetomo/groonga that referenced this pull request Nov 28, 2024
@kou kou merged commit 556b9de into groonga:main Nov 28, 2024
31 of 35 checks passed
@kou
Copy link
Member

kou commented Nov 28, 2024

安定しないけどこのテストはパスしている気がするからマージしよう。

@abetomo abetomo deleted the fix-calculation-for-target-segment branch November 28, 2024 02:59
abetomo added a commit to abetomo/groonga that referenced this pull request Nov 29, 2024
abetomo added a commit to abetomo/groonga that referenced this pull request Nov 29, 2024
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.

2 participants