MCPcopy Create free account
hub / github.com/activeloopai/deeplake / refresh

Method refresh

cpp/deeplake_pg/table_data_impl.hpp:142–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142inline void table_data::refresh()
143{
144 if (!dataset_ || dataset_->has_uncommitted_changes()) {
145 return;
146 }
147 if (pg::use_shared_mem_for_refresh) {
148 // Check if table version has changed and trigger refresh if needed
149 const uint64_t current_version = table_version_tracker::get_version(table_oid_);
150 if (current_version != cached_version_) {
151 cached_version_ = current_version;
152 streamers_.reset();
153 async::run_on_main([this]() {
154 return dataset_->refresh();
155 })
156 .get_future()
157 .get();
158 // After refresh from version change (another backend committed),
159 // use the dataset's actual row count. This correctly handles both
160 // inserts and deletes from other backends.
161 num_total_rows_ = dataset_->num_rows();
162 }
163 } else {
164 ASSERT(refreshing_dataset_ != nullptr);
165 if (refresh_promise_ && !refresh_promise_.is_ready()) {
166 return; // Already refreshing
167 } else if (refresh_promise_ && refresh_promise_.is_ready()) {
168 std::move(refresh_promise_).get();
169 if (refreshing_dataset_->version() != dataset_->version()) { // refresh happend!
170 streamers_.reset();
171 const auto ds_indexing_mode = dataset_->get_indexing_mode();
172 std::swap(dataset_, refreshing_dataset_);
173 dataset_->set_indexing_mode(ds_indexing_mode);
174 refreshing_dataset_->set_indexing_mode(deeplake::indexing_mode::off);
175 // After refresh from version change (another backend committed),
176 // use the dataset's actual row count. This correctly handles both
177 // inserts and deletes from other backends.
178 num_total_rows_ = dataset_->num_rows();
179 }
180 }
181 // trigger new refresh
182 refresh_promise_ = async::run_on_main([d = refreshing_dataset_]() {
183 return d->refresh();
184 });
185 }
186}
187
188inline void table_data::force_refresh()
189{

Callers 4

scan_beginMethod · 0.45
analyze_planFunction · 0.45
force_refreshMethod · 0.45

Calls 6

run_on_mainFunction · 0.85
get_futureMethod · 0.80
resetMethod · 0.45
getMethod · 0.45
num_rowsMethod · 0.45
is_readyMethod · 0.45

Tested by

no test coverage detected