Skip to content

Commit 3dc230b

Browse files
Changed resources() to a const accessor
1 parent c1ccef9 commit 3dc230b

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

tiledb/sm/consolidator/consolidator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class Consolidator : public JobBranch {
235235
/**
236236
* Derived from `JobBranch`
237237
*/
238-
ContextResources& resources() override {
238+
ContextResources& resources() const override {
239239
return resources_;
240240
}
241241

tiledb/sm/query/dimension_label/array_dimension_label_queries.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class ArrayDimensionLabelQueries : public JobBranch {
250250
/**
251251
* Derived from `JobBranch`
252252
*/
253-
ContextResources& resources() override {
253+
ContextResources& resources() const override {
254254
return resources_;
255255
}
256256
};

tiledb/sm/query/query.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ class Query : public JobBranch {
11971197
/**
11981198
* Derived from `JobBranch`
11991199
*/
1200-
ContextResources& resources() override {
1200+
ContextResources& resources() const override {
12011201
return resources_;
12021202
}
12031203
};

tiledb/sm/storage_manager/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Context : public ContextBase, public JobRoot {
165165
/**
166166
* Derived from `JobRoot`
167167
*/
168-
[[nodiscard]] ContextResources& resources() override {
168+
[[nodiscard]] ContextResources& resources() const override {
169169
return resources_;
170170
}
171171

tiledb/sm/storage_manager/job.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ struct JobResourceMixin {
157157
* Each class derived from `Parent` implements its own resources accessor.
158158
* Typically this accessor will simply return its own member variable.
159159
*/
160-
[[nodiscard]] virtual ContextResources& resources() = 0;
160+
[[nodiscard]] virtual ContextResources& resources() const = 0;
161161

162162
/**
163163
* Factory for cancellation source objects that are tied to the cancellation

tiledb/sm/storage_manager/test/unit_job.cc

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,24 @@ TEST_CASE("job::Child - construct and size") {
232232
CHECK(jf.context_.number_of_jobs() == 0);
233233
}
234234

235-
class TestJobRoot : public JobRoot {
235+
236+
class TestJobRootBase {
237+
protected:
236238
Config config_{};
237-
ContextResources resources_{
239+
mutable ContextResources resources_{
238240
config_, std::make_shared<Logger>("log"), 1, 1, ""};
239241
StorageManager sm_{resources_, config_};
242+
TestJobRootBase() = default;
243+
};
240244

245+
class TestJobRoot : protected TestJobRootBase, public JobRoot {
246+
using Base = TestJobRootBase;
241247
public:
242248
TestJobRoot()
243-
: JobRoot(sm_) {
249+
: TestJobRootBase(), JobRoot(Base::sm_) {
244250
}
245-
ContextResources& resources() override {
246-
return resources_;
251+
ContextResources& resources() const override {
252+
return Base::resources_;
247253
}
248254
};
249255
static_assert(TestJobRoot::is_parent);
@@ -258,7 +264,7 @@ class TestJobBranch : public JobBranch {
258264
TestJobBranch(JobParent& parent)
259265
: JobBranch(parent) {
260266
}
261-
ContextResources& resources() override {
267+
ContextResources& resources() const override {
262268
return parent().resources();
263269
}
264270
};
@@ -297,15 +303,20 @@ TEST_CASE("TestJobLeaf - construct from branch") {
297303
TestJobLeaf leaf{branch};
298304
}
299305

300-
class TestJobIsolate : public JobIsolate {
306+
class TestJobIsolateBase {
307+
protected:
301308
Config config_{};
302309
ContextResources resources_{
303310
config_, std::make_shared<Logger>("log"), 1, 1, ""};
304311
StorageManager sm_{resources_, config_};
312+
TestJobIsolateBase() = default;
313+
};
305314

315+
class TestJobIsolate : protected TestJobIsolateBase, public JobIsolate {
316+
using Base = TestJobIsolateBase;
306317
public:
307318
TestJobIsolate()
308-
: JobIsolate(sm_) {
319+
: TestJobIsolateBase(), JobIsolate(Base::sm_) {
309320
}
310321
};
311322
static_assert(!TestJobIsolate::is_parent);

0 commit comments

Comments
 (0)