Skip to content

reverse scan apiの制限つき実装 #46

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

Merged
merged 2 commits into from
Dec 16, 2024
Merged

reverse scan apiの制限つき実装 #46

merged 2 commits into from
Dec 16, 2024

Conversation

kuron99
Copy link
Contributor

@kuron99 kuron99 commented Dec 16, 2024

https://github.com/project-tsurugi/tsurugi-issues/issues/1075 の一部として、 yakushima scanへ逆方向のscanを行うreverse scanのAPIを追加します。

現状の実装は下記の制限つきで、最大のエントリを取得するためのものになっています。(kvs.hにドキュメントしています)

  • max_size = 1 を一緒に渡す必要がある
  • r_endにはINFを渡す必要がある

リリース後すみやかにreverse scanの実装を拡張し、これらの制限を取り除く予定です。

実装内容の概要

  • masstreeをtraverseし、右端のborder nodeをたどることで最大のエントリを取得するという方針
  • find_borderを呼ぶ時点でright_to_left == true なら r_end=INFのはずなので、key_sliceに最大要素(0xFF....FF)をつめて探すようにする
  • find_borderで見つけたものをscan_borderに渡し、keyが最大のchildを探す(permutationのindexを逆順にたどる)
  • childがvalueでなくlinkである場合は下のレイヤに下がって再帰的に繰り返し
  • 最初の1個を見つけたら打ち切りなので、border_node::prev_ は使わない

@kuron99 kuron99 requested a review from ban-nobuhiro December 16, 2024 03:44
@kuron99
Copy link
Contributor Author

kuron99 commented Dec 16, 2024

無関係なコミットが入っていたのでforce pushしました。

Copy link
Contributor

@ban-nobuhiro ban-nobuhiro left a comment

Choose a reason for hiding this comment

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

スタイル的には二か所の if(right_to_left) の if の後の空白がないことが気になりました。
それ以外は、提示された制約下に限れば問題ないと思います。

@kuron99
Copy link
Contributor Author

kuron99 commented Dec 16, 2024

レビューありがとうございます。確かにスタイルが周辺のコードと異なりました。空白を追加しました。

@kuron99 kuron99 merged commit a68c4ca into master Dec 16, 2024
6 checks passed
@kuron99 kuron99 deleted the reverse_scan_api branch December 16, 2024 09:50
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