34 : m_thrift(thrift), m_native_client(0), m_ns(0), m_native_table(0),
35 m_native_table_open(false), m_native_mutator(0), m_native_scanner(0) {
37 m_thrift_namespace = 0;
45 m_thrift_namespace = m_thrift_client->open_namespace(
"/");
47 HT_FATAL(
"Thrift support not installed");
57 : m_thrift(thrift), m_native_client(0), m_ns(0), m_native_table(0),
58 m_native_table_open(false), m_native_mutator(0), m_native_scanner(0) {
60 m_thrift_namespace = 0;
68 m_thrift_namespace = m_thrift_client->open_namespace(
"/");
70 HT_FATAL(
"Thrift support not installed");
81 ::uint64_t shared_mutator_flush_interval)
85 m_thrift_mutator = m_thrift_client->open_mutator(m_thrift_namespace,
86 tablename, mutator_flags, 0);
95 shared_mutator_flush_interval));
103 #ifdef HT_WITH_THRIFT
104 vector<ThriftGen::Cell> thrift_cells;
105 for (
const auto &cell : cells) {
107 (
const char*)cell.column_family,(
const char*)cell.column_qualifier,
108 string((
const char*)cell.value, cell.value_len), cell.timestamp,
109 cell.revision, (ThriftGen::KeyFlag::type) cell.flag));
111 m_thrift_client->mutator_set_cells(m_thrift_mutator, thrift_cells);
122 #ifdef HT_WITH_THRIFT
123 vector<ThriftGen::Cell> thrift_cells;
124 ThriftGen::KeyFlag::type flag = ThriftGen::KeyFlag::INSERT;
127 flag = ThriftGen::KeyFlag::DELETE_ROW;
129 flag = ThriftGen::KeyFlag::DELETE_CF;
131 flag = ThriftGen::KeyFlag::DELETE_CELL;
137 m_thrift_client->mutator_set_cells(m_thrift_mutator, thrift_cells);
149 #ifdef HT_WITH_THRIFT
150 m_thrift_client->flush_mutator(m_thrift_mutator);
162 #ifdef HT_WITH_THRIFT
164 ThriftGen::ScanSpec thrift_scan_spec;
165 ThriftGen::RowInterval thrift_row_interval;
166 thrift_row_interval.start_row = scan_spec.row_intervals[0].start;
167 thrift_row_interval.end_row = scan_spec.row_intervals[0].end;
168 thrift_row_interval.start_inclusive = scan_spec.row_intervals[0].start_inclusive;
169 thrift_row_interval.end_inclusive = scan_spec.row_intervals[0].end_inclusive;
170 thrift_row_interval.__isset.start_row = thrift_row_interval.__isset.end_row =
true;
171 thrift_row_interval.__isset.start_inclusive = thrift_row_interval.__isset.end_inclusive =
true;
173 thrift_scan_spec.columns.push_back(scan_spec.columns[0]);
174 thrift_scan_spec.row_intervals.push_back(thrift_row_interval);
175 thrift_scan_spec.__isset.columns = thrift_scan_spec.__isset.row_intervals =
true;
177 m_thrift_scanner = m_thrift_client->open_scanner(m_thrift_namespace,
178 tablename, thrift_scan_spec);
193 uint64_t bytes_scanned = 0;
195 #ifdef HT_WITH_THRIFT
196 vector<ThriftGen::Cell> cells;
199 m_thrift_client->next_cells(cells, m_thrift_scanner);
200 for (
const auto &cell : cells) {
201 bytes_scanned += cell.key.row.size() + cell.key.column_family.size()
202 + cell.key.column_qualifier.size() + 8 + 8 + 2
205 }
while (cells.size());
207 return bytes_scanned;
218 return bytes_scanned;
226 #ifdef HT_WITH_THRIFT
227 m_thrift_client->close_scanner(m_thrift_scanner);
238 #ifdef HT_WITH_THRIFT
239 m_thrift_client->close_namespace(m_thrift_namespace);
std::vector< Cell, CellAlloc > Cells
std::string String
A String is simply a typedef to std::string.
void set_cells(const Cells &cells)
uint64_t get_all_cells()
Get all cells that match the spec in the current scanner return the total number of bytes scanned...
const char * column_qualifier
const char * column_qualifier
LoadClient(const String &config_file, bool thrift=false)
void set_delete(const KeySpec &key)
Compatibility Macros for C/C++.
Cell make_cell(const char *row, const char *cf, const char *cq, const std::string &value, int64_t ts, int64_t rev, KeyFlag::type flag)
ClientPtr m_native_client
TableMutatorPtr m_native_mutator
const char * column_family
void create_mutator(const String &tablename, int mutator_flags,::uint64_t shared_mutator_flush_interval)
TableScannerPtr m_native_scanner
Encapsulates decomposed key and value.
void create_scanner(const String &tablename, const ScanSpec &scan_spec)
Create a scanner.
const char * column_family
A client for the ThriftBroker.