Skip to content

Commit 45ccac9

Browse files
Job system for activity tracking
Add a registry system centered on `class Registry`. The system supports automatic first-pass registration at construction time. Add a job system, a set of base classes for jobs. The job system is generic, with a mixin class to add application-specific behavior. The mixin class for the library deals with `StorageManager` and `ContextResources`, etc. There's only one remaining `StorageManager` member variable; it's in the mixin class. The `storage_manager()` accessor functions are also in the same place. `class JobRoot` is now a base class of `class Context`, now split into `ContextBase` and `Context` so that the storage manager member variable is available for the `JobRoot` constructor. `class JobBranch` is now a base class of `class Query` and `class Consolidator`, among others. Rework all the constructors to take a single `JobParent` argument rather than separate arguments for resources, cancellation sources, and storage managers. `JobParent::make_cancellation_source` is now the sole source of `CancellationSource` objects. Add `Context::cancel_all_tasks()`, currently as a proxy for the same function in `StorageManager`. This allowed removal of the accessor `storage_manager()` in the context C API handle. Remove now-unused `tiledb_ctx_handle_t::make_cancellation_source()`.
1 parent 3c8733b commit 45ccac9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3051
-597
lines changed

test/src/unit-Reader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ TEST_CASE_METHOD(
175175
array.memory_tracker(),
176176
tracker_,
177177
lq_state_machine,
178-
CancellationSource(context.storage_manager()),
178+
context.make_cancellation_source(),
179179
array.opened_array(),
180180
config,
181181
nullopt,

test/src/unit-enumerations.cc

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,18 +2398,10 @@ TEST_CASE_METHOD(
23982398
auto qc1 = create_qc("attr1", (int)2, QueryConditionOp::EQ);
23992399
qc1.set_use_enumeration(false);
24002400

2401-
Query q1(
2402-
ctx_.resources(),
2403-
ctx_.cancellation_source(),
2404-
ctx_.storage_manager(),
2405-
array);
2401+
Query q1(ctx_, array);
24062402
throw_if_not_ok(q1.set_condition(qc1));
24072403

2408-
Query q2(
2409-
ctx_.resources(),
2410-
ctx_.cancellation_source(),
2411-
ctx_.storage_manager(),
2412-
array);
2404+
Query q2(ctx_, array);
24132405
ser_des_query(&q1, &q2, client_side, ser_type);
24142406

24152407
auto qc2 = q2.condition();
@@ -2442,18 +2434,10 @@ TEST_CASE_METHOD(
24422434

24432435
throw_if_not_ok(qc1.combine(qc2, QueryConditionCombinationOp::OR, &qc3));
24442436

2445-
Query q1(
2446-
ctx_.resources(),
2447-
ctx_.cancellation_source(),
2448-
ctx_.storage_manager(),
2449-
array);
2437+
Query q1(ctx_, array);
24502438
throw_if_not_ok(q1.set_condition(qc3));
24512439

2452-
Query q2(
2453-
ctx_.resources(),
2454-
ctx_.cancellation_source(),
2455-
ctx_.storage_manager(),
2456-
array);
2440+
Query q2(ctx_, array);
24572441
ser_des_query(&q1, &q2, client_side, ser_type);
24582442

24592443
auto qc4 = q2.condition();

tiledb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ set(TILEDB_CORE_SOURCES
304304
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/storage_manager/cancellation_source.cc
305305
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/storage_manager/context.cc
306306
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/storage_manager/context_resources.cc
307+
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/storage_manager/job.cc
307308
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/storage_manager/storage_manager.cc
308309
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/subarray/range_subset.cc
309310
${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/subarray/relevant_fragment_generator.cc

tiledb/api/c_api/context/context_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ capi_return_t tiledb_ctx_is_supported_fs(
115115
}
116116

117117
capi_return_t tiledb_ctx_cancel_tasks(tiledb_ctx_t* ctx) {
118-
throw_if_not_ok(ctx->storage_manager()->cancel_all_tasks());
118+
ctx->cancel_all_tasks();
119119
return TILEDB_OK;
120120
}
121121

tiledb/api/c_api/context/context_api_internal.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,8 @@ struct tiledb_ctx_handle_t
6868
return ctx_.resources().config();
6969
}
7070

71-
inline tiledb::sm::StorageManager* storage_manager() {
72-
return ctx_.storage_manager();
73-
}
74-
75-
inline tiledb::sm::CancellationSource cancellation_source() {
76-
return ctx_.cancellation_source();
71+
inline void cancel_all_tasks() {
72+
return ctx_.cancel_all_tasks();
7773
}
7874

7975
inline tiledb::sm::RestClient& rest_client() {

tiledb/api/c_api/group/group_api.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ capi_return_t tiledb_group_consolidate_metadata(
496496
ensure_group_uri_argument_is_valid(group_uri);
497497

498498
auto cfg = (config == nullptr) ? ctx->config() : config->config();
499-
tiledb::sm::Group::consolidate_metadata(ctx->resources(), group_uri, cfg);
499+
tiledb::sm::Group::consolidate_metadata(ctx->context(), group_uri, cfg);
500500

501501
return TILEDB_OK;
502502
}
@@ -506,7 +506,7 @@ capi_return_t tiledb_group_vacuum_metadata(
506506
ensure_group_uri_argument_is_valid(group_uri);
507507

508508
auto cfg = (config == nullptr) ? ctx->config() : config->config();
509-
sm::Group::vacuum_metadata(ctx->resources(), group_uri, cfg);
509+
sm::Group::vacuum_metadata(ctx->context(), group_uri, cfg);
510510

511511
return TILEDB_OK;
512512
}

tiledb/api/c_api_test_support/storage_manager_stub/storage_manager_override.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ class StorageManagerStub {
5050
static constexpr bool is_overriding_class = true;
5151
StorageManagerStub(
5252
ContextResources&,
53-
const std::shared_ptr<common::Logger>&,
5453
const Config& config)
5554
: config_(config) {
5655
}
5756

58-
inline Status cancel_all_tasks() {
59-
return Status{};
57+
void cancel_all_tasks() {
58+
}
59+
60+
bool cancellation_in_progress() const {
61+
return false;
6062
}
6163
};
6264

tiledb/common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ add_subdirectory(exception)
4444
add_subdirectory(governor)
4545
add_subdirectory(interval)
4646
add_subdirectory(random)
47+
add_subdirectory(registry)
4748
add_subdirectory(thread_pool)
4849
add_subdirectory(types)
4950
add_subdirectory(util)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# tiledb/common/registry/CMakeLists.txt
3+
#
4+
# The MIT License
5+
#
6+
# Copyright (c) 2023-2024 TileDB, Inc.
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the "Software"), to deal
10+
# in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
# THE SOFTWARE.
25+
26+
add_test_subdirectory()

0 commit comments

Comments
 (0)