[fix] TimestampsFilter override get next cell hint
This commit is contained in:
@ -1621,13 +1621,13 @@ int TimestampsFilter::filter_cell(const ObHTableCell &cell, ReturnCode &ret_code
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TimestampsFilter::get_next_cell_hint(common::ObArenaAllocator &allocator, const ObHTableCell &cell, ObHTableCell *&new_cell)
|
||||
int TimestampsFilter::get_next_cell_hint(common::ObIAllocator &allocator, const ObHTableCell &cell, ObHTableCell *&new_cell)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (can_hint_) {
|
||||
ObTimestampNode key_node = ObTimestampNode(cell.get_timestamp());
|
||||
ObTimestampNode* found = nullptr;
|
||||
if (OB_FAIL(timestamps_.psearch(&key_node, found))) {
|
||||
if (OB_FAIL(timestamps_.nsearch(&key_node, found))) {
|
||||
OBLOG_LOG(WARN, "search node from tree failed", KR(ret), K(key_node));
|
||||
} else {
|
||||
if (found == NULL) {
|
||||
@ -1653,20 +1653,9 @@ int64_t TimestampsFilter::get_format_filter_string_length() const
|
||||
int TimestampsFilter::get_format_filter_string(char *buf, int64_t buf_len, int64_t &pos) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("buf is null", KR(ret));
|
||||
} else {
|
||||
int64_t n = snprintf(buf + pos, buf_len - pos, "TimestampsFilter");
|
||||
if (n < 0) {
|
||||
ret = OB_BUF_NOT_ENOUGH;
|
||||
LOG_WARN("snprintf error or buf not enough", KR(ret), K(n), K(pos), K(buf_len));
|
||||
} else {
|
||||
pos += n;
|
||||
if (OB_FAIL(ObHTableUtils::get_format_filter_string(buf, buf_len, pos, "TimestampsFilter"))) {
|
||||
LOG_WARN("failed to format filter string", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ public:
|
||||
}
|
||||
int init();
|
||||
virtual int filter_cell(const ObHTableCell &cell, ReturnCode &ret_code) override;
|
||||
int get_next_cell_hint(common::ObArenaAllocator &allocator, const ObHTableCell &cell, ObHTableCell *&new_cell);
|
||||
virtual int get_next_cell_hint(common::ObIAllocator &allocator, const ObHTableCell &cell, ObHTableCell *&new_cell) override;
|
||||
virtual bool is_hinting_filter() override { return can_hint_; }
|
||||
virtual int64_t get_format_filter_string_length() const override;
|
||||
virtual int get_format_filter_string(char *buf, int64_t buf_len, int64_t &pos) const override;
|
||||
|
@ -314,20 +314,33 @@ int ObHTableUtils::create_last_cell_on_row(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObHTableUtils::create_first_cell_on_row_col_ts(common::ObArenaAllocator &allocator,
|
||||
int ObHTableUtils::create_first_cell_on_row_col_ts(common::ObIAllocator &allocator,
|
||||
const ObHTableCell &cell,
|
||||
const int64_t timestamp,
|
||||
ObHTableCell *&new_cell)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObString rowkey_clone;
|
||||
ObString qualifier_clone;
|
||||
ObObj *last_cell = nullptr;
|
||||
ObNewRow *ob_row = nullptr;
|
||||
if (OB_FAIL(ob_write_string(allocator, cell.get_rowkey(), rowkey_clone))) {
|
||||
LOG_WARN("failed to clone rowkey", K(ret));
|
||||
} else {
|
||||
new_cell = OB_NEWx(ObHTableFirstOnRowColTSCell, (&allocator), rowkey_clone, timestamp);
|
||||
if (NULL == new_cell) {
|
||||
} else if (OB_FAIL(ob_write_string(allocator, cell.get_qualifier(), qualifier_clone))) {
|
||||
LOG_WARN("failed to clone qualifier", K(ret));
|
||||
} else if (OB_ISNULL(last_cell = static_cast<ObObj *>(allocator.alloc(sizeof(ObObj) * 3)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("no memory", K(ret));
|
||||
LOG_WARN("allocate memory for start_obj failed", K(ret));
|
||||
} else {
|
||||
last_cell[ObHTableConstants::COL_IDX_K].set_varbinary(rowkey_clone);
|
||||
last_cell[ObHTableConstants::COL_IDX_Q].set_varbinary(qualifier_clone);
|
||||
last_cell[ObHTableConstants::COL_IDX_T].set_int(timestamp);
|
||||
if (OB_ISNULL(ob_row = OB_NEWx(ObNewRow, (&allocator), last_cell, 3))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to allocator last NewRow on column timestamp.", K(ret));
|
||||
} else if (OB_ISNULL(new_cell = OB_NEWx(ObHTableCellEntity, (&allocator), ob_row, ObHTableCell::Type::NORMAL))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to allocator first entity on column timestamp.", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -145,22 +145,6 @@ private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHTableFirstOnRowColCell);
|
||||
};
|
||||
|
||||
class ObHTableFirstOnRowColTSCell: public ObHTableFirstOnRowCell
|
||||
{
|
||||
public:
|
||||
ObHTableFirstOnRowColTSCell(const common::ObString &rowkey, const int64_t timestamp)
|
||||
:ObHTableFirstOnRowCell(rowkey),
|
||||
timestamp_(timestamp)
|
||||
{}
|
||||
virtual ~ObHTableFirstOnRowColTSCell() {}
|
||||
|
||||
virtual int64_t get_timestamp() const override { return timestamp_; }
|
||||
virtual Type get_type() const { return Type::FIRST_ON_COL; }
|
||||
private:
|
||||
int64_t timestamp_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHTableFirstOnRowColTSCell);
|
||||
};
|
||||
|
||||
class ObHTableLastOnRowCell: public ObHTableEmptyCell
|
||||
{
|
||||
public:
|
||||
@ -340,7 +324,7 @@ public:
|
||||
/// Create a Cell that is smaller than all other possible Cells for the given Cell's rk:cf and passed qualifier.
|
||||
static int create_first_cell_on_row_col(common::ObIAllocator &allocator, const ObHTableCell &cell, const common::ObString &qualifier, ObHTableCell *&new_cell);
|
||||
/// Create a Cell that is smaller than all other possible Cells for the given Cell's rk:ts and passed timestamp.
|
||||
static int create_first_cell_on_row_col_ts(common::ObArenaAllocator &allocator, const ObHTableCell &cell, const int64_t timestamp, ObHTableCell *&new_cell);
|
||||
static int create_first_cell_on_row_col_ts(common::ObIAllocator &allocator, const ObHTableCell &cell, const int64_t timestamp, ObHTableCell *&new_cell);
|
||||
/// Create a Cell that is larger than all other possible Cells for the given Cell's row.
|
||||
static int create_last_cell_on_row(common::ObIAllocator &allocator, const ObHTableCell &cell, ObHTableCell *&new_cell);
|
||||
/// Create a Cell that is smaller than all other possible Cells for the given Cell's row.
|
||||
|
Reference in New Issue
Block a user