Navigation Menu

Skip to content

Commit

Permalink
Change the order of arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Jun 9, 2014
1 parent 882caeb commit 1b60523
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 91 deletions.
32 changes: 16 additions & 16 deletions new-interface/column.hpp
Expand Up @@ -32,10 +32,10 @@ class Column {
// - オプションの内容が不正である.
// - 十分なリソースを確保できない.
// - 索引の数が上限に達している.
virtual Index *create_index(const char *index_name,
virtual Index *create_index(Error *error,
const char *index_name,
IndexType index_type,
const IndexOptions &options,
Error *error) = 0;
const IndexOptions &options) = 0;
// 索引を破棄する.
// 成功すれば true を返す.
// 失敗したときは *error にその内容を格納し, false を返す.
Expand All @@ -45,7 +45,7 @@ class Column {
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された名前の索引が存在しない.
virtual bool drop_index(const char *index_name, Error *error) = 0;
virtual bool drop_index(Error *error, const char *index_name) = 0;

// 索引の名前を変更する.
// 成功すれば true を返す.
Expand All @@ -56,9 +56,9 @@ class Column {
// - 指定された名前(new)が索引名の条件を満たさない.
// - 指定された名前(new)の索引が存在する.
// - 変更前後の名前が同じときは何もせずに成功とする.
virtual bool rename_index(const char *index_name,
const char *new_index_name,
Error *error) = 0;
virtual bool rename_index(Error *error,
const char *index_name,
const char *new_index_name) = 0;

// 索引の順番を変更する.
// 成功すれば true を返す.
Expand All @@ -70,9 +70,9 @@ class Column {
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された名前の索引が存在しない.
virtual bool reorder_index(const char *index_name,
const char *prev_index_name,
Error *error) = 0;
virtual bool reorder_index(Error *error,
const char *index_name,
const char *prev_index_name) = 0;

// 索引を取得する.
// 成功すれば有効なオブジェクトへのポインタを返す.
Expand All @@ -84,15 +84,15 @@ class Column {
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された ID が有効な範囲にない.
virtual Index *get_index(IndexID index_id, Error *error) const = 0;
virtual Index *get_index(Error *error, IndexID index_id) const = 0;

// 索引を検索する.
// 成功すれば有効なオブジェクトへのポインタを返す.
// 失敗したときは *error にその内容を格納し, nullptr を返す.
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された名前の索引が存在しない.
virtual Index *find_index(const char *index_name, Error *error) const = 0;
virtual Index *find_index(Error *error, const char *index_name) const = 0;

// TODO: 機能から索引を検索する API が欲しい.
// たとえば,範囲検索に使える索引を探す,全文検索に使える索引を探すなど.
Expand All @@ -119,7 +119,7 @@ class Column {
// - 指定された値がカラムの制約にかかる.
// - リソースが確保できない.
// - 索引の更新に失敗する.
virtual bool set(RowID row_id, const Datum &datum, Error *error) = 0;
virtual bool set(Error *error, RowID row_id, const Datum &datum) = 0;

// 値を取得する.
// 成功すれば true を返す.
Expand All @@ -129,7 +129,7 @@ class Column {
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された行 ID が有効でない.
virtual bool get(RowID row_id, Datum *datum, Error *error) const = 0;
virtual bool get(Error *error, RowID row_id, Datum *datum) const = 0;

// 指定された条件を持たす行の ID を取得するためのカーソルを作成する.
// 成功すれば有効なオブジェクトへのポインタを返す.
Expand All @@ -142,8 +142,8 @@ class Column {
// - オプションが不正である.
// - リソースが確保できない.
virtual std::unique_ptr<Cursor> create_cursor(
const CursorOptions &options,
Error *error) const = 0;
Error *error,
const CursorOptions &options) const = 0;

protected:
Column();
Expand Down
40 changes: 19 additions & 21 deletions new-interface/db.hpp
Expand Up @@ -25,9 +25,9 @@ class DB {
// - オプションの内容が不正である.
// - 十分なリソースを確保できない.
// - テーブルの数が上限に達している.
virtual Table *create_table(const char *table_name,
const TableOptions &table_options,
Error *error) = 0;
virtual Table *create_table(Error *error,
const char *table_name,
const TableOptions &table_options) = 0;

// テーブルを破棄する.
// 成功すれば true を返す.
Expand All @@ -39,8 +39,8 @@ class DB {
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された名前のテーブルが存在しない.
// - 依存関係を解決できない.
virtual bool drop_table(const char *table_name,
Error *error) = 0;
virtual bool drop_table(Error *error,
const char *table_name) = 0;

// テーブルの名前を変更する.
// 成功すれば true を返す.
Expand All @@ -52,9 +52,9 @@ class DB {
// - 指定された名前(new)のテーブルが存在する.
// - 変更前後の名前が同じときは何もせずに成功とする.
// - 索引の更新に失敗する.
virtual bool rename_table(const char *table_name,
const char *new_table_name,
Error *error) = 0;
virtual bool rename_table(Error *error,
const char *table_name,
const char *new_table_name) = 0;

// テーブルの順番を変更する.
// 成功すれば true を返す.
Expand All @@ -66,9 +66,9 @@ class DB {
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された名前のテーブルが存在しない.
virtual bool reorder_table(const char *table_name,
const char *prev_table_name,
Error *error) = 0;
virtual bool reorder_table(Error *error,
const char *table_name,
const char *prev_table_name) = 0;

// テーブルを取得する.
// 成功すれば有効なオブジェクトへのポインタを返す.
Expand All @@ -80,16 +80,15 @@ class DB {
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された ID が有効な範囲にない.
virtual Table *get_table(TableID table_id,
Error *error) const = 0;
virtual Table *get_table(Error *error, TableID table_id) const = 0;

// テーブルを検索する.
// 成功すれば有効なオブジェクトへのポインタを返す.
// 失敗したときは *error にその内容を格納し, nullptr を返す.
//
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された名前のテーブルが存在しない.
virtual Table *find_table(const char *table_name, Error *error) const = 0;
virtual Table *find_table(Error *error, const char *table_name) const = 0;

// データベースの内容をファイルに出力する.
// 成功すれば true を返す.
Expand All @@ -114,9 +113,8 @@ class DB {
// - 指定された名前のファイルに対するアクセス権限がない.
// - 作業領域が確保できない.
// - ディスクの空き容量が足りない.
virtual bool save(const char *path,
const DBOptions &options,
Error *error) const = 0;
virtual bool save(Error *error, const char *path,
const DBOptions &options) const = 0;
};

// データベースを開く,もしくは作成する.
Expand All @@ -136,9 +134,9 @@ class DB {
// - 指定された名前のファイルに対するアクセス権限がない.
// - 指定された名前のファイルがデータベースのファイルではない.
// - データベースを構成するファイルが存在しない.
std::unique_ptr<DB> open_db(const char *path,
const DBOptions &options,
Error *error);
std::unique_ptr<DB> open_db(Error *error,
const char *path,
const DBOptions &options);

// データベースを削除する.
// 成功すれば true を返す.
Expand All @@ -152,7 +150,7 @@ std::unique_ptr<DB> open_db(const char *path,
// - 一部のファイルが欠けていても強制的に残りを削除するオプションは欲しい.
// - データベースを開かずにパスのみから推論して削除したいケースもありうる.
// - ファイルの削除に失敗する.
bool drop_db(const char *path, const DBOptions &options, Error *error);
bool drop_db(Error *error, const char *path, const DBOptions &options);

} // namespace grnxx

Expand Down
14 changes: 7 additions & 7 deletions new-interface/expression-builder.hpp
Expand Up @@ -22,8 +22,8 @@ class ExpressionBuilder {
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定された定数が異常値である.
// - リソースを確保できない.
virtual ExpressionNode *create_datum_node(const Datum &datum,
Error *error) = 0;
virtual ExpressionNode *create_datum_node(Error *error,
const Datum &datum) = 0;

// カラムに対応するノードを作成する.
// 成功すれば有効なオブジェクトへのポインタを返す.
Expand All @@ -32,8 +32,8 @@ class ExpressionBuilder {
// 失敗する状況としては,以下のようなものが挙げられる.
// - 指定されたカラムが存在しない.
// - リソースを確保できない.
virtual ExpressionNode *create_column_node(const char *column_name,
Error *error) = 0;
virtual ExpressionNode *create_column_node(Error *error,
const char *column_name) = 0;

// 演算子に対応するノードを作成する.
// 成功すれば有効なオブジェクトへのポインタを返す.
Expand All @@ -43,10 +43,10 @@ class ExpressionBuilder {
// - 演算子と引数が対応していない.
// - 演算子が求める引数の型・数と実際の引数の型・数が異なる.
// - リソースを確保できない.
virtual ExpressionNode *create_operator_node(OperatorType operator_type,
virtual ExpressionNode *create_operator_node(Error *error,
OperatorType operator_type,
int64_t num_args,
ExpressionNode **args,
Error *error) = 0;
ExpressionNode **args) = 0;

// すべてのノードを破棄する.
virtual void clear();
Expand Down
18 changes: 9 additions & 9 deletions new-interface/expression.hpp
Expand Up @@ -35,10 +35,10 @@ class Expression {
// - ゼロによる除算が発生する.
// - NaN が発生する.
// - TODO: これらの取り扱いについては検討の余地がある.
virtual int64_t filter(int64_t num_row_ids,
virtual int64_t filter(Error *error,
int64_t num_row_ids,
RowID *row_ids,
double *scores,
Error *error) = 0;
double *scores) = 0;

// スコアを調整する.
// 成功すれば true を返す.
Expand All @@ -56,10 +56,10 @@ class Expression {
// - ゼロによる除算が発生する.
// - NaN が発生する.
// - TODO: これらの取り扱いについては検討の余地がある.
virtual bool adjust(int64_t num_row_ids,
virtual bool adjust(Error *error,
int64_t num_row_ids,
RowID *row_ids,
double *scores,
Error *error) = 0;
double *scores) = 0;

// 行の一覧に対する評価結果を取得する.
// 成功すれば true を返す.
Expand All @@ -79,11 +79,11 @@ class Expression {
// - ゼロによる除算が発生する.
// - NaN が発生する.
// - TODO: これらの取り扱いについては検討の余地がある.
virtual bool evaluate(int64_t num_row_ids,
virtual bool evaluate(Error *error,
int64_t num_row_ids,
const RowID *row_ids,
const double *scores,
Datum *values,
Error *error) = 0;
Datum *values) = 0;
};

} // namespace grnxx
Expand Down
4 changes: 2 additions & 2 deletions new-interface/index.hpp
Expand Up @@ -30,8 +30,8 @@ class Index {
//
// TODO: 有効なオプションを取得できるようにしたい.
virtual std::unique_ptr<Cursor> create_cursor(
const CursorOptions &options,
Error *error) const = 0;
Error *error,
const CursorOptions &options) const = 0;
};

} // namespace grnxx
Expand Down
12 changes: 6 additions & 6 deletions new-interface/sorter-builder.hpp
Expand Up @@ -28,9 +28,9 @@ class Sorter {
// 失敗する状況としては,以下のようなものが挙げられる.
// - 式の評価結果が大小関係を持たない型になる.
// - リソースを確保できない.
virtual bool add_precondition(const Expression *expression,
SortOrder order,
Error *error) const = 0;
virtual bool add_precondition(Error *error,
const Expression *expression,
SortOrder order) const = 0;

// 整列条件を追加する.
// 成功すれば true を返す.
Expand All @@ -42,9 +42,9 @@ class Sorter {
// 失敗する状況としては,以下のようなものが挙げられる.
// - 式の評価結果が大小関係を持たない型になる.
// - リソースを確保できない.
virtual bool add_condition(const Expression *expression,
SortOrder order,
Error *error) const = 0;
virtual bool add_condition(Error *error,
const Expression *expression,
SortOrder order) const = 0;

// すべての条件を破棄する.
virtual void clear();
Expand Down
6 changes: 3 additions & 3 deletions new-interface/sorter.hpp
Expand Up @@ -23,9 +23,9 @@ class Sorter {
// 失敗する状況としては,以下のようなものが挙げられる.
// - 演算において例外が発生する.
// - リソースを確保できない.
virtual bool sort(int64_t num_row_ids, RowID *row_ids,
int64_t offset, int64_t limit,
Error *error);
virtual bool sort(Error *error,
int64_t num_row_ids, RowID *row_ids,
int64_t offset, int64_t limit);
};

} // namespace grnxx
Expand Down

0 comments on commit 1b60523

Please sign in to comment.