Job Components: `Index Collector`
index.Collector
An in-memory record collector, useful for batch data to a certain size or after a certain amount of time has passed.
NOTE: Records are store in an immutable array to be more memory efficient.
Type parameters
Name |
---|
T |
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new Collector<T
>(max
): Collector
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
max | Object |
max.size | number |
max.wait | number |
Returns
Collector
<T
>
Defined in
packages/utils/dist/src/collector.d.ts:16
Properties
size
• Readonly
size: number
the maximum wait time to collect the batch
Defined in
packages/utils/dist/src/collector.d.ts:11
wait
• Readonly
wait: number
the maximum batch size of the batch
Defined in
packages/utils/dist/src/collector.d.ts:13
Accessors
length
• get
length(): number
Get the current Queue Length
Returns
number
Defined in
packages/utils/dist/src/collector.d.ts:23
queue
• get
queue(): T
[]
Get the current queue
Returns
T
[]
Defined in
packages/utils/dist/src/collector.d.ts:27
Methods
add
▸ add(_records
): void
Add a record, or records, to the in-memory queue.
Parameters
Name | Type | |
---|---|---|
_records | T \ | T [] |
Returns
void
Defined in
packages/utils/dist/src/collector.d.ts:31
flushAll
▸ flushAll(): T
[]
Flush all of the records in the queue.
NOTE: This can potentially return more records than specified than the max size.
Returns
T
[]
Defined in
packages/utils/dist/src/collector.d.ts:45
getBatch
▸ getBatch(): null
| T
[]
Get the batch of data if it is full or has exceeded the time threshold.
Returns
null
| T
[]
null if the batch isn't ready
the a batch of records, less or equal to the max size
Defined in
packages/utils/dist/src/collector.d.ts:38