Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
191 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #ifndef GRNXX_MERGER_HPP | ||
| #define GRNXX_MERGER_HPP | ||
|
|
||
| #include "grnxx/types.hpp" | ||
|
|
||
| namespace grnxx { | ||
|
|
||
| enum MergeStatus { | ||
| MERGE_CONTINUE, | ||
| MERGE_FINISH | ||
| }; | ||
|
|
||
| class Merger { | ||
| public: | ||
| Merger(); | ||
| virtual ~Merger(); | ||
|
|
||
| // 所属するテーブルを取得する. | ||
| virtual Table *table() const = 0; | ||
|
|
||
| // 行の一覧を合成する. | ||
| // 成功すれば出力された行数を返す. | ||
| // 失敗したときは *error にその内容を格納し, -1 を返す. | ||
| // | ||
| // 入力がまだ残っているときは MERGE_CONTINUE, | ||
| // 入力がもう残っていないときは MERGE_FINISH を指定する. | ||
| // | ||
| // lhs_row_set, rhs_row_set を入力として, | ||
| // 合成した結果を result_row_set に出力する. | ||
| // 合成に使用された行は lhs_row_set, rhs_row_set から取り除かれる. | ||
| // そのため,空になった方の入力に行を補充することで合成を継続できる. | ||
| // | ||
| // 入力は行 ID 昇順もしくは降順になっているものとする. | ||
| // また,入力はそれぞれ重複を含まないものとする. | ||
| // | ||
| // 失敗する状況としては,以下のようなものが挙げられる. | ||
| // - スコアが合成によって不正な値になる. | ||
| // - リソースが確保できない. | ||
| virtual int64_t merge(Error *error, | ||
| RowSet *lhs_row_set, | ||
| RowSet *rhs_row_set, | ||
| RowSet *result_row_set, | ||
| MergeStatus status) const = 0; | ||
| }; | ||
|
|
||
| } // namespace grnxx | ||
|
|
||
| #endif // GRNXX_MERGER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #ifndef GRNXX_ROW_SET_HPP | ||
| #define GRNXX_ROW_SET_HPP | ||
|
|
||
| #include "grnxx/types.hpp" | ||
|
|
||
| namespace grnxx { | ||
|
|
||
| class RowSet { | ||
| public: | ||
| RowSet(); | ||
| ~RowSet(); | ||
|
|
||
| // 所属するテーブルを取得する. | ||
| Table *table() const; | ||
|
|
||
| // 行 ID を取得する. | ||
| RowID get_row_id(Int64 i) const; | ||
| // スコアを取得する. | ||
| double get_score(Int64 i) const; | ||
|
|
||
| // スコアを正規化する. | ||
| // 成功すれば true を返す. | ||
| // 失敗したときは *error にその内容を格納し, false を返す. | ||
| // | ||
| // TODO: 具体的な正規化方法を決める. | ||
| // 最大値ですべてのスコアを除算するというのが簡単そうである. | ||
| // 正規化後の最大値を指定できると便利かもしれない. | ||
| // ほかにも何か必要な正規化があるかどうか. | ||
| // | ||
| // 失敗する状況としては,以下のようなものが挙げられる. | ||
| // - 最大値が 0.0, negative, infinity である. | ||
| bool normalize(Error *error, const NormalizeOptions &options); | ||
|
|
||
| // TODO: Sorter を使うより RowSet::sort() の方が良い? | ||
|
|
||
| // 整列する. | ||
| // 成功すれば true を返す. | ||
| // 失敗したときは *error にその内容を格納し, false を返す. | ||
| // | ||
| // TODO: 整列条件の指定方法を決める. | ||
| // | ||
| // 失敗する状況としては,以下のようなものが挙げられる. | ||
| // - リソースが足りない. | ||
| // - 演算において例外が発生する. | ||
| bool sort(Error *error, const SortConditions &conditions); | ||
| }; | ||
|
|
||
| } // namespace grnxx | ||
|
|
||
| #endif // GRNXX_ROW_SET_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.