remove unused code
This commit is contained in:
@ -1,182 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX CLIENT
|
||||
#include "ob_htable.h"
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::table;
|
||||
using namespace oceanbase::table::hbase;
|
||||
int ObHTable::put(const ObHPut &put)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t N = put.get_column_count();
|
||||
ObHKVTable::Entities entities;
|
||||
for (int64_t i = 0; OB_SUCCESS == ret && i < N; ++i)
|
||||
{
|
||||
ObHCell cell;
|
||||
put.get_column(i, cell);
|
||||
|
||||
ObHKVTable::Key key;
|
||||
key.rowkey_ = put.get_row();
|
||||
// @todo ignore cell.get_column_family();
|
||||
key.column_qualifier_ = cell.get_column_qualifier();
|
||||
key.version_ = cell.get_timestamp();
|
||||
ObHKVTable::Value value;
|
||||
value.set_varbinary(cell.get_value());
|
||||
OHKVTable::Entity entity;
|
||||
entity.set_key(key);
|
||||
entity.set_value(value);
|
||||
|
||||
entities.push_back(entity);
|
||||
} // end for
|
||||
ret = hkv_table_->multi_put(entities);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObHTable::multi_put(const ObIArray<ObHPut> &puts)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const int64_t N = puts.count();
|
||||
for (int64_t i = 0; OB_SUCCESS == ret && i < N; ++i)
|
||||
{
|
||||
|
||||
} // end for
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObHTable::del(const ObHDelete &del)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObHTable::multi_del(const ObIArray<ObHDelete> &deletes);
|
||||
int ObHTable::mutate_row(const ObHRowMutations &row_mutations);
|
||||
|
||||
// with timestamp range or no timestamp
|
||||
int ObHTable::get_by_mscan_with_time_range(const ObHGet &get)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTableQuery query;
|
||||
|
||||
query.add_select_column(ObHKVTable::CQ_CNAME_STR);
|
||||
query.add_select_column(ObHKVTable::VERSION_CNAME_STR);
|
||||
query.add_select_column(ObHKVTable::VALUE_CNAME_STR);
|
||||
query.set_scan_order(ObQueryFlag::Forward);
|
||||
|
||||
ObHTableFilter htable_filter;
|
||||
htable_filter.set_max_versions(scan.get_max_versions());
|
||||
htable_filter.set_limit(scan.get_limit());
|
||||
|
||||
const int64_t N = get.get_column_count();
|
||||
for (int64_t i = 0; OB_SUCCESS == ret && i < N; ++i)
|
||||
{
|
||||
htable_filter.add_column(scan.get_qualifier(i));
|
||||
}
|
||||
query.set_htable_filter(htable_filter);
|
||||
|
||||
ObObj pk_objs_start[3];
|
||||
pk_objs_start[0].set_varbinary(get.get_row());
|
||||
pk_objs_start[1].set_min_value();
|
||||
pk_objs_start[2].set_min_value();
|
||||
ObObj pk_objs_end[3];
|
||||
pk_objs_end[0].set_varbinary(get.get_row());
|
||||
pk_objs_start[1].set_max_value();
|
||||
pk_objs_start[2].set_max_value();
|
||||
ObNewRange range;
|
||||
range.start_key_.assign(pk_objs_start, 3);
|
||||
range.end_key_.assign(pk_objs_end, 3);
|
||||
range.border_flag_.set_inclusive_start();
|
||||
range.border_flag_.unset_inclusive_end();
|
||||
query.add_scan_range(range);
|
||||
|
||||
ObTableEntityIterator *iter = nullptr;
|
||||
ret = hkv_table_->execute_query(query, iter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// with specific timestamp
|
||||
int ObHTable::get_by_mget(const ObHGet &get)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t N = get.get_column_count();
|
||||
ObHKVTable::Keys keys;
|
||||
for (int64_t i = 0; OB_SUCCESS == ret && i < N; ++i)
|
||||
{
|
||||
ObHCell cell;
|
||||
get.get_column(i, cell);
|
||||
|
||||
ObHKVTable::Key key;
|
||||
key.rowkey_ = put.get_row();
|
||||
// @todo ignore cell.get_column_family();
|
||||
key.column_qualifier_ = cell.get_column_qualifier();
|
||||
key.version_ = cell.get_timestamp();
|
||||
keys.push_back(entity);
|
||||
} // end for
|
||||
ObHKVTable::Values values;
|
||||
ret = hkv_table_->multi_get(keys, values);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObHTable::multi_get(const ObIArray<ObHGet> &gets);
|
||||
int ObHTable::scan(const ObHScan &scan)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObTableQuery query;
|
||||
|
||||
query.add_select_column(ObHKVTable::ROWKEY_CNAME_STR);
|
||||
query.add_select_column(ObHKVTable::CQ_CNAME_STR);
|
||||
query.add_select_column(ObHKVTable::VERSION_CNAME_STR);
|
||||
query.add_select_column(ObHKVTable::VALUE_CNAME_STR);
|
||||
|
||||
query.set_scan_order(scan.reversed() ? ObQueryFlag::Reversed : ObQueryFlag::Forward);
|
||||
|
||||
ObHTableFilter htable_filter;
|
||||
htable_filter.set_max_versions(scan.get_max_versions());
|
||||
htable_filter.set_limit(scan.get_limit());
|
||||
const int64_t N = scan.get_column_count();
|
||||
for (int64_t i = 0; OB_SUCCESS == ret && i < N; ++i)
|
||||
{
|
||||
htable_filter.add_column(scan.get_qualifier(i));
|
||||
}
|
||||
query.set_htable_filter(htable_filter);
|
||||
|
||||
ObObj pk_objs_start[3];
|
||||
pk_objs_start[0].set_varbinary(scan.get_start_row());
|
||||
pk_objs_start[1].set_min_value();
|
||||
pk_objs_start[2].set_min_value();
|
||||
ObObj pk_objs_end[3];
|
||||
pk_objs_end[0].set_varbinary(scan.get_stop_row());
|
||||
pk_objs_start[1].set_max_value();
|
||||
pk_objs_start[2].set_max_value();
|
||||
ObNewRange range;
|
||||
range.start_key_.assign(pk_objs_start, 3);
|
||||
range.end_key_.assign(pk_objs_end, 3);
|
||||
|
||||
if (scan.include_start_row()) {
|
||||
range.border_flag_.set_inclusive_start();
|
||||
} else {
|
||||
range.border_flag_.unset_inclusive_start();
|
||||
}
|
||||
if (scan.include_stop_row()) {
|
||||
range.border_flag_.set_inclusive_end();
|
||||
} else {
|
||||
range.border_flag_.unset_inclusive_end();
|
||||
}
|
||||
query.add_scan_range(range);
|
||||
query.set_batch(scan.get_batch());
|
||||
|
||||
ObTableEntityIterator *iter = nullptr;
|
||||
ret = hkv_table_->execute_query(query, iter);
|
||||
return ret;
|
||||
}
|
||||
@ -1,241 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef _OB_HTABLE_H
|
||||
#define _OB_HTABLE_H 1
|
||||
#include "ob_hkv_table.h"
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace table
|
||||
{
|
||||
/// HBase Interface
|
||||
namespace hbase
|
||||
{
|
||||
class ObHMutation
|
||||
{
|
||||
public:
|
||||
ObHMutation();
|
||||
virtual ~ObHMutation();
|
||||
const ObString &get_row() const;
|
||||
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHMutation);
|
||||
// function members
|
||||
protected:
|
||||
// data members
|
||||
ObString rowkey_;
|
||||
int64_t ts_;
|
||||
};
|
||||
|
||||
class ObHCell
|
||||
{
|
||||
public:
|
||||
const ObString &get_row();
|
||||
const ObString &get_column_family();
|
||||
const ObString &get_column_qualifier();
|
||||
int64_t get_timestamp();
|
||||
const ObString &get_value();
|
||||
};
|
||||
|
||||
// http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Put.html
|
||||
class ObHPut: public ObHMutation
|
||||
{
|
||||
public:
|
||||
ObHPut(const ObString &row);
|
||||
virtual ~ObHPut();
|
||||
int add_column(const ObString &family, const ObString &qualifier, int64_t ts, const ObString &value);
|
||||
int64_t get_column_count() const;
|
||||
int get_column(int64_t i, ObHCell &cell);
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHPut);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
// http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Delete.html
|
||||
class ObHDelete: public ObHMutation
|
||||
{
|
||||
public:
|
||||
ObHDelete(const ObString &row);
|
||||
virtual ~ObHDelete();
|
||||
/// Delete the latest version of the specified column.
|
||||
int add_column(const ObString &family, const ObString &qualifier);
|
||||
/// Delete the specified version of the specified column.
|
||||
int add_column(const ObString &family, const ObString &qualifier, int64_t timestamp);
|
||||
/// Delete all versions of the specified column.
|
||||
int add_columns(const ObString &family, const ObString &qualifier);
|
||||
/// Delete all versions of the specified column with a timestamp less than or equal to the specified timestamp.
|
||||
int add_columns(const ObString &family, const ObString &qualifier, int64_t timestamp);
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHDelete);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
class ObHRowMutation
|
||||
{
|
||||
public:
|
||||
ObHRowMutation(const ObString &row);
|
||||
virtual ~ObHRowMutation();
|
||||
|
||||
int add(const ObHMutation &mutation);
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHRowMutation);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
class ObHQuery
|
||||
{
|
||||
public:
|
||||
ObHQuery();
|
||||
virtual ~ObHQuery();
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHQuery);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
class ObHGet: public ObHQuery
|
||||
{
|
||||
public:
|
||||
ObHGet(const ObString &row);
|
||||
virtual ~ObHGet();
|
||||
/// Get the column from the specific family with the specified qualifier.
|
||||
int add_column(const ObString &family, const ObString &qualifier);
|
||||
/// Get all columns from the specified family.
|
||||
int add_family(const ObString &family);
|
||||
/// Get versions of columns with the specified timestamp.
|
||||
int set_timestamp(int64_t timestamp);
|
||||
/// Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).
|
||||
int set_time_range(int64_t min_stamp, int64_t max_stamp);
|
||||
/// Get up to the specified number of versions of each column.
|
||||
int read_versions(int32_t versions);
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHGet);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
|
||||
/// http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html
|
||||
class ObHScan: public ObHQuery
|
||||
{
|
||||
public:
|
||||
ObHScan();
|
||||
virtual ~ObHScan();
|
||||
|
||||
/// Set the start row of the scan.
|
||||
int with_start_row(const ObString &row, bool inclusive);
|
||||
/// Set the stop row of the scan.
|
||||
int with_stop_row(const ObString &row, bool inclusive);
|
||||
/// Get the column from the specified family with the specified qualifier.
|
||||
int add_column(const ObString &family, const ObString &qualifier);
|
||||
/// Get all columns from the specified family.
|
||||
int add_family(const ObString &family);
|
||||
/// Get versions of columns with the specified timestamp.
|
||||
int set_timestamp(int64_t timestamp);
|
||||
/// Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).
|
||||
int set_time_range(int64_t min_stamp, int64_t max_stamp);
|
||||
/// Get up to the specified number of versions of each column.
|
||||
int read_versions(int32_t versions);
|
||||
int read_all_versions();
|
||||
/// Set the maximum number of cells to return for each call to next().
|
||||
int set_batch(int32_t batch_size);
|
||||
/// Set the limit of rows for this scan.
|
||||
/// We will terminate the scan if the number of returned rows reaches this value.
|
||||
/// @param limit - the limit of rows for this scan
|
||||
int set_limit(int32_t limit);
|
||||
/// Set the maximum result size.
|
||||
/// The default is -1; this means that no specific maximum result size will be set for this scan.
|
||||
/// @param max_result_size - The maximum result size in bytes.
|
||||
int set_max_result_size(int64_t max_result_size);
|
||||
/// Set the maximum number of values to return per row per Column Family
|
||||
/// @param limit - the maximum number of values returned / row / CF
|
||||
int set_max_results_per_column_family(int32_t limit);
|
||||
/// Set offset for the row per Column Family.
|
||||
/// @param offset - is the number of kvs that will be skipped.
|
||||
int set_row_offset_per_column_family(int32_t offset);
|
||||
/// Set whether this scan is a reversed one
|
||||
int set_reversed(bool reversed);
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHScan);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
common::ObArenaAllocator alloc_;
|
||||
ObString start_row_;
|
||||
ObString stop_row_;
|
||||
bool include_start_row_;
|
||||
bool include_stop_row_;
|
||||
ObArray<ObString> qualifiers_;
|
||||
int64_t timestamp_;
|
||||
};
|
||||
|
||||
/// A HBase Table for demo
|
||||
class ObHTable
|
||||
{
|
||||
public:
|
||||
ObHTable();
|
||||
virtual ~ObHTable();
|
||||
|
||||
int put(const ObHPut &put);
|
||||
int multi_put(const ObIArray<ObHPut> &puts);
|
||||
int del(const ObHDelete &del);
|
||||
int multi_del(const ObIArray<ObHDelete> &deletes);
|
||||
/// Performs multiple mutations atomically on a single row.
|
||||
int mutate_row(const ObHRowMutations &row_mutations);
|
||||
int get(const ObHGet &get);
|
||||
int multi_get(const ObIArray<ObHGet> &gets);
|
||||
int scan(const ObHScan &scan);
|
||||
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObHTable);
|
||||
// function members
|
||||
private:
|
||||
// data members
|
||||
ObHKVTable *hkv_table_;
|
||||
};
|
||||
|
||||
} // end namespace hbase
|
||||
} // end namespace table
|
||||
} // end namespace oceanbase
|
||||
|
||||
#endif /* _OB_HTABLE_H */
|
||||
@ -1,86 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef _OB_KV_TABLE_H
|
||||
#define _OB_KV_TABLE_H 1
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace table
|
||||
{
|
||||
/** A Key-Value Table for HBase
|
||||
* 1. provide kv inerface like memcached
|
||||
* 2. the schema of each kvtable is 'create table kv (K varbinary(1024), V varbinary(1024), primary key(K)) partition by key(K) partitions 16;'
|
||||
*/
|
||||
class ObKVTable
|
||||
{
|
||||
public:
|
||||
/// Key type for ObKVTable
|
||||
typedef ObString Key;
|
||||
/// Value type for ObKVTable
|
||||
typedef ObObj Value;
|
||||
/// Entity of ObKVTable
|
||||
class Entity: public ObITableEntity
|
||||
{
|
||||
public:
|
||||
Entity();
|
||||
~Entity();
|
||||
|
||||
virtual void reset();
|
||||
virtual int set_rowkey(const ObRowkey &rowkey) override;
|
||||
virtual int set_rowkey(const ObITableEntity &other) override;
|
||||
virtual int set_rowkey_value(int64_t idx, const ObObj &value) override;
|
||||
virtual int add_rowkey_value(const ObObj &value) override;
|
||||
virtual int64_t get_rowkey_size() const override { return 1; }
|
||||
virtual int get_rowkey_value(int64_t idx, ObObj &value) const override;
|
||||
virtual int64_t hash_rowkey() const override;
|
||||
virtual int get_property(const ObString &prop_name, ObObj &prop_value) const override;
|
||||
virtual int set_property(const ObString &prop_name, const ObObj &prop_value) override;
|
||||
virtual int get_properties(ObIArray<std::pair<ObString, ObObj> > &properties) const override;
|
||||
virtual int get_properties_names(ObIArray<ObString> &properties) const override;
|
||||
virtual int get_properties_values(ObIArray<ObObj> &values) const override;
|
||||
|
||||
const Key &key() const { return key_; }
|
||||
const Value &value() const { return value_; }
|
||||
void set_key(const Key &k) { key_ = k;}
|
||||
void set_value(const Value &v) { value_ = v;}
|
||||
TO_STRING_KV(K_(key), K_(value));
|
||||
private:
|
||||
Key key_;
|
||||
Value value_;
|
||||
};
|
||||
public:
|
||||
int init(ObTableServiceClient &client, ObTable *tbl);
|
||||
void destroy();
|
||||
|
||||
int get(const Key &key, Value &value);
|
||||
int multi_get(const IKeys &keys, IValues &values);
|
||||
|
||||
int put(const Key &key, const Value &value);
|
||||
int multi_put(const IKeys &keys, const IValues &values);
|
||||
int multi_put(const IEntities &entities);
|
||||
|
||||
int remove(const Key &key);
|
||||
int multi_remove(const IKeys &keys);
|
||||
private:
|
||||
ObKVTable();
|
||||
virtual ~ObKVTable();
|
||||
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObKVTable);
|
||||
};
|
||||
|
||||
} // end namespace table
|
||||
} // end namespace oceanbase
|
||||
|
||||
#endif /* _OB_KV_TABLE_H */
|
||||
Reference in New Issue
Block a user