36 #include <boost/progress.hpp>
52 unique_ptr<boost::progress_display> progress;
57 :
HqlInterpreter::Callback(interp.normal_mode()), commander(interp),
60 == CommandInterpreter::TIMESTAMP_FORMAT_NANOS;
65 if (output == stdout || output == stderr)
73 void on_return(
const string &
str)
override { cout << str << endl; }
75 void on_update(
size_t total)
override {
84 <<
" bytes of input data..." << endl;
85 progress = make_unique<boost::progress_display>(total);
89 void on_progress(
size_t amount)
override {
95 Callback::on_finish(mutator);
99 if (progress && progress->count() < file_size)
100 *progress += file_size - progress->count();
102 double elapsed = stopwatch.
elapsed();
105 fprintf(stderr,
"Load complete.\n");
108 fprintf(stderr,
" Elapsed time: %.2f s\n", elapsed);
110 if (total_values_size)
111 fprintf(stderr,
"Avg value size: %.2f bytes\n",
112 (
double)total_values_size / total_cells);
115 fprintf(stderr,
" Avg key size: %.2f bytes\n",
116 (
double)total_keys_size / total_cells);
118 if (total_keys_size && total_values_size) {
119 fprintf(stderr,
" Throughput: %.2f bytes/s",
120 (total_keys_size + total_values_size) / elapsed);
123 fprintf(stderr,
" (%.2f bytes/s)", file_size / elapsed);
128 fprintf(stderr,
" Total cells: %llu\n", (
Llu)total_cells);
129 fprintf(stderr,
" Throughput: %.2f cells/s\n",
130 total_cells / elapsed);
133 fprintf(stderr,
" Resends: %llu\n",
134 (
Llu)mutator->get_resend_count());
141 if (scanner && m_profile) {
145 scanner->get_profile_data(profile_data);
146 fprintf(stderr,
" Cells scanned: %lld\n", (
Lld)profile_data.cells_scanned);
147 fprintf(stderr,
"Cells returned: %lld\n", (
Lld)profile_data.cells_returned);
148 fprintf(stderr,
" Bytes scanned: %lld\n", (
Lld)profile_data.bytes_scanned);
149 fprintf(stderr,
"Bytes returned: %lld\n", (
Lld)profile_data.bytes_returned);
150 fprintf(stderr,
" Disk read: %lld\n", (
Lld)profile_data.disk_read);
151 fprintf(stderr,
" Scan blocks: %d\n", (
int)profile_data.scanblocks);
152 fprintf(stderr,
" Sub scanners: %d\n", (
int)profile_data.subscanners);
155 for (
auto & server : profile_data.servers) {
162 fprintf(stderr,
" Servers: %s\n", servers.c_str());
173 HqlCommandInterpreter::HqlCommandInterpreter(
Client *client,
bool profile)
174 : m_interp(client->create_hql_interpreter(false)), m_profile(profile) {
double elapsed()
Returns the elapsed time.
String format_number(int64_t n, int sep)
Return decimal number string separated by a separator (default: comma) for every 3 digits...
bool m_profile
Flag indicating if SELECT commands should be profiled.
The Stopwatch measures elapsed time.
long long unsigned int Llu
Shortcut for printf formats.
Po::typed_value< String > * str(String *v=0)
int execute_line(const std::string &line) override
Executes an HQL command.
std::shared_ptr< TableScanner > TableScannerPtr
Smart pointer to TableScanner.
std::shared_ptr< TableMutator > TableMutatorPtr
Smart pointer to TableMutator.
File system utility functions.
The API of HQL interpreter.
Compatibility Macros for C/C++.
int64_t elapsed_millis()
Returns elapsed time in milliseconds.
long long int Lld
Shortcut for printf formats.
Callback interface/base class for execute.
Declarations for HqlCommandInterpreter.
The Stopwatch class measures elapsed time between instantiation (or a call to start) and a call to st...
HqlCommandInterpreter(Client *client, bool profile=false)
Constructor.
Declarations for HqlHelpText.
Error codes, Exception handling, error logging.
HqlInterpreterPtr m_interp
HQL interpreter.
void stop()
Stops the Stopwatch.
int timestamp_output_format()