Navigation Menu

Skip to content

Commit

Permalink
Add RecordSet::subset().
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Jun 12, 2014
1 parent ef6cad9 commit d283fc7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
8 changes: 2 additions & 6 deletions new-interface/expression.hpp
Expand Up @@ -37,8 +37,7 @@ class Expression {
// - NaN が発生する.
// - TODO: これらの取り扱いについては検討の余地がある.
virtual int64_t filter(Error *error,
RecordSet *record_set,
int64_t offset) = 0;
RecordSet *record_set) = 0;

// スコアを調整する.
// 成功すれば true を返す.
Expand All @@ -60,8 +59,7 @@ class Expression {
// - NaN が発生する.
// - TODO: これらの取り扱いについては検討の余地がある.
virtual bool adjust(Error *error,
RecordSet *record_set,
int64_t offset) = 0;
RecordSet *record_set) = 0;

// 行の一覧に対する評価結果を取得する.
// 成功すれば true を返す.
Expand All @@ -76,8 +74,6 @@ class Expression {
// - リソースが確保できない.
virtual bool evaluate(Error *error,
const RecordSet &record_set,
int64_t offset,
int64_t limit,
Data *values) = 0;
};

Expand Down
26 changes: 20 additions & 6 deletions new-interface/record-set.hpp
Expand Up @@ -5,22 +5,36 @@

namespace grnxx {

struct Record {
RowID row_id;
double score;
};

class RecordSet {
public:
RecordSet();
~RecordSet();

// 所属するテーブルを取得する.
Table *table() const;
// レコード ID の最小値を取得する.
RecordID min_record_id() const;
// レコード ID の最大値を取得する.
RecordID max_record_id() const;
// レコード数を取得する.
int64_t num_records() const;

// レコードを取得する.
// 不正なレコード ID を指定したときの動作は未定義である.
Record get(int64_t i) const;

// 行 ID を取得する.
RowID get_row_id(RecordID record_id) const;
// 不正なレコード ID を指定したときの動作は未定義である.
RowID get_row_id(int64_t i) const;

// スコアを取得する.
double get_score(RecordID record_id) const;
// 不正なレコード ID を指定したときの動作は未定義である.
double get_score(int64_t i) const;

// 一部を取得する.
// 不正な範囲を指定したときの動作は未定義である.
RecordSet subset(int64_t offset, int64_t count) const;

// スコアを正規化する.
// 成功すれば true を返す.
Expand Down
1 change: 0 additions & 1 deletion new-interface/types.hpp
Expand Up @@ -31,7 +31,6 @@ using TableID = int64_t;
using ColumnID = int64_t;
using IndexID = int64_t;
using RowID = int64_t;
using RecordID = int64_t;

constexpr RowID NULL_ROW_ID = RowID(0);
constexpr RowID MIN_ROW_ID = RowID(1);
Expand Down

0 comments on commit d283fc7

Please sign in to comment.