@smoothbricks/lmao 0.1.0
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 +269 -0
- package/dist/allocator.wasm +0 -0
- package/dist/bun/preload.d.ts +11 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +10 -0
- package/dist/bun/trace-preload.d.ts +8 -0
- package/dist/bun/trace-preload.d.ts.map +1 -0
- package/dist/bun/trace-preload.js +12 -0
- package/dist/es.d.ts +8 -0
- package/dist/es.d.ts.map +1 -0
- package/dist/es.js +9 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/lib/JsBufferStrategy.d.ts +49 -0
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -0
- package/dist/lib/JsBufferStrategy.js +60 -0
- package/dist/lib/archive/chunkCompaction.d.ts +15 -0
- package/dist/lib/archive/chunkCompaction.d.ts.map +1 -0
- package/dist/lib/archive/chunkCompaction.js +24 -0
- package/dist/lib/archive/chunkEnvelope.d.ts +21 -0
- package/dist/lib/archive/chunkEnvelope.d.ts.map +1 -0
- package/dist/lib/archive/chunkEnvelope.js +55 -0
- package/dist/lib/archive/chunkRouting.d.ts +10 -0
- package/dist/lib/archive/chunkRouting.d.ts.map +1 -0
- package/dist/lib/archive/chunkRouting.js +47 -0
- package/dist/lib/archive/chunkStats.d.ts +12 -0
- package/dist/lib/archive/chunkStats.d.ts.map +1 -0
- package/dist/lib/archive/chunkStats.js +10 -0
- package/dist/lib/archive/index.d.ts +5 -0
- package/dist/lib/archive/index.d.ts.map +1 -0
- package/dist/lib/archive/index.js +4 -0
- package/dist/lib/arrow/capacityStats.d.ts +9 -0
- package/dist/lib/arrow/capacityStats.d.ts.map +1 -0
- package/dist/lib/arrow/capacityStats.js +231 -0
- package/dist/lib/arrow/dictionaries.d.ts +27 -0
- package/dist/lib/arrow/dictionaries.d.ts.map +1 -0
- package/dist/lib/arrow/dictionaries.js +135 -0
- package/dist/lib/arrow/flechette.d.ts +40 -0
- package/dist/lib/arrow/flechette.d.ts.map +1 -0
- package/dist/lib/arrow/flechette.js +67 -0
- package/dist/lib/arrow/utils.d.ts +38 -0
- package/dist/lib/arrow/utils.d.ts.map +1 -0
- package/dist/lib/arrow/utils.js +112 -0
- package/dist/lib/buffer/Nanoseconds.d.ts +109 -0
- package/dist/lib/buffer/Nanoseconds.d.ts.map +1 -0
- package/dist/lib/buffer/Nanoseconds.js +86 -0
- package/dist/lib/bufferStrategy.d.ts +95 -0
- package/dist/lib/bufferStrategy.d.ts.map +1 -0
- package/dist/lib/bufferStrategy.js +1 -0
- package/dist/lib/capacityTuning.d.ts +50 -0
- package/dist/lib/capacityTuning.d.ts.map +1 -0
- package/dist/lib/capacityTuning.js +65 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts +35 -0
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/evaluatorGenerator.js +199 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +139 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +289 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +115 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerGenerator.js +575 -0
- package/dist/lib/convertToArrow.d.ts +40 -0
- package/dist/lib/convertToArrow.d.ts.map +1 -0
- package/dist/lib/convertToArrow.js +1467 -0
- package/dist/lib/defineOpContext.d.ts +96 -0
- package/dist/lib/defineOpContext.d.ts.map +1 -0
- package/dist/lib/defineOpContext.js +227 -0
- package/dist/lib/errors/Blocked.d.ts +113 -0
- package/dist/lib/errors/Blocked.d.ts.map +1 -0
- package/dist/lib/errors/Blocked.js +68 -0
- package/dist/lib/errors/CodeError.d.ts +101 -0
- package/dist/lib/errors/CodeError.d.ts.map +1 -0
- package/dist/lib/errors/CodeError.js +42 -0
- package/dist/lib/errors/RetriesExhausted.d.ts +67 -0
- package/dist/lib/errors/RetriesExhausted.d.ts.map +1 -0
- package/dist/lib/errors/RetriesExhausted.js +31 -0
- package/dist/lib/errors/Transient.d.ts +115 -0
- package/dist/lib/errors/Transient.d.ts.map +1 -0
- package/dist/lib/errors/Transient.js +54 -0
- package/dist/lib/errors/index.d.ts +14 -0
- package/dist/lib/errors/index.d.ts.map +1 -0
- package/dist/lib/errors/index.js +16 -0
- package/dist/lib/errors/retry-policy.d.ts +60 -0
- package/dist/lib/errors/retry-policy.d.ts.map +1 -0
- package/dist/lib/errors/retry-policy.js +54 -0
- package/dist/lib/flushScheduler.d.ts +162 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -0
- package/dist/lib/flushScheduler.js +388 -0
- package/dist/lib/library.d.ts +149 -0
- package/dist/lib/library.d.ts.map +1 -0
- package/dist/lib/library.js +588 -0
- package/dist/lib/logApi.d.ts +61 -0
- package/dist/lib/logApi.d.ts.map +1 -0
- package/dist/lib/logApi.js +12 -0
- package/dist/lib/logBinding.d.ts +63 -0
- package/dist/lib/logBinding.d.ts.map +1 -0
- package/dist/lib/logBinding.js +1 -0
- package/dist/lib/op.d.ts +105 -0
- package/dist/lib/op.d.ts.map +1 -0
- package/dist/lib/op.js +59 -0
- package/dist/lib/opContext/contextTypes.d.ts +88 -0
- package/dist/lib/opContext/contextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/contextTypes.js +34 -0
- package/dist/lib/opContext/createOpGroup.d.ts +57 -0
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -0
- package/dist/lib/opContext/createOpGroup.js +341 -0
- package/dist/lib/opContext/defineOp.d.ts +83 -0
- package/dist/lib/opContext/defineOp.d.ts.map +1 -0
- package/dist/lib/opContext/defineOp.js +197 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts +58 -0
- package/dist/lib/opContext/featureFlagTypes.d.ts.map +1 -0
- package/dist/lib/opContext/featureFlagTypes.js +1 -0
- package/dist/lib/opContext/index.d.ts +13 -0
- package/dist/lib/opContext/index.d.ts.map +1 -0
- package/dist/lib/opContext/index.js +15 -0
- package/dist/lib/opContext/opGroupTypes.d.ts +250 -0
- package/dist/lib/opContext/opGroupTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opGroupTypes.js +31 -0
- package/dist/lib/opContext/opTypes.d.ts +48 -0
- package/dist/lib/opContext/opTypes.d.ts.map +1 -0
- package/dist/lib/opContext/opTypes.js +7 -0
- package/dist/lib/opContext/spanContextTypes.d.ts +347 -0
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -0
- package/dist/lib/opContext/spanContextTypes.js +1 -0
- package/dist/lib/opContext/types.d.ts +297 -0
- package/dist/lib/opContext/types.d.ts.map +1 -0
- package/dist/lib/opContext/types.js +16 -0
- package/dist/lib/result.d.ts +308 -0
- package/dist/lib/result.d.ts.map +1 -0
- package/dist/lib/result.js +359 -0
- package/dist/lib/schema/LogSchema.d.ts +62 -0
- package/dist/lib/schema/LogSchema.d.ts.map +1 -0
- package/dist/lib/schema/LogSchema.js +134 -0
- package/dist/lib/schema/builder.d.ts +12 -0
- package/dist/lib/schema/builder.d.ts.map +1 -0
- package/dist/lib/schema/builder.js +169 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts +60 -0
- package/dist/lib/schema/defineFeatureFlags.d.ts.map +1 -0
- package/dist/lib/schema/defineFeatureFlags.js +29 -0
- package/dist/lib/schema/defineLogSchema.d.ts +87 -0
- package/dist/lib/schema/defineLogSchema.d.ts.map +1 -0
- package/dist/lib/schema/defineLogSchema.js +171 -0
- package/dist/lib/schema/evaluator.d.ts +267 -0
- package/dist/lib/schema/evaluator.d.ts.map +1 -0
- package/dist/lib/schema/evaluator.js +169 -0
- package/dist/lib/schema/extend.d.ts +14 -0
- package/dist/lib/schema/extend.d.ts.map +1 -0
- package/dist/lib/schema/extend.js +51 -0
- package/dist/lib/schema/systemSchema.d.ts +112 -0
- package/dist/lib/schema/systemSchema.d.ts.map +1 -0
- package/dist/lib/schema/systemSchema.js +260 -0
- package/dist/lib/schema/typeGuards.d.ts +52 -0
- package/dist/lib/schema/typeGuards.d.ts.map +1 -0
- package/dist/lib/schema/typeGuards.js +127 -0
- package/dist/lib/schema/types.d.ts +156 -0
- package/dist/lib/schema/types.d.ts.map +1 -0
- package/dist/lib/schema/types.js +4 -0
- package/dist/lib/spanBuffer.d.ts +133 -0
- package/dist/lib/spanBuffer.d.ts.map +1 -0
- package/dist/lib/spanBuffer.js +442 -0
- package/dist/lib/spanBufferHelpers.d.ts +53 -0
- package/dist/lib/spanBufferHelpers.d.ts.map +1 -0
- package/dist/lib/spanBufferHelpers.js +65 -0
- package/dist/lib/spanBufferStats.d.ts +38 -0
- package/dist/lib/spanBufferStats.d.ts.map +1 -0
- package/dist/lib/spanBufferStats.js +1 -0
- package/dist/lib/spanContext.d.ts +141 -0
- package/dist/lib/spanContext.d.ts.map +1 -0
- package/dist/lib/spanContext.js +763 -0
- package/dist/lib/sqlite/index.d.ts +14 -0
- package/dist/lib/sqlite/index.d.ts.map +1 -0
- package/dist/lib/sqlite/index.js +12 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts +24 -0
- package/dist/lib/sqlite/sqlite-async-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-async-writer.js +65 -0
- package/dist/lib/sqlite/sqlite-common.d.ts +37 -0
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-common.js +207 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts +25 -0
- package/dist/lib/sqlite/sqlite-d1.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-d1.js +67 -0
- package/dist/lib/sqlite/sqlite-db.d.ts +29 -0
- package/dist/lib/sqlite/sqlite-db.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-db.js +1 -0
- package/dist/lib/sqlite/sqlite-node.d.ts +16 -0
- package/dist/lib/sqlite/sqlite-node.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-node.js +68 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts +39 -0
- package/dist/lib/sqlite/sqlite-writer.d.ts.map +1 -0
- package/dist/lib/sqlite/sqlite-writer.js +78 -0
- package/dist/lib/testing/bun-harness.d.ts +150 -0
- package/dist/lib/testing/bun-harness.d.ts.map +1 -0
- package/dist/lib/testing/bun-harness.js +729 -0
- package/dist/lib/testing/extractFacts.d.ts +73 -0
- package/dist/lib/testing/extractFacts.d.ts.map +1 -0
- package/dist/lib/testing/extractFacts.js +237 -0
- package/dist/lib/testing/facts.d.ts +235 -0
- package/dist/lib/testing/facts.d.ts.map +1 -0
- package/dist/lib/testing/facts.js +209 -0
- package/dist/lib/testing/index.d.ts +58 -0
- package/dist/lib/testing/index.d.ts.map +1 -0
- package/dist/lib/testing/index.js +74 -0
- package/dist/lib/testing/queryable-span.d.ts +39 -0
- package/dist/lib/testing/queryable-span.d.ts.map +1 -0
- package/dist/lib/testing/queryable-span.js +58 -0
- package/dist/lib/testing/span-query.d.ts +21 -0
- package/dist/lib/testing/span-query.d.ts.map +1 -0
- package/dist/lib/testing/span-query.js +47 -0
- package/dist/lib/testing/stdio-replay.d.ts +4 -0
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -0
- package/dist/lib/testing/stdio-replay.js +42 -0
- package/dist/lib/testing/trace-query.d.ts +59 -0
- package/dist/lib/testing/trace-query.d.ts.map +1 -0
- package/dist/lib/testing/trace-query.js +462 -0
- package/dist/lib/testing/vitest-harness.d.ts +135 -0
- package/dist/lib/testing/vitest-harness.d.ts.map +1 -0
- package/dist/lib/testing/vitest-harness.js +486 -0
- package/dist/lib/threadId.d.ts +58 -0
- package/dist/lib/threadId.d.ts.map +1 -0
- package/dist/lib/threadId.js +123 -0
- package/dist/lib/traceContext.d.ts +116 -0
- package/dist/lib/traceContext.d.ts.map +1 -0
- package/dist/lib/traceContext.js +37 -0
- package/dist/lib/traceId.d.ts +78 -0
- package/dist/lib/traceId.d.ts.map +1 -0
- package/dist/lib/traceId.js +87 -0
- package/dist/lib/traceRoot.d.ts +133 -0
- package/dist/lib/traceRoot.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.d.ts +75 -0
- package/dist/lib/traceRoot.es.d.ts.map +1 -0
- package/dist/lib/traceRoot.es.js +129 -0
- package/dist/lib/traceRoot.js +19 -0
- package/dist/lib/traceRoot.node.d.ts +77 -0
- package/dist/lib/traceRoot.node.d.ts.map +1 -0
- package/dist/lib/traceRoot.node.js +133 -0
- package/dist/lib/traceRoot.universal.d.ts +3 -0
- package/dist/lib/traceRoot.universal.d.ts.map +1 -0
- package/dist/lib/traceRoot.universal.js +17 -0
- package/dist/lib/tracer.d.ts +296 -0
- package/dist/lib/tracer.d.ts.map +1 -0
- package/dist/lib/tracer.js +346 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +56 -0
- package/dist/lib/tracers/ArrayQueueTracer.d.ts.map +1 -0
- package/dist/lib/tracers/ArrayQueueTracer.js +67 -0
- package/dist/lib/tracers/CompositeTracer.d.ts +24 -0
- package/dist/lib/tracers/CompositeTracer.d.ts.map +1 -0
- package/dist/lib/tracers/CompositeTracer.js +57 -0
- package/dist/lib/tracers/NoOpTracer.d.ts +58 -0
- package/dist/lib/tracers/NoOpTracer.d.ts.map +1 -0
- package/dist/lib/tracers/NoOpTracer.js +41 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts +42 -0
- package/dist/lib/tracers/SQLiteTracer.d.ts.map +1 -0
- package/dist/lib/tracers/SQLiteTracer.js +84 -0
- package/dist/lib/tracers/StdioTracer.d.ts +83 -0
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -0
- package/dist/lib/tracers/StdioTracer.js +270 -0
- package/dist/lib/tracers/TestTracer.d.ts +95 -0
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -0
- package/dist/lib/tracers/TestTracer.js +87 -0
- package/dist/lib/tracers/index.d.ts +12 -0
- package/dist/lib/tracers/index.d.ts.map +1 -0
- package/dist/lib/tracers/index.js +11 -0
- package/dist/lib/types.d.ts +366 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/utf8Cache.d.ts +111 -0
- package/dist/lib/utf8Cache.d.ts.map +1 -0
- package/dist/lib/utf8Cache.js +177 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +88 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -0
- package/dist/lib/wasm/WasmBufferStrategy.js +138 -0
- package/dist/lib/wasm/wasmAllocator.d.ts +109 -0
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -0
- package/dist/lib/wasm/wasmAllocator.js +227 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +123 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -0
- package/dist/lib/wasm/wasmSpanBuffer.js +772 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts +167 -0
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -0
- package/dist/lib/wasm/wasmTraceRoot.js +264 -0
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +8 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +17 -0
- package/package.json +193 -0
- package/src/bun/preload.ts +11 -0
- package/src/bun/trace-preload.ts +14 -0
- package/src/es.ts +11 -0
- package/src/index.ts +194 -0
- package/src/lib/JsBufferStrategy.ts +102 -0
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +485 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +390 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +647 -0
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +292 -0
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +354 -0
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +127 -0
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +392 -0
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +389 -0
- package/src/lib/__tests__/arrow-conversion-algorithms.test.ts +54 -0
- package/src/lib/__tests__/arrow-test-helpers.ts +71 -0
- package/src/lib/__tests__/binary-e2e.test.ts +203 -0
- package/src/lib/__tests__/buffer-overflow-op-api.test.ts +608 -0
- package/src/lib/__tests__/buffer-overflow.test.ts +612 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +544 -0
- package/src/lib/__tests__/effective-schema.test.ts +439 -0
- package/src/lib/__tests__/flechette.test.ts +42 -0
- package/src/lib/__tests__/flushScheduler.test.ts +537 -0
- package/src/lib/__tests__/integration.test.ts +600 -0
- package/src/lib/__tests__/library.test.ts +934 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +849 -0
- package/src/lib/__tests__/op-context-binding.test.ts +135 -0
- package/src/lib/__tests__/op-metadata.test.ts +198 -0
- package/src/lib/__tests__/op-type-safety.test.ts +71 -0
- package/src/lib/__tests__/package-exports.test.ts +57 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +319 -0
- package/src/lib/__tests__/remapped-buffer-view.test.ts +635 -0
- package/src/lib/__tests__/scope-attributes.test.ts +348 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +680 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +435 -0
- package/src/lib/__tests__/test-helpers.ts +318 -0
- package/src/lib/__tests__/timestamp.test.ts +259 -0
- package/src/lib/__tests__/trace-archive-primitives.test.ts +98 -0
- package/src/lib/__tests__/traceContext-type-enforcement.test.ts +271 -0
- package/src/lib/__tests__/tracer.test.ts +211 -0
- package/src/lib/__tests__/type-narrowing.test.ts +137 -0
- package/src/lib/archive/chunkCompaction.ts +44 -0
- package/src/lib/archive/chunkEnvelope.ts +79 -0
- package/src/lib/archive/chunkRouting.ts +70 -0
- package/src/lib/archive/chunkStats.ts +25 -0
- package/src/lib/archive/index.ts +4 -0
- package/src/lib/arrow/capacityStats.ts +340 -0
- package/src/lib/arrow/dictionaries.ts +159 -0
- package/src/lib/arrow/flechette.ts +114 -0
- package/src/lib/arrow/utils.ts +126 -0
- package/src/lib/buffer/Nanoseconds.ts +131 -0
- package/src/lib/bufferStrategy.ts +106 -0
- package/src/lib/capacityTuning.ts +102 -0
- package/src/lib/codegen/__tests__/__snapshots__/evaluatorGenerator.test.ts.snap +160 -0
- package/src/lib/codegen/__tests__/__snapshots__/scopeGenerator.test.ts.snap +196 -0
- package/src/lib/codegen/__tests__/__snapshots__/spanLoggerGenerator.test.ts.snap +1965 -0
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +516 -0
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +207 -0
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +237 -0
- package/src/lib/codegen/evaluatorGenerator.ts +309 -0
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +444 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +715 -0
- package/src/lib/convertToArrow.ts +1805 -0
- package/src/lib/defineOpContext.ts +398 -0
- package/src/lib/errors/Blocked.ts +165 -0
- package/src/lib/errors/CodeError.ts +132 -0
- package/src/lib/errors/RetriesExhausted.ts +78 -0
- package/src/lib/errors/Transient.ts +168 -0
- package/src/lib/errors/__tests__/Blocked-config.test.ts +152 -0
- package/src/lib/errors/__tests__/Transient.test.ts +129 -0
- package/src/lib/errors/__tests__/retry-policy.test.ts +85 -0
- package/src/lib/errors/index.ts +24 -0
- package/src/lib/errors/retry-policy.ts +87 -0
- package/src/lib/flushScheduler.ts +509 -0
- package/src/lib/library.ts +682 -0
- package/src/lib/logApi.ts +70 -0
- package/src/lib/logBinding.ts +67 -0
- package/src/lib/op.ts +103 -0
- package/src/lib/opContext/__tests__/retry.test.ts +764 -0
- package/src/lib/opContext/contextTypes.ts +130 -0
- package/src/lib/opContext/createOpGroup.ts +456 -0
- package/src/lib/opContext/defineOp.ts +281 -0
- package/src/lib/opContext/featureFlagTypes.ts +54 -0
- package/src/lib/opContext/index.ts +16 -0
- package/src/lib/opContext/opGroupTypes.ts +342 -0
- package/src/lib/opContext/opTypes.ts +80 -0
- package/src/lib/opContext/spanContextTypes.ts +398 -0
- package/src/lib/opContext/types.ts +403 -0
- package/src/lib/result.ts +550 -0
- package/src/lib/schema/LogSchema.ts +153 -0
- package/src/lib/schema/__tests__/defineLogSchema.test.ts +342 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +443 -0
- package/src/lib/schema/builder.ts +201 -0
- package/src/lib/schema/defineFeatureFlags.ts +91 -0
- package/src/lib/schema/defineLogSchema.ts +291 -0
- package/src/lib/schema/evaluator.ts +404 -0
- package/src/lib/schema/extend.ts +69 -0
- package/src/lib/schema/systemSchema.ts +339 -0
- package/src/lib/schema/typeGuards.ts +163 -0
- package/src/lib/schema/types.ts +265 -0
- package/src/lib/spanBuffer.ts +571 -0
- package/src/lib/spanBufferHelpers.ts +73 -0
- package/src/lib/spanBufferStats.ts +40 -0
- package/src/lib/spanContext.ts +1566 -0
- package/src/lib/sqlite/__tests__/sqlite-common.test.ts +89 -0
- package/src/lib/sqlite/index.ts +26 -0
- package/src/lib/sqlite/sqlite-async-writer.ts +101 -0
- package/src/lib/sqlite/sqlite-common.ts +309 -0
- package/src/lib/sqlite/sqlite-d1.ts +104 -0
- package/src/lib/sqlite/sqlite-db.ts +32 -0
- package/src/lib/sqlite/sqlite-node.ts +83 -0
- package/src/lib/sqlite/sqlite-writer.ts +128 -0
- package/src/lib/testing/TRACE-TESTING.md +100 -0
- package/src/lib/testing/__tests__/bun-harness.test.ts +108 -0
- package/src/lib/testing/__tests__/extractFacts.test.ts +279 -0
- package/src/lib/testing/__tests__/facts.test.ts +324 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +32 -0
- package/src/lib/testing/bun-harness.ts +990 -0
- package/src/lib/testing/extractFacts.ts +362 -0
- package/src/lib/testing/facts.ts +470 -0
- package/src/lib/testing/index.ts +141 -0
- package/src/lib/testing/queryable-span.ts +108 -0
- package/src/lib/testing/span-query.ts +65 -0
- package/src/lib/testing/stdio-replay.ts +50 -0
- package/src/lib/testing/trace-query.ts +329 -0
- package/src/lib/testing/vitest-harness.ts +691 -0
- package/src/lib/threadId.ts +135 -0
- package/src/lib/traceContext.ts +182 -0
- package/src/lib/traceId.ts +142 -0
- package/src/lib/traceRoot.es.ts +157 -0
- package/src/lib/traceRoot.node.ts +170 -0
- package/src/lib/traceRoot.ts +154 -0
- package/src/lib/traceRoot.universal.ts +22 -0
- package/src/lib/tracer.ts +896 -0
- package/src/lib/tracers/ArrayQueueTracer.ts +76 -0
- package/src/lib/tracers/CompositeTracer.ts +76 -0
- package/src/lib/tracers/NoOpTracer.ts +73 -0
- package/src/lib/tracers/SQLiteTracer.ts +115 -0
- package/src/lib/tracers/StdioTracer.ts +380 -0
- package/src/lib/tracers/TestTracer.ts +146 -0
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +184 -0
- package/src/lib/tracers/__tests__/NoOpTracer.test.ts +204 -0
- package/src/lib/tracers/__tests__/StdioTracer.test.ts +313 -0
- package/src/lib/tracers/__tests__/TestTracer.test.ts +200 -0
- package/src/lib/tracers/index.ts +12 -0
- package/src/lib/types.ts +498 -0
- package/src/lib/utf8Cache.ts +201 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +219 -0
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +256 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +476 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +699 -0
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +449 -0
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +390 -0
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +444 -0
- package/src/lib/wasm/allocator.zig +945 -0
- package/src/lib/wasm/wasmAllocator.ts +469 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +1014 -0
- package/src/lib/wasm/wasmTraceRoot.ts +315 -0
- package/src/node.ts +10 -0
- package/src/testing.ts +18 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { createColumnBuffer } from '@smoothbricks/arrow-builder';
|
|
3
|
+
import { createTagWriter, S } from '@smoothbricks/lmao';
|
|
4
|
+
import { createSpanBuffer } from '../../spanBuffer.js';
|
|
5
|
+
|
|
6
|
+
import { createTestOpMetadata, createTestSchema, createTestTraceRoot } from '../test-helpers.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tests for lazy column initialization
|
|
10
|
+
*
|
|
11
|
+
* Per GitHub review feedback: Columns should only be allocated when accessed,
|
|
12
|
+
* not eagerly during buffer creation. This saves memory for sparse columns.
|
|
13
|
+
*
|
|
14
|
+
* COLUMN TYPES:
|
|
15
|
+
*
|
|
16
|
+
* 1. SpanBuffer-specific columns (NOT in schema, created in preamble):
|
|
17
|
+
* - timestamp, entry_type
|
|
18
|
+
* → ONLY exist on SpanBuffer, NOT on ColumnBuffer from createColumnBuffer()
|
|
19
|
+
* → Already tested in integration.test.ts lines 45-46
|
|
20
|
+
*
|
|
21
|
+
* 2. System SCHEMA columns (merged via createTestSchema → mergeWithSystemSchema):
|
|
22
|
+
* - message: S.category().eager() ← EAGER (allocated immediately)
|
|
23
|
+
* - line, error_code, etc. ← LAZY (default)
|
|
24
|
+
*
|
|
25
|
+
* 3. User SCHEMA columns:
|
|
26
|
+
* - Default: LAZY (allocated on first access)
|
|
27
|
+
* - Can be .eager() to allocate immediately
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
describe('Eager vs Lazy Column Allocation', () => {
|
|
31
|
+
it('eager schema columns allocated immediately, lazy user columns deferred', () => {
|
|
32
|
+
const schema = createTestSchema({
|
|
33
|
+
userId: S.category(),
|
|
34
|
+
requestId: S.category(),
|
|
35
|
+
count: S.number(),
|
|
36
|
+
active: S.boolean(),
|
|
37
|
+
});
|
|
38
|
+
// createColumnBuffer is generic and returns ColumnBuffer<T>
|
|
39
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
40
|
+
|
|
41
|
+
// System schema's message column is EAGER - always allocated (via mergeWithSystemSchema)
|
|
42
|
+
expect(Array.isArray(buffer.message_values)).toBe(true);
|
|
43
|
+
|
|
44
|
+
// Access ONE user column via _values suffix (category = Array now, not Uint32Array)
|
|
45
|
+
// Note: buffer.userId is a setter method, buffer.userId_values is the getter
|
|
46
|
+
const userIdColumn = buffer.userId_values;
|
|
47
|
+
expect(Array.isArray(userIdColumn)).toBe(true);
|
|
48
|
+
|
|
49
|
+
// Now check that OTHER user columns were NOT allocated
|
|
50
|
+
// Getters are on the prototype, not the instance
|
|
51
|
+
const proto = Object.getPrototypeOf(buffer);
|
|
52
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, 'requestId_values');
|
|
53
|
+
expect(descriptor?.get).toBeDefined(); // Should be a getter on prototype
|
|
54
|
+
|
|
55
|
+
// After access, the getter should be replaced with the value
|
|
56
|
+
const requestIdColumn = buffer.requestId_values;
|
|
57
|
+
expect(Array.isArray(requestIdColumn)).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should allocate null bitmaps lazily', () => {
|
|
61
|
+
const schema = createTestSchema({
|
|
62
|
+
userId: S.category(),
|
|
63
|
+
requestId: S.category(),
|
|
64
|
+
});
|
|
65
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
66
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
67
|
+
|
|
68
|
+
// Access userId column via _values suffix (category = Array now)
|
|
69
|
+
const userIdColumn = buffer.userId_values;
|
|
70
|
+
expect(Array.isArray(userIdColumn)).toBe(true);
|
|
71
|
+
|
|
72
|
+
// Check that userId's null bitmap was allocated (by accessing it)
|
|
73
|
+
const userIdBitmap = buffer.userId_nulls;
|
|
74
|
+
expect(userIdBitmap).toBeInstanceOf(Uint8Array);
|
|
75
|
+
|
|
76
|
+
// Check requestId's null bitmap is still a getter on prototype (not accessed yet)
|
|
77
|
+
const proto = Object.getPrototypeOf(buffer);
|
|
78
|
+
const bitmapDescriptor = Object.getOwnPropertyDescriptor(proto, 'requestId_nulls');
|
|
79
|
+
expect(bitmapDescriptor?.get).toBeDefined();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should save memory with sparse column access', () => {
|
|
83
|
+
const schema = createTestSchema({
|
|
84
|
+
col1: S.number(),
|
|
85
|
+
col2: S.number(),
|
|
86
|
+
col3: S.number(),
|
|
87
|
+
col4: S.number(),
|
|
88
|
+
col5: S.number(),
|
|
89
|
+
});
|
|
90
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
91
|
+
const buffer = createColumnBuffer(schema, 1024);
|
|
92
|
+
|
|
93
|
+
// Only access 2 of 5 columns (use _values suffix for the array)
|
|
94
|
+
buffer.col1_values[0] = 1;
|
|
95
|
+
buffer.col3_values[0] = 3;
|
|
96
|
+
|
|
97
|
+
// col2, col4, col5 should still be getters on prototype (not accessed yet)
|
|
98
|
+
// Note: use _values suffix to check the getter (not the setter method)
|
|
99
|
+
const proto = Object.getPrototypeOf(buffer);
|
|
100
|
+
const col2Desc = Object.getOwnPropertyDescriptor(proto, 'col2_values');
|
|
101
|
+
const col4Desc = Object.getOwnPropertyDescriptor(proto, 'col4_values');
|
|
102
|
+
const col5Desc = Object.getOwnPropertyDescriptor(proto, 'col5_values');
|
|
103
|
+
|
|
104
|
+
expect(col2Desc?.get).toBeDefined();
|
|
105
|
+
expect(col4Desc?.get).toBeDefined();
|
|
106
|
+
expect(col5Desc?.get).toBeDefined();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should have getters that become values after first access', () => {
|
|
110
|
+
const schema = createTestSchema({
|
|
111
|
+
field1: S.category(),
|
|
112
|
+
field2: S.number(),
|
|
113
|
+
});
|
|
114
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
115
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
116
|
+
|
|
117
|
+
// Before access: should be getter on prototype (use _values suffix)
|
|
118
|
+
const proto = Object.getPrototypeOf(buffer);
|
|
119
|
+
const beforeDesc = Object.getOwnPropertyDescriptor(proto, 'field1_values');
|
|
120
|
+
expect(beforeDesc?.get).toBeDefined();
|
|
121
|
+
|
|
122
|
+
// Access the column via _values suffix (category = Array now)
|
|
123
|
+
const column = buffer.field1_values;
|
|
124
|
+
expect(Array.isArray(column)).toBe(true);
|
|
125
|
+
|
|
126
|
+
// After access: the property should still work (getter returns cached value from symbol-keyed storage)
|
|
127
|
+
const afterValue = buffer.field1_values;
|
|
128
|
+
expect(afterValue).toBe(column); // Same instance returned
|
|
129
|
+
expect(Array.isArray(afterValue)).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('Lazy Column Initialization', () => {
|
|
134
|
+
it('should not allocate attribute columns until accessed', () => {
|
|
135
|
+
const schema = createTestSchema({
|
|
136
|
+
userId: S.category(),
|
|
137
|
+
requestId: S.category(),
|
|
138
|
+
operation: S.enum(['GET', 'POST', 'PUT', 'DELETE']),
|
|
139
|
+
duration: S.number(),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
143
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
144
|
+
|
|
145
|
+
// System schema's message column is EAGER - always allocated (via mergeWithSystemSchema)
|
|
146
|
+
// Note: timestamp/entry_type are SpanBuffer-specific, NOT in ColumnBuffer
|
|
147
|
+
expect(Array.isArray(buffer.message_values)).toBe(true);
|
|
148
|
+
|
|
149
|
+
// Access one attribute column via _values suffix - should allocate it lazily on first access
|
|
150
|
+
const userIdColumn = buffer.userId_values;
|
|
151
|
+
// Category stores raw strings in Array
|
|
152
|
+
expect(Array.isArray(userIdColumn)).toBe(true);
|
|
153
|
+
expect(userIdColumn.length).toBeGreaterThan(0);
|
|
154
|
+
|
|
155
|
+
// Access null bitmap - should allocate it lazily on first access
|
|
156
|
+
const userIdNulls = buffer.userId_nulls;
|
|
157
|
+
expect(userIdNulls).toBeInstanceOf(Uint8Array);
|
|
158
|
+
expect(userIdNulls.length).toBeGreaterThan(0);
|
|
159
|
+
|
|
160
|
+
// Verify lazy allocation worked by checking that multiple accesses return same object
|
|
161
|
+
expect(buffer.userId_values).toBe(userIdColumn);
|
|
162
|
+
expect(buffer.userId_nulls).toBe(userIdNulls);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should allocate correct TypedArray type for different schema types', () => {
|
|
166
|
+
const schema = createTestSchema({
|
|
167
|
+
smallEnum: S.enum(['A', 'B', 'C']), // < 256 values -> Uint8Array
|
|
168
|
+
category: S.category(), // -> Array<string> (no hot-path interning)
|
|
169
|
+
text: S.text(), // -> Array<string> (no hot-path interning)
|
|
170
|
+
num: S.number(), // -> Float64Array
|
|
171
|
+
bool: S.boolean(), // -> Uint8Array
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
175
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
176
|
+
|
|
177
|
+
// Access each column via _values suffix and verify type
|
|
178
|
+
// Per spec 01a:
|
|
179
|
+
// - enum: Uint8Array (small enums) or Uint16Array/Uint32Array (larger)
|
|
180
|
+
// - category: Array<string> (raw strings, no hot-path interning)
|
|
181
|
+
// - text: Array<string> (raw strings)
|
|
182
|
+
expect(buffer.smallEnum_values).toBeInstanceOf(Uint8Array);
|
|
183
|
+
expect(Array.isArray(buffer.category_values)).toBe(true); // Category stores raw strings
|
|
184
|
+
expect(Array.isArray(buffer.text_values)).toBe(true); // Text stores raw strings
|
|
185
|
+
expect(buffer.num_values).toBeInstanceOf(Float64Array);
|
|
186
|
+
expect(buffer.bool_values).toBeInstanceOf(Uint8Array);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should allocate small enum as Uint8Array', () => {
|
|
190
|
+
// Create enum with < 256 values (at the limit)
|
|
191
|
+
const enumValues = Array.from({ length: 256 }, (_, i) => `VALUE_${i}`);
|
|
192
|
+
const schema = createTestSchema({
|
|
193
|
+
maxEnum: S.enum(enumValues),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
197
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
198
|
+
|
|
199
|
+
// Should use Uint8Array for <= 255 values (use _values suffix)
|
|
200
|
+
expect(buffer.maxEnum_values).toBeInstanceOf(Uint8Array);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('should work correctly when writing to lazily-allocated columns', () => {
|
|
204
|
+
const schema = createTestSchema({
|
|
205
|
+
userId: S.category(),
|
|
206
|
+
count: S.number(),
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
210
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
211
|
+
|
|
212
|
+
// Write to columns via _values suffix (triggering lazy allocation)
|
|
213
|
+
// Category stores strings in Array (no hot-path interning)
|
|
214
|
+
const userIdColumn = buffer.userId_values;
|
|
215
|
+
const countColumn = buffer.count_values;
|
|
216
|
+
|
|
217
|
+
// Write a string value for category (raw strings stored directly)
|
|
218
|
+
userIdColumn[0] = 'user-123';
|
|
219
|
+
countColumn[0] = 45.67;
|
|
220
|
+
|
|
221
|
+
// Verify values
|
|
222
|
+
expect(userIdColumn[0]).toBe('user-123');
|
|
223
|
+
expect(countColumn[0]).toBe(45.67);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('should allow multiple accesses to the same column without re-allocation', () => {
|
|
227
|
+
const schema = createTestSchema({
|
|
228
|
+
userId: S.category(),
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
232
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
233
|
+
|
|
234
|
+
// First access (use _values suffix)
|
|
235
|
+
const column1 = buffer.userId_values;
|
|
236
|
+
|
|
237
|
+
// Second access - should return same array
|
|
238
|
+
const column2 = buffer.userId_values;
|
|
239
|
+
|
|
240
|
+
// Should be the exact same object
|
|
241
|
+
expect(column1).toBe(column2);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should handle null bitmap lazy initialization correctly', () => {
|
|
245
|
+
const schema = createTestSchema({
|
|
246
|
+
userId: S.category(),
|
|
247
|
+
requestId: S.category(),
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// createColumnBuffer expects ColumnSchema instance (schema extends LogSchema extends ColumnSchema)
|
|
251
|
+
const buffer = createColumnBuffer(schema, 64);
|
|
252
|
+
|
|
253
|
+
// Access one null bitmap
|
|
254
|
+
const userIdNulls = buffer.userId_nulls;
|
|
255
|
+
expect(userIdNulls).toBeInstanceOf(Uint8Array);
|
|
256
|
+
|
|
257
|
+
// Access another null bitmap
|
|
258
|
+
const requestIdNulls = buffer.requestId_nulls;
|
|
259
|
+
expect(requestIdNulls).toBeInstanceOf(Uint8Array);
|
|
260
|
+
|
|
261
|
+
// Should be different arrays
|
|
262
|
+
expect(userIdNulls).not.toBe(requestIdNulls);
|
|
263
|
+
|
|
264
|
+
// Multiple accesses should return same array
|
|
265
|
+
expect(buffer.userId_nulls).toBe(userIdNulls);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
describe('SpanBuffer Lazy Column Allocation', () => {
|
|
270
|
+
it('should have eager columns allocated immediately and lazy columns undefined until accessed', () => {
|
|
271
|
+
const schema = createTestSchema({
|
|
272
|
+
userId: S.category(),
|
|
273
|
+
requestId: S.category(),
|
|
274
|
+
count: S.number(),
|
|
275
|
+
operation: S.enum(['CREATE', 'READ', 'UPDATE', 'DELETE']),
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata(), 8);
|
|
279
|
+
|
|
280
|
+
// Eager columns (system columns) should be allocated immediately
|
|
281
|
+
expect(buffer.timestamp).toBeDefined();
|
|
282
|
+
expect(buffer.timestamp).toBeInstanceOf(BigInt64Array);
|
|
283
|
+
expect(buffer.entry_type).toBeDefined();
|
|
284
|
+
expect(buffer.entry_type).toBeInstanceOf(Uint8Array);
|
|
285
|
+
// Also check public aliases
|
|
286
|
+
expect(buffer.timestamp).toBe(buffer.timestamp);
|
|
287
|
+
expect(buffer.entry_type).toBe(buffer.entry_type);
|
|
288
|
+
|
|
289
|
+
// System schema's message column is EAGER - always allocated
|
|
290
|
+
expect(Array.isArray(buffer.message_values)).toBe(true);
|
|
291
|
+
|
|
292
|
+
// Lazy columns (user attributes) should be undefined before access
|
|
293
|
+
expect(buffer.getColumnIfAllocated('userId')).toBeUndefined();
|
|
294
|
+
expect(buffer.getColumnIfAllocated('requestId')).toBeUndefined();
|
|
295
|
+
expect(buffer.getColumnIfAllocated('count')).toBeUndefined();
|
|
296
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeUndefined();
|
|
297
|
+
|
|
298
|
+
// Access one lazy column - should trigger allocation
|
|
299
|
+
const userIdColumn = buffer.userId_values;
|
|
300
|
+
expect(Array.isArray(userIdColumn)).toBe(true);
|
|
301
|
+
|
|
302
|
+
// After access, the column should be allocated
|
|
303
|
+
expect(buffer.getColumnIfAllocated('userId')).toBeDefined();
|
|
304
|
+
expect(buffer.getColumnIfAllocated('userId')).toBe(userIdColumn);
|
|
305
|
+
|
|
306
|
+
// Other columns should still be undefined
|
|
307
|
+
expect(buffer.getColumnIfAllocated('requestId')).toBeUndefined();
|
|
308
|
+
expect(buffer.getColumnIfAllocated('count')).toBeUndefined();
|
|
309
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeUndefined();
|
|
310
|
+
|
|
311
|
+
// Access another column
|
|
312
|
+
const countColumn = buffer.count_values;
|
|
313
|
+
expect(countColumn).toBeInstanceOf(Float64Array);
|
|
314
|
+
|
|
315
|
+
// Now both accessed columns should be allocated
|
|
316
|
+
expect(buffer.getColumnIfAllocated('userId')).toBeDefined();
|
|
317
|
+
expect(buffer.getColumnIfAllocated('count')).toBeDefined();
|
|
318
|
+
expect(buffer.getColumnIfAllocated('count')).toBe(countColumn);
|
|
319
|
+
|
|
320
|
+
// Unaccessed columns should still be undefined
|
|
321
|
+
expect(buffer.getColumnIfAllocated('requestId')).toBeUndefined();
|
|
322
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeUndefined();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('should allocate lazy columns when TagWriter writes to them', () => {
|
|
326
|
+
const schema = createTestSchema({
|
|
327
|
+
userId: S.category(),
|
|
328
|
+
requestId: S.category(),
|
|
329
|
+
count: S.number(),
|
|
330
|
+
operation: S.enum(['CREATE', 'READ', 'UPDATE', 'DELETE']),
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
const buffer = createSpanBuffer(schema, createTestTraceRoot('test-trace'), createTestOpMetadata(), 8);
|
|
334
|
+
|
|
335
|
+
// Lazy columns should be undefined before TagWriter access
|
|
336
|
+
expect(buffer.getColumnIfAllocated('userId')).toBeUndefined();
|
|
337
|
+
expect(buffer.getColumnIfAllocated('requestId')).toBeUndefined();
|
|
338
|
+
expect(buffer.getColumnIfAllocated('count')).toBeUndefined();
|
|
339
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeUndefined();
|
|
340
|
+
|
|
341
|
+
// Create TagWriter and write to one column (createTagWriter expects LogSchema instance)
|
|
342
|
+
const tagWriter = createTagWriter(schema, buffer);
|
|
343
|
+
tagWriter.userId('user-123');
|
|
344
|
+
|
|
345
|
+
// After TagWriter write, the column should be allocated
|
|
346
|
+
expect(buffer.getColumnIfAllocated('userId')).toBeDefined();
|
|
347
|
+
const userIdColumn = buffer.getColumnIfAllocated('userId');
|
|
348
|
+
expect(Array.isArray(userIdColumn)).toBe(true);
|
|
349
|
+
if (!Array.isArray(userIdColumn)) {
|
|
350
|
+
throw new Error('Expected userId column to allocate as a string array');
|
|
351
|
+
}
|
|
352
|
+
expect(userIdColumn[0]).toBe('user-123');
|
|
353
|
+
|
|
354
|
+
// Other columns should still be undefined
|
|
355
|
+
expect(buffer.getColumnIfAllocated('requestId')).toBeUndefined();
|
|
356
|
+
expect(buffer.getColumnIfAllocated('count')).toBeUndefined();
|
|
357
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeUndefined();
|
|
358
|
+
|
|
359
|
+
// Write to another column via TagWriter
|
|
360
|
+
tagWriter.count(42);
|
|
361
|
+
|
|
362
|
+
// Now both columns should be allocated
|
|
363
|
+
expect(buffer.getColumnIfAllocated('userId')).toBeDefined();
|
|
364
|
+
expect(buffer.getColumnIfAllocated('count')).toBeDefined();
|
|
365
|
+
const countColumn = buffer.getColumnIfAllocated('count');
|
|
366
|
+
expect(countColumn).toBeInstanceOf(Float64Array);
|
|
367
|
+
if (!(countColumn instanceof Float64Array)) {
|
|
368
|
+
throw new Error('Expected count column to allocate as Float64Array');
|
|
369
|
+
}
|
|
370
|
+
expect(countColumn[0]).toBe(42);
|
|
371
|
+
|
|
372
|
+
// Unaccessed columns should still be undefined
|
|
373
|
+
expect(buffer.getColumnIfAllocated('requestId')).toBeUndefined();
|
|
374
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeUndefined();
|
|
375
|
+
|
|
376
|
+
// Write to enum column via TagWriter
|
|
377
|
+
tagWriter.operation('CREATE');
|
|
378
|
+
|
|
379
|
+
// Enum column should now be allocated
|
|
380
|
+
expect(buffer.getColumnIfAllocated('operation')).toBeDefined();
|
|
381
|
+
const operationColumn = buffer.getColumnIfAllocated('operation');
|
|
382
|
+
expect(operationColumn).toBeInstanceOf(Uint8Array);
|
|
383
|
+
if (!(operationColumn instanceof Uint8Array)) {
|
|
384
|
+
throw new Error('Expected operation column to allocate as Uint8Array');
|
|
385
|
+
}
|
|
386
|
+
// Enum values are mapped to indices (CREATE = 0, READ = 1, etc.)
|
|
387
|
+
expect(operationColumn[0]).toBe(0);
|
|
388
|
+
});
|
|
389
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import type { ColumnValueType } from '@smoothbricks/arrow-builder';
|
|
3
|
+
import { buildTextDictionary } from '../arrow/dictionaries.js';
|
|
4
|
+
import { concatenateNullBitmaps } from '../arrow/utils.js';
|
|
5
|
+
import { S } from '../schema/builder.js';
|
|
6
|
+
import { defineLogSchema } from '../schema/defineLogSchema.js';
|
|
7
|
+
import type { AnySpanBuffer } from '../types.js';
|
|
8
|
+
import { createBuffer } from './test-helpers.js';
|
|
9
|
+
|
|
10
|
+
function mockBuffer(
|
|
11
|
+
writeIndex: number,
|
|
12
|
+
column: ColumnValueType | undefined,
|
|
13
|
+
nulls: Uint8Array | undefined,
|
|
14
|
+
): AnySpanBuffer {
|
|
15
|
+
const buffer = createBuffer(
|
|
16
|
+
defineLogSchema({
|
|
17
|
+
field: S.text(),
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
buffer._writeIndex = writeIndex;
|
|
21
|
+
buffer.getColumnIfAllocated = (columnName: string): ColumnValueType | undefined =>
|
|
22
|
+
columnName === 'field' ? column : undefined;
|
|
23
|
+
buffer.getNullsIfAllocated = (columnName: string): Uint8Array | undefined =>
|
|
24
|
+
columnName === 'field' ? nulls : undefined;
|
|
25
|
+
return buffer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('arrow conversion algorithms', () => {
|
|
29
|
+
it('concatenateNullBitmaps handles non-byte-aligned buffer offsets', () => {
|
|
30
|
+
const buffers: AnySpanBuffer[] = [
|
|
31
|
+
mockBuffer(3, ['a', undefined, 'b'], new Uint8Array([0b00000101])),
|
|
32
|
+
mockBuffer(5, ['c', 'd', undefined, 'e', undefined], new Uint8Array([0b00001011])),
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const { nullBitmap, nullCount } = concatenateNullBitmaps(buffers, 'field');
|
|
36
|
+
|
|
37
|
+
expect(nullBitmap).toBeDefined();
|
|
38
|
+
expect(nullBitmap?.[0]).toBe(0b01011101);
|
|
39
|
+
expect(nullCount).toBe(3);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('buildTextDictionary marks all rows null when text column is never allocated', () => {
|
|
43
|
+
const buffers: AnySpanBuffer[] = [mockBuffer(2, undefined, undefined), mockBuffer(1, undefined, undefined)];
|
|
44
|
+
|
|
45
|
+
const result = buildTextDictionary(buffers, 'field');
|
|
46
|
+
|
|
47
|
+
expect(result).not.toBeNull();
|
|
48
|
+
expect(result?.dictionary).toEqual([]);
|
|
49
|
+
expect(result?.indices.length).toBe(3);
|
|
50
|
+
expect(result?.nullCount).toBe(3);
|
|
51
|
+
expect(result?.nullBitmap).toBeDefined();
|
|
52
|
+
expect(result?.nullBitmap?.[0]).toBe(0);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isRecord } from '@smoothbricks/validation';
|
|
2
|
+
import type { Column, Table } from '@uwdata/flechette';
|
|
3
|
+
import type { AnySpanBuffer } from '../types.js';
|
|
4
|
+
|
|
5
|
+
export function requireColumn(table: Table, columnName: string): Column<unknown> {
|
|
6
|
+
const column = table.getChild(columnName);
|
|
7
|
+
if (!column) {
|
|
8
|
+
throw new Error(`Column not found: ${columnName}`);
|
|
9
|
+
}
|
|
10
|
+
return column;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getColumnValue(table: Table, columnName: string, rowIndex: number): unknown {
|
|
14
|
+
return requireColumn(table, columnName).get(rowIndex);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getRawTimestamp(table: Table, rowIndex: number): bigint {
|
|
18
|
+
const column = requireColumn(table, 'timestamp');
|
|
19
|
+
const batch = column.data[0];
|
|
20
|
+
if (!batch || !(batch.values instanceof BigInt64Array)) {
|
|
21
|
+
throw new Error('timestamp column does not expose raw BigInt64Array values');
|
|
22
|
+
}
|
|
23
|
+
return batch.values[rowIndex];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function requireBinaryCell(column: Column<unknown>, rowIndex: number): Uint8Array {
|
|
27
|
+
const value = column.at(rowIndex);
|
|
28
|
+
if (!(value instanceof Uint8Array)) {
|
|
29
|
+
throw new Error(`Expected binary cell at row ${rowIndex}`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function nextWriterRow(writer: { nextRow(): unknown }): object {
|
|
35
|
+
const row = writer.nextRow();
|
|
36
|
+
if (!isRecord(row)) {
|
|
37
|
+
throw new Error('Expected createColumnWriter().nextRow() to return a row writer object');
|
|
38
|
+
}
|
|
39
|
+
return row;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function invokeWriterMethod(writer: object, methodName: string, value: unknown): object {
|
|
43
|
+
const method = Reflect.get(writer, methodName);
|
|
44
|
+
if (typeof method !== 'function') {
|
|
45
|
+
throw new Error(`Expected row writer method '${methodName}'`);
|
|
46
|
+
}
|
|
47
|
+
const next = Reflect.apply(method, writer, [value]);
|
|
48
|
+
if (!isRecord(next)) {
|
|
49
|
+
throw new Error(`Expected row writer method '${methodName}' to return a row writer object`);
|
|
50
|
+
}
|
|
51
|
+
return next;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function callBufferWriter(buffer: object, methodName: string, rowIndex: number, value: unknown): void {
|
|
55
|
+
const method = Reflect.get(buffer, methodName);
|
|
56
|
+
if (typeof method !== 'function') {
|
|
57
|
+
throw new Error(`Expected buffer writer '${methodName}'`);
|
|
58
|
+
}
|
|
59
|
+
Reflect.apply(method, buffer, [rowIndex, value]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isAnySpanBuffer(value: unknown): value is AnySpanBuffer {
|
|
63
|
+
return isRecord(value) && 'timestamp' in value && 'entry_type' in value && '_writeIndex' in value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function requireAnySpanBuffer(value: unknown, message: string): AnySpanBuffer {
|
|
67
|
+
if (!isAnySpanBuffer(value)) {
|
|
68
|
+
throw new Error(message);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|