MCPcopy Create free account
hub / github.com/baidu/tera / CompactTablet

Method CompactTablet

src/tabletnode/tabletnode_impl.cc:541–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541void TabletNodeImpl::CompactTablet(const CompactTabletRequest* request,
542 CompactTabletResponse* response,
543 google::protobuf::Closure* done) {
544 response->set_sequence_id(request->sequence_id());
545 StatusCode status = kTabletNodeOk;
546 io::TabletIO* tablet_io =
547 tablet_manager_->GetTablet(request->tablet_name(), request->key_range().key_start(),
548 request->key_range().key_end(), &status);
549 if (tablet_io == NULL) {
550 LOG(WARNING) << "compact fail to get tablet: " << request->tablet_name() << " ["
551 << DebugString(request->key_range().key_start()) << ", "
552 << DebugString(request->key_range().key_end())
553 << "], status: " << StatusCodeToString(status);
554 response->set_status(kKeyNotInRange);
555 done->Run();
556 return;
557 }
558 LOG(INFO) << "start compact tablet: " << tablet_io->GetTablePath() << " ["
559 << DebugString(tablet_io->GetStartKey()) << ", " << DebugString(tablet_io->GetEndKey())
560 << "]";
561
562 if (request->has_lg_no() && request->lg_no() >= 0) {
563 tablet_io->Compact(request->lg_no(), &status);
564 } else {
565 tablet_io->Compact(-1, &status);
566 }
567 CompactStatus compact_status = tablet_io->GetCompactStatus();
568 response->set_status(status);
569 response->set_compact_status(compact_status);
570 uint64_t compact_size = 0;
571 tablet_io->GetDataSize(&compact_size);
572 response->set_compact_size(compact_size);
573 LOG(INFO) << "compact tablet: " << tablet_io->GetTablePath() << " ["
574 << DebugString(tablet_io->GetStartKey()) << ", " << DebugString(tablet_io->GetEndKey())
575 << "], status: " << StatusCodeToString(status) << ", compacted size: " << compact_size;
576 tablet_io->DecRef();
577 done->Run();
578}
579
580void TabletNodeImpl::Update(const UpdateRequest* request, UpdateResponse* response,
581 google::protobuf::Closure* done) {

Callers 1

TEST_FFunction · 0.45

Calls 11

DebugStringFunction · 0.85
StatusCodeToStringFunction · 0.85
GetTablePathMethod · 0.80
GetTabletMethod · 0.45
RunMethod · 0.45
GetStartKeyMethod · 0.45
GetEndKeyMethod · 0.45
CompactMethod · 0.45
GetCompactStatusMethod · 0.45
GetDataSizeMethod · 0.45
DecRefMethod · 0.45

Tested by 1

TEST_FFunction · 0.36