MCPcopy Create free account
hub / github.com/bytedance/bolt / TaskCursorBase

Method TaskCursorBase

bolt/exec/tests/utils/Cursor.cpp:154–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152
153 // Unblock consumers.
154 if (consumerBlocked_) {
155 consumerBlocked_ = false;
156 consumerPromise_.setValue();
157 }
158}
159
160bool TaskQueue::hasNext() {
161 std::lock_guard<std::mutex> l(mutex_);
162 return !queue_.empty();
163}
164
165class TaskCursorBase : public TaskCursor {
166 public:
167 TaskCursorBase(
168 const CursorParameters& params,
169 const std::shared_ptr<folly::Executor>& executor) {
170 static std::atomic<int32_t> cursorId;
171 if (params.taskId.has_value()) {
172 taskId_ = *params.taskId;
173 } else {
174 taskId_ = fmt::format("test_cursor_{}", ++cursorId);
175 }
176
177 if (params.queryCtx) {
178 queryCtx_ = params.queryCtx;
179 } else {
180 // NOTE: the destructor of 'executor_' will wait for all the async task
181 // activities to finish on TaskCursor destruction.
182 executor_ = executor;
183 static std::atomic<uint64_t> cursorQueryId{0};
184 queryCtx_ = core::QueryCtx::create(
185 executor_.get(),
186 core::QueryConfig({}),
187 std::
188 unordered_map<std::string, std::shared_ptr<config::ConfigBase>>{},
189 cache::AsyncDataCache::getInstance(),
190 nullptr,
191 nullptr,
192 fmt::format("TaskCursorQuery_{}", cursorQueryId++));
193 }
194
195 if (!params.queryConfigs.empty()) {
196 auto configCopy = params.queryConfigs;
197 queryCtx_->testingOverrideConfigUnsafe(std::move(configCopy));
198 }
199
200 planFragment_ = {
201 params.planNode,
202 params.executionStrategy,
203 params.numSplitGroups,
204 params.groupedExecutionLeafNodeIds};
205
206 if (!params.spillDirectory.empty()) {
207 taskSpillDirectory_ = params.spillDirectory + "/" + taskId_;
208 taskSpillDirectoryCb_ = params.spillDirectoryCallback;
209 if (taskSpillDirectoryCb_ == nullptr) {
210 auto fileSystem =
211 bolt::filesystems::getFileSystem(taskSpillDirectory_, nullptr);

Callers

nothing calls this directly

Calls 8

getFileSystemFunction · 0.85
has_valueMethod · 0.80
createFunction · 0.50
QueryConfigClass · 0.50
getMethod · 0.45
emptyMethod · 0.45
mkdirMethod · 0.45

Tested by

no test coverage detected