trxcllnt commented on a change in pull request #12451:
URL: https://github.com/apache/arrow/pull/12451#discussion_r810394714
##########
File path: js/src/builder/struct.ts
##########
@@ -23,12 +23,31 @@ import { Struct, TypeMap } from '../type.js';
/** @ignore */
export class StructBuilder<T extends TypeMap = any, TNull = any> extends
Builder<Struct<T>, TNull> {
- public setValue(index: number, value: Struct<T>['TValue']) {
+ /**
+ * Write a value (or null-value sentinel) at the supplied index.
+ * If the value matches one of the null-value representations, a 1-bit is
+ * written to the null `BitmapBufferBuilder`, otherwise, a 0 is written.
The
+ * value is then passed to `Builder.prototype.setValue()`.
+ * @param {number} index The index of the value to write.
+ * @param {T['TValue'] | TNull } value The value to write at the supplied
index.
+ * @returns {this} The updated `Builder` instance.
+ */
+ public set(index: number, value: Struct<T>['TValue'] | TNull) {
+ this.setValid(index, this.isValid(value));
+ this.setValue(index, value);
+ return this;
+ }
Review comment:
> I would have thought that doesn't work for more complex nested types
such as a struct within a struct which would need the fields of that
inner-struct to also have a null value appended.
@Alfred-Mountfield Ah good point. In that case, I think the change needs to
be not to override `set()` or change the `setValue()` implementation, but to
also override `setValid()` and make it set nulls into each child. I'll update
my suggestion in a new thread.
--
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]