-
Notifications
You must be signed in to change notification settings - Fork 0
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
Replaced scan_info definition with the range class #129
Conversation
f3cc94f
to
d304948
Compare
@kuron99 scan_infoをrangeに書き換えました。まだtestを通ってませんのでtestが通るように随時調整していきます |
d304948
to
cb49132
Compare
テスト失敗メモ場所api_test.scan_with_host_variable
テスト考察実際のQueryは通るのでテスト固有の問題
|
@YoshiakiNishimura 変更前のコードだと下記部分で「レンジの上端または下端がNULLの場合はnot foundにする」というケアをしているのでこのパスが変更後にどうなったかを調べてもらうといいかもしれません。
|
問題の箇所は以下です
直観として下のコードを書いた場合、上のreturnを通りそうですが、従来はどのような考えで上の処理を通らないようにしていたのですか? ps->set_null("p0");
std::vector<mock::basic_record> result{};
execute_query("SELECT * FROM T0 WHERE C0 < :p0", variables, *ps, result); |
上のreturnを通っていたと思いますよ。通ったうえでその戻り値 status::err_integrity_constraint_violationが、#129 (comment) のところまで行って、NULLが検知されたことをケアするという動きになっていました。 |
考え方としては、INSERT文などでnon-nullableなフィールドにnullをアサインしようとするとNULL制約違反のためencode_keyはstatus::err_integrity_constraint_violationを戻すのですが、encode_keyをscanに使用した場合は条件文の中の話なのでNULL制約違反とはいえなくて「その条件で検索しても何もみつからない」というscanになになります。 厳密にはencode_keyがerr_integrity_constraint_violationを戻すのはやりすぎで「エンコードしようとしたものがNULLだった」ということを返して呼び出し側が判定すべきですが、encode_keyは古いコードでよくないですね。 |
原因わかりました。
152行でreturnします。 今回details::encode_keyを前に移動して下記の通り処理してますので152行でreturnしません。 auto status_result = details::two_encode_keys(request_context_,
details::create_search_key_fields(secondary_or_primary_index, node.lower().keys(), *info_),
details::create_search_key_fields(secondary_or_primary_index, node.upper().keys(), *info_),
vars, *resource_ptr, *key_begin, blen, *key_end, elen);
if (status_result != status::ok) {
auto msg = string_builder{} << to_string_view(status_result) << string_builder::to_string;
throw_exception(jogasaki::plan::impl::compile_exception{create_error_info(
error_code::sql_execution_exception, msg, status::err_compiler_error)});
} 今回scan_infoをrangeにしてbegin_,end_だけにしましたが、scan::openにstatus::err_integrity_constraint_violationの情報を伝えるために情報を保持する、statusメンバーを追加いたします。 class range
private:
std::unique_ptr<bound> begin_;
std::unique_ptr<bound> end_;
}; |
scan結果が空になるということを伝えるためですよね。であれば、statusメンバではなく |
286bf39
to
c492896
Compare
c492896
to
5323388
Compare
@kuron99 |
@@ -48,15 +48,15 @@ class processor : public process::abstract::processor { | |||
* @param io_info input/output information | |||
* @param relation_io_map mapping from relation to input/output indices | |||
* @param io_exchange_map map from input/output to exchange operator | |||
* @param resource the memory resource to build the structures needed by this processor | |||
* @param request_context memory resource for initializing and managing processor structures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
渡しているものは request_contextで、コメントの説明は memory resource
と言っているのでズレがあります。
あくまで渡すmemory resourceの説明をしたいなら、request_context to pass memory resource ...
あたりでしょうか。
@@ -57,15 +57,15 @@ class task_context : public abstract::task_context { | |||
* @brief create new object | |||
* @param partition the index of partition assigned to this object (used as index of source on the input exchange) | |||
* @param io_exchange_map mapping from input/output indices to exchanges | |||
* @param scan_info the scan information, nullptr if the task doesn't contain scan | |||
* @param range the range information, nullptr if the task doesn't contain range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the task doesn't contain range
の最後の range
は scan
のままでいいです。タスクが scan処理を含まなければscan_infoやrangeの指定は不要だという意味なので。
{ | ||
(void)resource_; //TODO remove if not necessary | ||
} | ||
operator_builder::operator_builder(std::shared_ptr<processor_info> info, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このファイル全体にフォーマッターが適用されているように見えますが、意図的なものでしょうか?
不要なフォーマット変更がdiffに含まれているようなので、レビューしやすいように今回の変更に必要なものだけにしてもらえますか。
もしフォーマットを一括で変更したい場合は別途相談してください。
またその場合もレビューの邪魔にならないようにコミットを分けて適用しましょう。
@@ -83,14 +83,14 @@ class operator_builder { | |||
* @param compiler_ctx compiler context | |||
* @param io_info I/O information | |||
* @param relation_io_map mapping from relation to I/O index | |||
* @param resource the memory resource used to building operators | |||
* @param request_context the memory resource used to building operators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the memory resource used to building operators
の部分も合わせて変更してください。
*/ | ||
class scan_info { | ||
public: | ||
class range { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
趣味の問題に近いですが、rangeという単純名だとstd::rangeみたいなものもあるので、scan_rangeあたりにしませんか?rangeだと一般名で検索でヒットしすぎるので少しだけ修飾したいという思いです。
range& operator=(range const& other) = delete; | ||
range(range&& other) noexcept = default; | ||
range& operator=(range&& other) noexcept = default; | ||
[[nodiscard]] bound const* begin() const noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rangeが保持するboundがnullptrであるという状態はどういうレンジを表現していると考えるべきでしょうか?もしその状態が必須でなければ、レンジは必ずboundを持つことにして、この関数の戻り値を bound const&
にしてもいいような気がします。その方が呼び出し側で boundがnullptrがどうかというチェックが不要になるので使いやすそう。
@@ -238,6 +237,7 @@ inline std::ostream& operator<<(std::ostream& out, storage const& value) { | |||
out << "storage(handle:" << std::hex << value.handle() << ")"; | |||
return out; | |||
} | |||
|
|||
end_point_kind adjust_endpoint_kind(bool use_secondary, kvs::end_point_kind endpoint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc commentを追加して用途と目的を簡単に書いてください。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビューしてコメントしました。
7d71a44
to
75b8abf
Compare
@kuron99 指摘反映しました |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すごい細かい話ですが、ファイルの末尾に改行だけを含む空の行を追加してもらえますか?
古いC言語の規約でファイル末尾は空の行でないとならないという話があって、最近のC++では関係ないはずなのですが、各種フォーマッタがこれに準じて勝手に空行を挿入しgitにdiffとして検出されてしまうことがあるので。
: begin_(std::move(begin)), end_(std::move(end)), is_empty_(is_empty) { | ||
|
||
BOOST_ASSERT(&begin_); | ||
BOOST_ASSERT(&end_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この2つのassertはthisがnullptrになる場合くらいしかfalseにならないのであまり意味がなさそうに見えます。
@@ -20,18 +20,17 @@ | |||
|
|||
namespace jogasaki::executor::process::impl { | |||
|
|||
class range : public abstract::range { | |||
class scan_range : public abstract::range { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scan_rangeをコンテナに入れることがありそうな気がするので、デフォルトコンストラクタも追加しませんか。空のレンジ(is_empty_ = true)を作るものということにするといいと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
クラス名に合わせてファイル名も scan_range.h/.cpp
へ変更お願いします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらのファイルも末尾に空行追加おねがいします。
@@ -39,14 +39,14 @@ class operator_container { | |||
* @param root the root of the operator tree | |||
* @param operator_count the number of operators | |||
* @param io_exchange_map the mapping from input/output index to exchange | |||
* @param range the range gathered from the scan operator in the operator tree (if any). | |||
* @param scan_range the range gathered from the scan operator in the operator tree (if any). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param
の直後は変数名なのでここは range
のままでOKです。
@@ -53,7 +53,7 @@ class scan_context : public context_base { | |||
std::unique_ptr<kvs::storage> stg, | |||
std::unique_ptr<kvs::storage> secondary_stg, | |||
transaction_context* tx, | |||
impl::range const* range_, | |||
impl::scan_range const* range_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
仮変数名は末尾のアンダースコア不要ですね。
|
||
} | ||
|
||
} // jogasaki::executor::process::mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも空行を維持でお願いします。
}; | ||
|
||
} | ||
} // namespace jogasaki::executor::process::mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも空行を維持でお願いします。
src/jogasaki/data/aligned_buffer.cpp
Outdated
|
||
} | ||
|
||
} // namespace jogasaki::data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも空行を維持でお願いします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビュー完了しました。ファイル末尾の空行は全部指摘していませんが、抜けているものがあれば空行を維持する方向でお願いします。
726575d
to
0814847
Compare
@YoshiakiNishimura #129 (comment) だけまだ未対応でしょうか? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上記( #129 (comment) )が完了したらマージしてもらってOKです。
0814847
to
bb0ff5e
Compare
#127 の続き