| 118 | } |
| 119 | |
| 120 | int FlatSparseBuilder::dump(const IndexDumper::Pointer &dumper) { |
| 121 | if (state_ != BUILD_STATE_BUILT || !holder_) { |
| 122 | LOG_INFO("Build the index before FlatSparseBuilder::dump"); |
| 123 | return IndexError_NoReady; |
| 124 | } |
| 125 | |
| 126 | LOG_INFO("Begin FlatSparseBuilder::dump"); |
| 127 | |
| 128 | auto start_time = ailego::Monotime::MilliSeconds(); |
| 129 | |
| 130 | int ret = IndexHelper::SerializeToDumper(meta_, dumper.get()); |
| 131 | if (ret != 0) { |
| 132 | LOG_ERROR("Failed to serialize meta into dumper."); |
| 133 | return ret; |
| 134 | } |
| 135 | |
| 136 | uint32_t dump_count; |
| 137 | ret = do_dump(dumper, &dump_count); |
| 138 | if (ret != 0) { |
| 139 | LOG_ERROR("Failed to dump index"); |
| 140 | return ret; |
| 141 | } |
| 142 | |
| 143 | holder_ = nullptr; |
| 144 | stats_.set_dumped_count(dump_count); |
| 145 | stats_.set_dumped_costtime(ailego::Monotime::MilliSeconds() - start_time); |
| 146 | |
| 147 | LOG_INFO("End FlatSparseBuilder::dump"); |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | int FlatSparseBuilder::do_dump(const IndexDumper::Pointer &dumper, |
| 152 | uint32_t *dump_count) { |
nothing calls this directly
no test coverage detected