ARROW-3475: [C++] Allow builders to finish to the corresponding array type#4262
ARROW-3475: [C++] Allow builders to finish to the corresponding array type#4262bkietz wants to merge 5 commits intoapache:masterfrom
Conversation
|
Hmmm, I'm not sure how to resolve this doc error. Doxygen produces an extra declaration of I could rename the method to |
| ARROW_RETURN_NOT_OK(Finish(&out_untyped)); | ||
| *out = std::static_pointer_cast<ArrayType>(std::move(out_untyped)); | ||
| return Status::OK(); | ||
| } |
There was a problem hiding this comment.
One option is to Call this Finish simply and add a DCHECK to assert that the runtime type matches ArrayType. I tried this here:
I'm not sure what pitfalls there might be from that
There was a problem hiding this comment.
That's an option. I avoided it because it seems sloppy/user-hostile to allow something to compile which could easily be caught as an error:
Int64Builder i64_b;
// ...
std::shared_ptr<Int32Array> i32_a;
i64_b.Finish(&i32_a); // would compile, but fail at runtimeThere was a problem hiding this comment.
Another way would be to make this a non-member method:
Int64Builder builder;
// ...
std::shared_ptr<Int64Array> array;
Finish(&builder, &array); // type match guaranteed at compile timeThere was a problem hiding this comment.
Gotcha. Well, I think it's OK to accept things as they are now, the boilerplate does not seem too onerous
|
+1 |
Allows
Int64Builderto finish intoshared_ptr<Int64Array>,ListBuilderto finish intoshared_ptr<ListArray>, etc.