Navigation Menu

Skip to content

Commit

Permalink
Add SorterOptions and Sorter::create().
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Jun 23, 2014
1 parent d836f50 commit 1ee7bf9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions new-interface/sorter.hpp
Expand Up @@ -5,11 +5,38 @@

namespace grnxx {

struct SorterOptions {
// 整列結果から上位 offset 件を破棄する.
// 0 以上でなければならない.
int64_t offset;
// 整列結果から最大 limit 件を取得する.
// 1 以上でなければならない.
int64_t limit;

SorterOptions();
};

class Sorter {
public:
Sorter();
virtual ~Sorter();

// 整列器を作成する.
// 成功すれば有効なオブジェクトへのポインタを返す.
// 失敗したときは *error にその内容を格納し, nullptr を返す.
//
// 返り値は std::unique_ptr なので自動的に delete される.
// 自動で delete されて困るときは release() で生のポインタを取り出す必要がある.
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された式の評価結果が真偽値ではない.
// - オプションが不正である.
// - リソースが確保できない.
static std::unique_ptr<Sorter> create(
Error *error,
std::unique_ptr<Order> &&order,
const SorterOptions &options);

// 整列の対象となるレコードの一覧を設定する.
// 成功すれば true を返す.
// 失敗したときは *error にその内容を格納し, false を返す.
Expand Down

0 comments on commit 1ee7bf9

Please sign in to comment.