| 423 | } |
| 424 | |
| 425 | void Adapter::Scan(const std::string& start_key, const std::string& end_key, |
| 426 | const std::vector<std::string>& cf_list, bool print, bool is_async) { |
| 427 | tera::ScanDescriptor scan_desp(start_key); |
| 428 | scan_desp.SetEnd(end_key); |
| 429 | scan_desp.SetBufferSize(FLAGS_buf_size); |
| 430 | for (size_t i = 0; i < cf_list.size(); i++) { |
| 431 | scan_desp.AddColumnFamily(cf_list[i]); |
| 432 | } |
| 433 | tera::ErrorCode err; |
| 434 | tera::ResultStream* result = table_->Scan(scan_desp, &err); |
| 435 | if (result == NULL) { |
| 436 | std::cerr << "fail to scan: " << tera::strerr(err); |
| 437 | return; |
| 438 | } |
| 439 | |
| 440 | uint64_t count = 0; |
| 441 | while (!result->Done()) { |
| 442 | if (print) { |
| 443 | std::cerr << count++ << "\t" << result->RowName() << "\t" << result->Family() << "\t" |
| 444 | << result->Qualifier() << "\t" << result->Timestamp() << "\t" << result->Value() |
| 445 | << std::endl; |
| 446 | } |
| 447 | size_t size = result->RowName().size() + result->Family().size() + result->Qualifier().size() + |
| 448 | sizeof(result->Timestamp()) + result->Value().size(); |
| 449 | scan_marker_.OnFinish(size, 0); |
| 450 | scan_marker_.OnSuccess(size, 0); |
| 451 | result->Next(); |
| 452 | } |
| 453 | delete result; |
| 454 | } |
| 455 | |
| 456 | void Adapter::WaitComplete() { |
| 457 | pthread_mutex_lock(&mutex_); |
no test coverage detected