westonpace commented on code in PR #13751:
URL: https://github.com/apache/arrow/pull/13751#discussion_r933670960
##########
cpp/src/arrow/compute/light_array.h:
##########
@@ -40,9 +40,35 @@ namespace compute {
/// allows us to take advantage of these resources without coupling the logic
with
/// the execution engine.
struct LightContext {
+ static constexpr int kLogMinibatchSizeMax = 10;
+ static constexpr int kMinibatchSizeMax = 1 << kLogMinibatchSizeMax;
+
bool has_avx2() const { return (hardware_flags &
arrow::internal::CpuInfo::AVX2) > 0; }
int64_t hardware_flags;
util::TempVectorStack* stack;
+ MemoryPool* memory_pool;
+
+ // A deleter for a light context that owns its TempVectorStack
+ struct OwningLightContextDeleter {
+ void operator()(LightContext* ctx) const {
+ delete ctx->stack;
+ delete ctx;
+ };
+ };
+
+ // Creates a new light context with an owned temp vector stack. Only to be
+ // used at the highest level (e.g. in ExecPlan, unit tests or benchmarks)
+ // Nodes should get their light context from the plan
Review Comment:
Right but then something like this...
```
TEST(SomeTest, ThatNeedsLightContext) {
auto ctx = LightContext::Make();
DoThingWithCtx(*ctx);
}
```
...becomes...
```
TEST(SomeTest, ThatNeedsLightContext) {
util::TempVectorStack stack;
stack.Init(kWhatWasThatParameterAgain);
LightContext ctx(&stack);
DoThingWithCtx(ctx);
}
```
Whatever our "master context" ends up being I would very much like to have a
one-liner that creates one and all I have to do is keep track of the thing that
comes back from that one-liner. Otherwise I have to remember the recipe every
time I write a unit test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]