yggio 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -203,9 +203,8 @@ or `serie.scalar(0)` for one row - and values become a column through
203
203
  `BatchReader` read yields Arrow JS batches, and a write consumes a native
204
204
  reader, Arrow JS table/batch/reader, IPC bytes, named columns, or plain rows
205
205
  through that same reader path. `serie.cast` casts a column in hand,
206
- `SerieReader.fromArrowReader` casts a stream batch by batch under one plan,
207
- `SerieReader.fromSerie` streams a held column as the one record serie it is,
208
- and `ArrowCastPlan.compile` holds one cast for every column of a layout.
206
+ `Serie.fromArrowReader` keeps a reader external as a lazy Serie, cast batch by batch under one plan; `Serie.intoChunks` walks any serie one record column per batch;
207
+ and `CastPlan.compile` holds one cast for every column of a layout.
209
208
  Each takes `{ safe, representation }`, an absent answer taking the core's
210
209
  default; whether a value may be absent is the target field's nullability. Run
211
210
  `npm run bench:records` for the copied-IPC read, projection, cast, and write
package/benchmarks/fix.js CHANGED
@@ -116,15 +116,11 @@ const order = fields.struct(
116
116
  { nullable: false },
117
117
  )
118
118
  // `PartyRole(452)` states a code set, so it holds its wire code as text.
119
- const message = fix.MarketMessage.fromFixRecord(
120
- order,
121
- {
119
+ const message = fix.MarketMessage.fromFixRecord(order, {
122
120
  symbol: 'AAPL',
123
121
  orderqty: Scalar.decimal(100n * 10n ** 18n, 18),
124
122
  parties: [{ partyid: 'BROKER', partyidsource: 'D', partyrole: '1' }],
125
- },
126
- registry,
127
- )
123
+ }, new fix.MarketMessagesOptions(registry))
128
124
 
129
125
  const catalog = new fix.FixRegistry()
130
126
  const counter = Field.from('NoPartyIDs: int32')
@@ -157,8 +153,8 @@ arrivingField.fix.tag = 55
157
153
  if (catalog.clone().addField(foldingField) !== false) throw new Error('party_id should fold')
158
154
  if (catalog.clone().addField(arrivingField) !== true) throw new Error('Symbol should arrive')
159
155
  const singleton = catalog.msgtype('D')
160
- const codec = new fix.FixCodec(catalog)
161
- const snapshotCodec = new fix.FixCodec(catalog, { snapshotNs: 1_000_000_000n })
156
+ const catalogOptions = new fix.MarketMessagesOptions(catalog)
157
+ const snapshotOptions = new fix.MarketMessagesOptions(catalog, { snapshotNs: 1_000_000_000n })
162
158
 
163
159
  function drain(values) {
164
160
  let count = 0
@@ -168,14 +164,14 @@ function drain(values) {
168
164
 
169
165
  // The stream and Arrow doors, over a capture of wide orders: what is measured
170
166
  // is the crossing - one pull per line, one batch per pull - beside the parse.
171
- const seedCodec = new fix.FixCodec(registry)
167
+ const seedOptions = new fix.MarketMessagesOptions(registry)
172
168
  const fixedSchema = fix.MarketMessage.field()
173
169
  const encoder = new TextEncoder()
174
170
  const LINES = Array.from({ length: 256 }, (_, index) =>
175
171
  encoder.encode(`8=FIX.4.4|35=D|11=ORDER-${String(index).padStart(6, '0')}|55=AAPL|54=1|38=100|58=${'x'.repeat(200)}|10=0|`),
176
172
  )
177
173
  const capture = new arrow.Table({ body: arrow.vectorFromArray(LINES, new arrow.Binary()) })
178
- const parsed = seedCodec.parseLine(Buffer.from(LINES[0])).next().value
174
+ const parsed = fix.MarketMessage.fromLine(Buffer.from(LINES[0]), seedOptions)
179
175
  const orderType = registry.msgtype('D')
180
176
  const orderDeclaration = orderType.asField()
181
177
  if (parsed.identifiers.get('clordid') !== 'ORDER-000000') {
@@ -188,7 +184,7 @@ if (orderType.marketdatakind !== 'OPER' || parsed.marketdatakind !== 'OPER' || s
188
184
  throw new Error('FIX category and exact snapshot boundary mismatch')
189
185
  }
190
186
  const parsedRow = parsed.intoRow(fixedSchema)
191
- const parsedIpc = seedCodec.parseTextArrowReader(capture).intoIpc()
187
+ const parsedIpc = new fix.MarketMessages(seedOptions).fromTextArrowReader(capture).intoArrowReader().intoIpc()
192
188
  // The line door, each line as a text reader answers it.
193
189
  const TEXT_LINES = LINES.map((body, index) => new TextLine(BigInt(index), Buffer.from(body)))
194
190
  // The same door with a `msgpluginid` capture on every line: the capture fills
@@ -203,14 +199,14 @@ const msgpluginidRegistry = (() => {
203
199
  held.insert(venue)
204
200
  return held
205
201
  })()
206
- const msgpluginidCodec = new fix.FixCodec(msgpluginidRegistry, { captureNames: ['msgpluginid'] })
202
+ const msgpluginidOptions = new fix.MarketMessagesOptions(msgpluginidRegistry, { captureNames: ['msgpluginid'] })
207
203
  const MSGPLUGINID_LINES = LINES.map((body, index) =>
208
204
  new TextLine(BigInt(index), Buffer.from(body), [index % 2 === 0 ? VENDOR_DIALECT : 'OMS_X1_TradeCapture']),
209
205
  )
210
- if (drain(msgpluginidCodec.parseTextLines(MSGPLUGINID_LINES)) !== LINES.length) {
206
+ if (drain(new fix.MarketMessages(msgpluginidOptions).fromTextLines(MSGPLUGINID_LINES)) !== LINES.length) {
211
207
  throw new Error('msgpluginid line cardinality mismatch')
212
208
  }
213
- if (drain(seedCodec.parseLines(LINES)) !== LINES.length) throw new Error('line cardinality mismatch')
209
+ if (drain(new fix.MarketMessages(seedOptions).fromLines(LINES)) !== LINES.length) throw new Error('line cardinality mismatch')
214
210
  const sink = { write() {} }
215
211
 
216
212
  try {
@@ -244,7 +240,7 @@ try {
244
240
  benchmark('fix/field_msgcat', () => orderDeclaration.fix.msgcat)
245
241
  benchmark('fix/msgtype_marketdatakind', () => orderType.marketdatakind)
246
242
  benchmark('fix/message_marketdatakind', () => parsed.marketdatakind)
247
- benchmark('fix/codec_snapshot_ns', () => snapshotCodec.snapshotNs)
243
+ benchmark('fix/options_snapshot_ns', () => snapshotOptions.snapshotNs)
248
244
  benchmark('fix/identifier_values', () => orderType.identifierValues(parsed))
249
245
  // The typed holders, each read once into the plain object it crosses as.
250
246
  benchmark('fix/message_header', () => parsed.header())
@@ -262,7 +258,7 @@ try {
262
258
  benchmark('fix/message_get_by_name', () => message.getByName('ticker'))
263
259
  benchmark('fix/message_get_by_path', () => message.getByPath('Parties.0.PartyID'))
264
260
  benchmark('fix/infer_fixml_protocol', () => MimeType.inferBytes(FIXML_LINE))
265
- benchmark('fix/infer_ullink_msgtype', () => fix.FixCodec.inferMsgtypeText(ULLINK_LINE))
261
+ benchmark('fix/infer_ullink_msgtype', () => fix.MarketMessagesOptions.inferMsgtypeText(ULLINK_LINE))
266
262
  benchmark('fix/fields_first', () => {
267
263
  const iterator = catalog.keys()[Symbol.iterator]()
268
264
  const first = iterator.next().value
@@ -302,41 +298,41 @@ try {
302
298
  copy.insert(empty)
303
299
  return copy.remove('NewMessage')
304
300
  })
305
- benchmark('fix/numeric_group_parse', () => drain(codec.parseLine(Buffer.from('35=D|453=2|448=ONE|448=TWO|'))))
301
+ benchmark('fix/numeric_group_parse', () => drain(new fix.MarketMessages(catalogOptions).fromLines([Buffer.from('35=D|453=2|448=ONE|448=TWO|')])))
306
302
  benchmark('fix/message_into_row', () => message.intoRow(order))
307
303
  benchmark('fix/message_into_bytes', () => message.intoBytes(124))
308
304
  benchmark('fix/message_set', () => parsed.clone().set(55, 'MSFT'))
309
305
  benchmark('fix/message_remove', () => parsed.clone().remove(55))
310
- benchmark('fix/message_from_row', () => fix.MarketMessage.fromRow(fixedSchema, parsedRow, registry))
306
+ benchmark('fix/message_from_row', () => fix.MarketMessage.fromRow(fixedSchema, parsedRow, seedOptions))
311
307
  benchmark('fix/message_into_text', () => message.intoText('|'))
312
308
  benchmark('fix/identified_message_arrow', () =>
313
- seedCodec.arrowReader(fixedSchema, [parsed]).intoTable().numRows,
309
+ new fix.MarketMessages(seedOptions).fromItems([parsed]).intoArrowReader(fixedSchema).intoTable().numRows,
314
310
  )
315
311
  const streams = Math.max(1, Math.round(iterations / 50))
316
- benchmarkStreams(`fix/parse_lines_drain/${LINES.length}`, streams, () => drain(seedCodec.parseLines(LINES)))
312
+ benchmarkStreams(`fix/parse_lines_drain/${LINES.length}`, streams, () => drain(new fix.MarketMessages(seedOptions).fromLines(LINES)))
317
313
  benchmarkStreams(`fix/parse_text_lines_drain/${LINES.length}`, streams, () =>
318
- drain(seedCodec.parseTextLines(TEXT_LINES)),
314
+ drain(new fix.MarketMessages(seedOptions).fromTextLines(TEXT_LINES)),
319
315
  )
320
316
  benchmarkStreams(`fix/parse_text_lines_msgpluginid_drain/${LINES.length}`, streams, () =>
321
- drain(msgpluginidCodec.parseTextLines(MSGPLUGINID_LINES)),
317
+ drain(new fix.MarketMessages(msgpluginidOptions).fromTextLines(MSGPLUGINID_LINES)),
322
318
  )
323
319
  benchmarkStreams(`fix/parse_text_arrow_reader/${LINES.length}`, streams, () =>
324
- seedCodec.parseTextArrowReader(capture).intoTable().numRows,
320
+ new fix.MarketMessages(seedOptions).fromTextArrowReader(capture).intoArrowReader().intoTable().numRows,
325
321
  )
326
322
  benchmarkStreams(`fix/lifecycle_drain/${LINES.length}`, streams, () =>
327
- drain(seedCodec.lifecycle(seedCodec.parseLines(LINES))),
323
+ drain(new fix.MarketMessages(seedOptions).fromLines(LINES).intoLifecycle()),
328
324
  )
329
325
  benchmarkStreams(`fix/lifecycle_arrow_reader/${LINES.length}`, streams, () =>
330
- seedCodec.lifecycleArrowReader(BatchReader.fromIpc(parsedIpc)).intoTable().numRows,
326
+ new fix.MarketMessages(seedOptions).fromArrowReader(BatchReader.fromIpc(parsedIpc)).intoLifecycle().intoArrowReader().intoTable().numRows,
331
327
  )
332
328
  benchmarkStreams(`fix/messages_drain/${LINES.length}`, streams, () =>
333
- drain(seedCodec.messages(BatchReader.fromIpc(parsedIpc))),
329
+ drain(new fix.MarketMessages(seedOptions).fromArrowReader(BatchReader.fromIpc(parsedIpc))),
334
330
  )
335
331
  benchmarkStreams(`fix/arrow_reader_over_parse_lines/${LINES.length}`, streams, () =>
336
- seedCodec.arrowReader(fixedSchema, seedCodec.parseLines(LINES)).intoTable().numRows,
332
+ new fix.MarketMessages(seedOptions).fromLines(LINES).intoArrowReader(fixedSchema).intoTable().numRows,
337
333
  )
338
334
  benchmarkStreams(`fix/write_arrow_reader/${LINES.length}`, streams, () =>
339
- seedCodec.writeArrowReader(BatchReader.fromIpc(parsedIpc), sink),
335
+ new fix.MarketMessages(seedOptions).fromArrowReader(BatchReader.fromIpc(parsedIpc)).intoWriter(sink),
340
336
  )
341
337
  benchmarkLoad('fix/from_handle_seed', () => fix.FixRegistry.fromHandle(SEED))
342
338
  benchmarkLoad(`fix/from_handle_${WIDE_FIELDS}_fields`, () =>
@@ -207,7 +207,6 @@ benchmark('serie/into_reversed', () => orderPrices.intoReversed())
207
207
  benchmark('serie/into_taken', () => orderPrices.intoTaken(orderIndices))
208
208
  benchmark('serie/into_filtered', () => orderPrices.intoFiltered(orderMask))
209
209
  benchmark('serie/partition_by', () => orderPrices.partitionBy(orderVenues))
210
- benchmark('serie/partition_by_paths', () => orderQuotes.partitionByPaths(['venue', 'price']))
211
210
  const sortedInPlace = orderPrices.intoSorted()
212
211
  benchmark('serie/as_sorted', () => sortedInPlace.asSorted())
213
212
  const uniqueInPlace = orderVenues.intoUnique()