Abstract
Readonly
childrenReadonly
finishedA boolean indicating whether Builder.prototype.finish()
has been called on this Builder
.
Readonly
lengthThe number of values written to the Builder
that haven't been flushed yet.
Optional
Readonly
nullThe list of null-value sentinels for this Builder
. When one of these values
is written to the Builder
(either via Builder.prototype.set()
or Builder.prototype.append()
),
a 1-bit is written to this Builder's underlying null BitmapBufferBuilder.
Readonly
strideThe number of elements in the underlying values TypedArray that
represent a single logical element, determined by this Builder's
DataType
. This is 1 for most types, but is larger when the DataType
is Int64
, Uint64
, Decimal
, DateMillisecond
, certain variants of
Interval
, Time
, or Timestamp
, FixedSizeBinary
, and FixedSizeList
.
Readonly
typeThe Builder's DataType
instance.
The aggregate length (in bytes) of the values that have been written.
The aggregate length (in bytes) that has been reserved to write new values.
The aggregate number of rows that have been reserved to write new values.
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 to
the null BitmapBufferBuilder
, and the value is passed to
Builder.prototype.setValue()
.
The updated Builder
instance.
Write a value to the underlying buffers at the supplied index, bypassing the null-value check. This is a low-level method that
Static
throughDOMStatic
through
An abstract base class for types that construct Arrow Vectors from arbitrary JavaScript values.
A
Builder
is responsible for writing arbitrary JavaScript values to ArrayBuffers and/or child Builders according to the Arrow specification for each DataType, creating or resizing the underlying ArrayBuffers as necessary.The
Builder
for each ArrowDataType
handles converting and appending values for a givenDataType
. The high-levelmakeBuilder()
convenience method creates the specificBuilder
subclass for the suppliedDataType
.Once created,
Builder
instances support both appending values to the end of theBuilder
, and random-access writes to specific indices (Builder.prototype.append(value)
is a convenience method forbuilder.set(builder.length, value)
). Appending or setting values beyond the Builder's current length may cause the builder to grow its underlying buffers or child Builders (if applicable) to accommodate the new values.After enough values have been written to a
Builder
,Builder.prototype.flush()
will commit the values to the underlying ArrayBuffers (or child Builders). The internal Builder state will be reset, and an instance ofData<T>
is returned. Alternatively,Builder.prototype.toVector()
will flush theBuilder
and return an instance ofVector<T>
instead.When there are no more values to write, use
Builder.prototype.finish()
to finalize theBuilder
. This does not reset the internal state, so it is necessary to callBuilder.prototype.flush()
ortoVector()
one last time if there are still values queued to be flushed.Note: calling
Builder.prototype.finish()
is required when using aDictionaryBuilder
, because this is when it flushes the values that have been enqueued in its internal dictionary'sBuilder
, and creates thedictionaryVector
for theDictionary
DataType
.Example
Typeparam
T The
DataType
of thisBuilder
.Typeparam
TNull The type(s) of values which will be considered null-value sentinels.