@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,79 @@
|
|
|
1
|
+
export interface TraceChunkEnvelopeInput {
|
|
2
|
+
readonly file_ref: string;
|
|
3
|
+
readonly chunk_ref: string;
|
|
4
|
+
readonly row_count: number;
|
|
5
|
+
readonly started_at_ms: number;
|
|
6
|
+
readonly ended_at_ms: number;
|
|
7
|
+
readonly partition_keys?: readonly string[];
|
|
8
|
+
readonly metadata?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TraceChunkEnvelope {
|
|
12
|
+
readonly chunk_id: string;
|
|
13
|
+
readonly file_ref: string;
|
|
14
|
+
readonly chunk_ref: string;
|
|
15
|
+
readonly row_count: number;
|
|
16
|
+
readonly started_at_ms: number;
|
|
17
|
+
readonly ended_at_ms: number;
|
|
18
|
+
readonly partition_keys: readonly string[];
|
|
19
|
+
readonly metadata?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function buildTraceChunkEnvelope(input: TraceChunkEnvelopeInput): TraceChunkEnvelope {
|
|
23
|
+
const canonical = {
|
|
24
|
+
chunk_ref: input.chunk_ref,
|
|
25
|
+
ended_at_ms: input.ended_at_ms,
|
|
26
|
+
file_ref: input.file_ref,
|
|
27
|
+
metadata: input.metadata ?? null,
|
|
28
|
+
partition_keys: [...(input.partition_keys ?? [])].sort(),
|
|
29
|
+
row_count: input.row_count,
|
|
30
|
+
started_at_ms: input.started_at_ms,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const chunk_id = `chunk_${hashDeterministic(canonical)}`;
|
|
34
|
+
return {
|
|
35
|
+
chunk_id,
|
|
36
|
+
file_ref: input.file_ref,
|
|
37
|
+
chunk_ref: input.chunk_ref,
|
|
38
|
+
row_count: input.row_count,
|
|
39
|
+
started_at_ms: input.started_at_ms,
|
|
40
|
+
ended_at_ms: input.ended_at_ms,
|
|
41
|
+
partition_keys: canonical.partition_keys,
|
|
42
|
+
metadata: input.metadata,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function hashDeterministic(value: unknown): string {
|
|
47
|
+
return fnv1a64(stableSerialize(value));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function stableSerialize(value: unknown): string {
|
|
51
|
+
if (value === null) return 'null';
|
|
52
|
+
if (typeof value === 'number' || typeof value === 'boolean') return JSON.stringify(value);
|
|
53
|
+
if (typeof value === 'string') return JSON.stringify(value);
|
|
54
|
+
if (typeof value === 'bigint') {
|
|
55
|
+
return `"${value.toString()}n"`;
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
return `[${value.map((item) => stableSerialize(item)).join(',')}]`;
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === 'object') {
|
|
61
|
+
// null and array excluded above — TS narrows to `object` via direct typeof check
|
|
62
|
+
const entries = Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
63
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableSerialize(v)}`).join(',')}}`;
|
|
64
|
+
}
|
|
65
|
+
return JSON.stringify(String(value));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function fnv1a64(input: string): string {
|
|
69
|
+
let hash = 0xcbf29ce484222325n;
|
|
70
|
+
const prime = 0x100000001b3n;
|
|
71
|
+
const mod = 0xffffffffffffffffn;
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < input.length; i++) {
|
|
74
|
+
hash ^= BigInt(input.charCodeAt(i));
|
|
75
|
+
hash = (hash * prime) & mod;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return hash.toString(16).padStart(16, '0');
|
|
79
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type PartitionCardinality = 'single' | 'mixed' | 'unknown';
|
|
2
|
+
|
|
3
|
+
export interface PartitionSplit<T> {
|
|
4
|
+
readonly partition: string;
|
|
5
|
+
readonly selector: string;
|
|
6
|
+
readonly row_indexes: readonly number[];
|
|
7
|
+
readonly rows: readonly T[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function inspectPartitionCardinality<T>(
|
|
11
|
+
rows: readonly T[],
|
|
12
|
+
partitionOf: (row: T) => string | null | undefined,
|
|
13
|
+
): PartitionCardinality {
|
|
14
|
+
if (rows.length === 0) {
|
|
15
|
+
return 'unknown';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const partitions = new Set<string>();
|
|
19
|
+
for (const row of rows) {
|
|
20
|
+
const partition = partitionOf(row);
|
|
21
|
+
if (partition === undefined || partition === null || partition.length === 0) {
|
|
22
|
+
return 'unknown';
|
|
23
|
+
}
|
|
24
|
+
partitions.add(partition);
|
|
25
|
+
if (partitions.size > 1) {
|
|
26
|
+
return 'mixed';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return partitions.size === 1 ? 'single' : 'unknown';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function splitChunkByPartition<T>(
|
|
34
|
+
rows: readonly T[],
|
|
35
|
+
partitionOf: (row: T) => string | null | undefined,
|
|
36
|
+
partitionField = 'group',
|
|
37
|
+
): readonly PartitionSplit<T>[] {
|
|
38
|
+
const grouped = new Map<string, { indexes: number[]; rows: T[] }>();
|
|
39
|
+
|
|
40
|
+
for (let index = 0; index < rows.length; index++) {
|
|
41
|
+
const row = rows[index];
|
|
42
|
+
const partition = partitionOf(row);
|
|
43
|
+
if (partition === undefined || partition === null || partition.length === 0) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const group = grouped.get(partition);
|
|
48
|
+
if (group) {
|
|
49
|
+
group.indexes.push(index);
|
|
50
|
+
group.rows.push(row);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
grouped.set(partition, { indexes: [index], rows: [row] });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const keys = [...grouped.keys()].sort();
|
|
58
|
+
return keys.map((partition) => {
|
|
59
|
+
const group = grouped.get(partition);
|
|
60
|
+
if (!group) {
|
|
61
|
+
throw new Error(`invariant throw: missing partition group for ${partition}`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
partition,
|
|
65
|
+
selector: `${partitionField} == ${JSON.stringify(partition)}`,
|
|
66
|
+
row_indexes: group.indexes,
|
|
67
|
+
rows: group.rows,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TraceChunkEnvelope } from './chunkEnvelope.js';
|
|
2
|
+
import type { PartitionSplit } from './chunkRouting.js';
|
|
3
|
+
|
|
4
|
+
export interface TraceChunkStats {
|
|
5
|
+
readonly chunk_id: string;
|
|
6
|
+
readonly row_count: number;
|
|
7
|
+
readonly partition_count: number;
|
|
8
|
+
readonly started_at_ms: number;
|
|
9
|
+
readonly ended_at_ms: number;
|
|
10
|
+
readonly duration_ms: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function extractChunkStats<T>(
|
|
14
|
+
envelope: TraceChunkEnvelope,
|
|
15
|
+
partitions: readonly PartitionSplit<T>[] = [],
|
|
16
|
+
): TraceChunkStats {
|
|
17
|
+
return {
|
|
18
|
+
chunk_id: envelope.chunk_id,
|
|
19
|
+
row_count: envelope.row_count,
|
|
20
|
+
partition_count: partitions.length,
|
|
21
|
+
started_at_ms: envelope.started_at_ms,
|
|
22
|
+
ended_at_ms: envelope.ended_at_ms,
|
|
23
|
+
duration_ms: Math.max(0, envelope.ended_at_ms - envelope.started_at_ms),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import {
|
|
2
|
+
bool,
|
|
3
|
+
type Column,
|
|
4
|
+
dictionary,
|
|
5
|
+
float64,
|
|
6
|
+
type IntType,
|
|
7
|
+
int8,
|
|
8
|
+
type Table,
|
|
9
|
+
TimeUnit,
|
|
10
|
+
tableFromColumns,
|
|
11
|
+
timestamp,
|
|
12
|
+
uint8,
|
|
13
|
+
uint32,
|
|
14
|
+
uint64,
|
|
15
|
+
utf8,
|
|
16
|
+
} from '@uwdata/flechette';
|
|
17
|
+
import { SYSTEM_SCHEMA_FIELD_NAMES } from '../schema/systemSchema.js';
|
|
18
|
+
import { getSchemaType } from '../schema/typeGuards.js';
|
|
19
|
+
import type { SpanBufferConstructor } from '../spanBuffer.js';
|
|
20
|
+
import type { OpMetadata } from '../types.js';
|
|
21
|
+
import { getArrowIndexTypeOr, makeArrowColumn } from './flechette.js';
|
|
22
|
+
import { getArrowFieldName } from './utils.js';
|
|
23
|
+
|
|
24
|
+
export interface CapacityStatsEntry {
|
|
25
|
+
bufferClass: SpanBufferConstructor;
|
|
26
|
+
metadata: OpMetadata;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const F64Array = Float64Array;
|
|
30
|
+
|
|
31
|
+
type Utf8Encoded = {
|
|
32
|
+
data: Uint8Array;
|
|
33
|
+
offsets: Int32Array;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function encodeUtf8(strings: string[]): Utf8Encoded {
|
|
37
|
+
const enc = new TextEncoder();
|
|
38
|
+
const bytes = strings.map((s) => enc.encode(s));
|
|
39
|
+
const total = bytes.reduce((n, b) => n + b.length, 0);
|
|
40
|
+
const data = new Uint8Array(total);
|
|
41
|
+
const offsets = new Int32Array(strings.length + 1);
|
|
42
|
+
let pos = 0;
|
|
43
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
44
|
+
data.set(bytes[i], pos);
|
|
45
|
+
offsets[i] = pos;
|
|
46
|
+
pos += bytes[i].length;
|
|
47
|
+
}
|
|
48
|
+
offsets[strings.length] = pos;
|
|
49
|
+
return { data, offsets };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function indexTypeForCount(count: number): IntType {
|
|
53
|
+
return count <= 255 ? uint8() : uint32();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function append(entries: [string, Column<unknown>][], name: string, column: Column<unknown>): void {
|
|
57
|
+
entries.push([name, column]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function createCapacityStatsTable(
|
|
61
|
+
entriesToLog: CapacityStatsEntry[],
|
|
62
|
+
periodStartNs: bigint,
|
|
63
|
+
mergedSchema: Record<string, unknown>,
|
|
64
|
+
): Table {
|
|
65
|
+
if (entriesToLog.length === 0) return tableFromColumns({});
|
|
66
|
+
|
|
67
|
+
const rowsPerModule = 4;
|
|
68
|
+
const totalRows = entriesToLog.length * rowsPerModule;
|
|
69
|
+
|
|
70
|
+
const entryTypeStrings = ['period-start', 'buffer-writes', 'buffer-spans', 'buffer-capacity'];
|
|
71
|
+
const [periodStartIdx, writesIdx, spansIdx, capacityIdx] = [0, 1, 2, 3];
|
|
72
|
+
|
|
73
|
+
const traceIdStrings = [''];
|
|
74
|
+
const packageNameStrings = Array.from(new Set(entriesToLog.map((e) => e.metadata.package_name)));
|
|
75
|
+
const packageFileStrings = Array.from(new Set(entriesToLog.map((e) => e.metadata.package_file)));
|
|
76
|
+
const gitShaStrings = Array.from(new Set(entriesToLog.map((e) => e.metadata.git_sha)));
|
|
77
|
+
const messageStrings = [''];
|
|
78
|
+
|
|
79
|
+
const packageNameMap = new Map(packageNameStrings.map((v, i) => [v, i]));
|
|
80
|
+
const packageFileMap = new Map(packageFileStrings.map((v, i) => [v, i]));
|
|
81
|
+
const gitShaMap = new Map(gitShaStrings.map((v, i) => [v, i]));
|
|
82
|
+
|
|
83
|
+
const entryTypes = new Int8Array(totalRows);
|
|
84
|
+
const traceIds = new Uint8Array(totalRows);
|
|
85
|
+
const packageNames = new Uint32Array(totalRows);
|
|
86
|
+
const packageFiles = new Uint32Array(totalRows);
|
|
87
|
+
const gitShas = new Uint32Array(totalRows);
|
|
88
|
+
const messages = new Uint8Array(totalRows);
|
|
89
|
+
|
|
90
|
+
const timestamps = new BigInt64Array(totalRows);
|
|
91
|
+
const threadIds = new BigUint64Array(totalRows);
|
|
92
|
+
const spanIds = new Uint32Array(totalRows);
|
|
93
|
+
const parentThreadIds = new BigUint64Array(totalRows);
|
|
94
|
+
const parentSpanIds = new Uint32Array(totalRows);
|
|
95
|
+
const uint64Values = new BigUint64Array(totalRows);
|
|
96
|
+
|
|
97
|
+
const parentThreadValidity = new Uint8Array(Math.ceil(totalRows / 8));
|
|
98
|
+
const parentSpanValidity = new Uint8Array(Math.ceil(totalRows / 8));
|
|
99
|
+
|
|
100
|
+
for (let m = 0; m < entriesToLog.length; m++) {
|
|
101
|
+
const base = m * rowsPerModule;
|
|
102
|
+
const { bufferClass, metadata } = entriesToLog[m];
|
|
103
|
+
|
|
104
|
+
const pName = packageNameMap.get(metadata.package_name) ?? 0;
|
|
105
|
+
const pFile = packageFileMap.get(metadata.package_file) ?? 0;
|
|
106
|
+
const gSha = gitShaMap.get(metadata.git_sha) ?? 0;
|
|
107
|
+
|
|
108
|
+
const stats = bufferClass.stats;
|
|
109
|
+
const values = [periodStartNs, BigInt(stats.totalWrites), BigInt(stats.spansCreated), BigInt(stats.capacity)];
|
|
110
|
+
const kinds = [periodStartIdx, writesIdx, spansIdx, capacityIdx];
|
|
111
|
+
|
|
112
|
+
for (let i = 0; i < rowsPerModule; i++) {
|
|
113
|
+
const row = base + i;
|
|
114
|
+
entryTypes[row] = kinds[i];
|
|
115
|
+
traceIds[row] = 0;
|
|
116
|
+
packageNames[row] = pName;
|
|
117
|
+
packageFiles[row] = pFile;
|
|
118
|
+
gitShas[row] = gSha;
|
|
119
|
+
messages[row] = 0;
|
|
120
|
+
uint64Values[row] = values[i];
|
|
121
|
+
timestamps[row] = periodStartNs;
|
|
122
|
+
threadIds[row] = 0n;
|
|
123
|
+
spanIds[row] = 0;
|
|
124
|
+
parentThreadIds[row] = 0n;
|
|
125
|
+
parentSpanIds[row] = 0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const entryTypeUtf8 = encodeUtf8(entryTypeStrings);
|
|
130
|
+
const traceIdUtf8 = encodeUtf8(traceIdStrings);
|
|
131
|
+
const packageNameUtf8 = encodeUtf8(packageNameStrings);
|
|
132
|
+
const packageFileUtf8 = encodeUtf8(packageFileStrings);
|
|
133
|
+
const gitShaUtf8 = encodeUtf8(gitShaStrings);
|
|
134
|
+
const messageUtf8 = encodeUtf8(messageStrings);
|
|
135
|
+
|
|
136
|
+
const cols: [string, Column<unknown>][] = [];
|
|
137
|
+
|
|
138
|
+
append(
|
|
139
|
+
cols,
|
|
140
|
+
'timestamp',
|
|
141
|
+
makeArrowColumn({ type: timestamp(TimeUnit.NANOSECOND), length: totalRows, nullCount: 0, values: timestamps }),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
append(
|
|
145
|
+
cols,
|
|
146
|
+
'trace_id',
|
|
147
|
+
makeArrowColumn({
|
|
148
|
+
type: dictionary(utf8(), indexTypeForCount(traceIdStrings.length), false, 0),
|
|
149
|
+
length: totalRows,
|
|
150
|
+
nullCount: 0,
|
|
151
|
+
values: traceIds,
|
|
152
|
+
dictionary: makeArrowColumn({
|
|
153
|
+
type: utf8(),
|
|
154
|
+
length: traceIdStrings.length,
|
|
155
|
+
nullCount: 0,
|
|
156
|
+
values: traceIdUtf8.data,
|
|
157
|
+
offsets: traceIdUtf8.offsets,
|
|
158
|
+
}),
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
append(cols, 'thread_id', makeArrowColumn({ type: uint64(), length: totalRows, nullCount: 0, values: threadIds }));
|
|
163
|
+
append(cols, 'span_id', makeArrowColumn({ type: uint32(), length: totalRows, nullCount: 0, values: spanIds }));
|
|
164
|
+
append(
|
|
165
|
+
cols,
|
|
166
|
+
'parent_thread_id',
|
|
167
|
+
makeArrowColumn({
|
|
168
|
+
type: uint64(),
|
|
169
|
+
length: totalRows,
|
|
170
|
+
nullCount: totalRows,
|
|
171
|
+
values: parentThreadIds,
|
|
172
|
+
validity: parentThreadValidity,
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
append(
|
|
176
|
+
cols,
|
|
177
|
+
'parent_span_id',
|
|
178
|
+
makeArrowColumn({
|
|
179
|
+
type: uint32(),
|
|
180
|
+
length: totalRows,
|
|
181
|
+
nullCount: totalRows,
|
|
182
|
+
values: parentSpanIds,
|
|
183
|
+
validity: parentSpanValidity,
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
append(
|
|
188
|
+
cols,
|
|
189
|
+
'entry_type',
|
|
190
|
+
makeArrowColumn({
|
|
191
|
+
type: dictionary(utf8(), int8(), false, 1),
|
|
192
|
+
length: totalRows,
|
|
193
|
+
nullCount: 0,
|
|
194
|
+
values: entryTypes,
|
|
195
|
+
dictionary: makeArrowColumn({
|
|
196
|
+
type: utf8(),
|
|
197
|
+
length: entryTypeStrings.length,
|
|
198
|
+
nullCount: 0,
|
|
199
|
+
values: entryTypeUtf8.data,
|
|
200
|
+
offsets: entryTypeUtf8.offsets,
|
|
201
|
+
}),
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
append(
|
|
206
|
+
cols,
|
|
207
|
+
'package_name',
|
|
208
|
+
makeArrowColumn({
|
|
209
|
+
type: dictionary(utf8(), indexTypeForCount(packageNameStrings.length), false, 2),
|
|
210
|
+
length: totalRows,
|
|
211
|
+
nullCount: 0,
|
|
212
|
+
values: packageNames,
|
|
213
|
+
dictionary: makeArrowColumn({
|
|
214
|
+
type: utf8(),
|
|
215
|
+
length: packageNameStrings.length,
|
|
216
|
+
nullCount: 0,
|
|
217
|
+
values: packageNameUtf8.data,
|
|
218
|
+
offsets: packageNameUtf8.offsets,
|
|
219
|
+
}),
|
|
220
|
+
}),
|
|
221
|
+
);
|
|
222
|
+
append(
|
|
223
|
+
cols,
|
|
224
|
+
'package_file',
|
|
225
|
+
makeArrowColumn({
|
|
226
|
+
type: dictionary(utf8(), indexTypeForCount(packageFileStrings.length), false, 3),
|
|
227
|
+
length: totalRows,
|
|
228
|
+
nullCount: 0,
|
|
229
|
+
values: packageFiles,
|
|
230
|
+
dictionary: makeArrowColumn({
|
|
231
|
+
type: utf8(),
|
|
232
|
+
length: packageFileStrings.length,
|
|
233
|
+
nullCount: 0,
|
|
234
|
+
values: packageFileUtf8.data,
|
|
235
|
+
offsets: packageFileUtf8.offsets,
|
|
236
|
+
}),
|
|
237
|
+
}),
|
|
238
|
+
);
|
|
239
|
+
append(
|
|
240
|
+
cols,
|
|
241
|
+
'git_sha',
|
|
242
|
+
makeArrowColumn({
|
|
243
|
+
type: dictionary(utf8(), indexTypeForCount(gitShaStrings.length), false, 4),
|
|
244
|
+
length: totalRows,
|
|
245
|
+
nullCount: 0,
|
|
246
|
+
values: gitShas,
|
|
247
|
+
dictionary: makeArrowColumn({
|
|
248
|
+
type: utf8(),
|
|
249
|
+
length: gitShaStrings.length,
|
|
250
|
+
nullCount: 0,
|
|
251
|
+
values: gitShaUtf8.data,
|
|
252
|
+
offsets: gitShaUtf8.offsets,
|
|
253
|
+
}),
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
append(
|
|
257
|
+
cols,
|
|
258
|
+
'message',
|
|
259
|
+
makeArrowColumn({
|
|
260
|
+
type: dictionary(utf8(), indexTypeForCount(messageStrings.length), false, 5),
|
|
261
|
+
length: totalRows,
|
|
262
|
+
nullCount: 0,
|
|
263
|
+
values: messages,
|
|
264
|
+
dictionary: makeArrowColumn({
|
|
265
|
+
type: utf8(),
|
|
266
|
+
length: messageStrings.length,
|
|
267
|
+
nullCount: 0,
|
|
268
|
+
values: messageUtf8.data,
|
|
269
|
+
offsets: messageUtf8.offsets,
|
|
270
|
+
}),
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
273
|
+
append(
|
|
274
|
+
cols,
|
|
275
|
+
'uint64_value',
|
|
276
|
+
makeArrowColumn({ type: uint64(), length: totalRows, nullCount: 0, values: uint64Values }),
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
for (const [fieldName, fieldSchema] of Object.entries(mergedSchema)) {
|
|
280
|
+
if (SYSTEM_SCHEMA_FIELD_NAMES.has(fieldName)) continue;
|
|
281
|
+
const lmaoType = getSchemaType(fieldSchema);
|
|
282
|
+
const arrowFieldName = getArrowFieldName(fieldName);
|
|
283
|
+
|
|
284
|
+
if (lmaoType === 'number') {
|
|
285
|
+
append(
|
|
286
|
+
cols,
|
|
287
|
+
arrowFieldName,
|
|
288
|
+
makeArrowColumn({
|
|
289
|
+
type: float64(),
|
|
290
|
+
length: totalRows,
|
|
291
|
+
nullCount: totalRows,
|
|
292
|
+
values: new F64Array(totalRows),
|
|
293
|
+
validity: new Uint8Array(Math.ceil(totalRows / 8)),
|
|
294
|
+
}),
|
|
295
|
+
);
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (lmaoType === 'boolean') {
|
|
300
|
+
append(
|
|
301
|
+
cols,
|
|
302
|
+
arrowFieldName,
|
|
303
|
+
makeArrowColumn({
|
|
304
|
+
type: bool(),
|
|
305
|
+
length: totalRows,
|
|
306
|
+
nullCount: totalRows,
|
|
307
|
+
values: new Uint8Array(Math.ceil(totalRows / 8)),
|
|
308
|
+
validity: new Uint8Array(Math.ceil(totalRows / 8)),
|
|
309
|
+
}),
|
|
310
|
+
);
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
let idxType: IntType = uint8();
|
|
315
|
+
if (lmaoType === 'enum') {
|
|
316
|
+
idxType = getArrowIndexTypeOr(fieldSchema, uint8());
|
|
317
|
+
}
|
|
318
|
+
const dictType = dictionary(utf8(), idxType);
|
|
319
|
+
append(
|
|
320
|
+
cols,
|
|
321
|
+
arrowFieldName,
|
|
322
|
+
makeArrowColumn({
|
|
323
|
+
type: dictType,
|
|
324
|
+
length: totalRows,
|
|
325
|
+
nullCount: totalRows,
|
|
326
|
+
values: new Uint8Array(totalRows),
|
|
327
|
+
validity: new Uint8Array(Math.ceil(totalRows / 8)),
|
|
328
|
+
dictionary: makeArrowColumn({
|
|
329
|
+
type: utf8(),
|
|
330
|
+
length: 1,
|
|
331
|
+
nullCount: 0,
|
|
332
|
+
values: new Uint8Array(0),
|
|
333
|
+
offsets: new Int32Array([0, 0]),
|
|
334
|
+
}),
|
|
335
|
+
}),
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return tableFromColumns(cols);
|
|
340
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dictionary building for Arrow conversion
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { type IntType, uint8, uint16, uint32 } from '@uwdata/flechette';
|
|
6
|
+
import type { AnySpanBuffer } from '../types.js';
|
|
7
|
+
import { concatenateNullBitmaps } from './utils.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Dictionary build result with consistent shape for V8 optimization.
|
|
11
|
+
* Using a class ensures all instances share the same hidden class.
|
|
12
|
+
*/
|
|
13
|
+
export class DictionaryBuildResult {
|
|
14
|
+
constructor(
|
|
15
|
+
public readonly dictionary: string[],
|
|
16
|
+
public readonly indices: Uint8Array | Uint16Array | Uint32Array,
|
|
17
|
+
public readonly indexArrayCtor: Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor,
|
|
18
|
+
public readonly arrowIndexType: IntType,
|
|
19
|
+
public readonly nullBitmap: Uint8Array | undefined,
|
|
20
|
+
public readonly nullCount: number,
|
|
21
|
+
) {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Build a sorted category dictionary from buffers
|
|
26
|
+
*/
|
|
27
|
+
export function buildSortedCategoryDictionary(
|
|
28
|
+
buffers: AnySpanBuffer[],
|
|
29
|
+
columnName: string,
|
|
30
|
+
maskTransform?: (value: string) => string,
|
|
31
|
+
): DictionaryBuildResult {
|
|
32
|
+
const totalRows = buffers.reduce((sum, buf) => sum + buf._writeIndex, 0);
|
|
33
|
+
|
|
34
|
+
// Build mapping from original value to masked value (for dictionary lookup)
|
|
35
|
+
// and collect unique masked values for the dictionary
|
|
36
|
+
const uniqueMaskedStrings = new Set<string>();
|
|
37
|
+
const originalToMasked = new Map<string, string>();
|
|
38
|
+
|
|
39
|
+
for (const buf of buffers) {
|
|
40
|
+
const column = buf.getColumnIfAllocated(columnName);
|
|
41
|
+
if (column && Array.isArray(column)) {
|
|
42
|
+
for (let i = 0; i < buf._writeIndex; i++) {
|
|
43
|
+
const value = column[i];
|
|
44
|
+
if (typeof value === 'string' && !originalToMasked.has(value)) {
|
|
45
|
+
const maskedValue = maskTransform ? maskTransform(value) : value;
|
|
46
|
+
originalToMasked.set(value, maskedValue);
|
|
47
|
+
uniqueMaskedStrings.add(maskedValue);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const dictionary = Array.from(uniqueMaskedStrings).sort();
|
|
54
|
+
const maskedToIndex = new Map(dictionary.map((s, i) => [s, i]));
|
|
55
|
+
|
|
56
|
+
// Determine index type constructors based on dictionary size
|
|
57
|
+
const uniqueCount = dictionary.length;
|
|
58
|
+
const indexArrayCtor = uniqueCount <= 255 ? Uint8Array : uniqueCount <= 65535 ? Uint16Array : Uint32Array;
|
|
59
|
+
const arrowIndexType = uniqueCount <= 255 ? uint8() : uniqueCount <= 65535 ? uint16() : uint32();
|
|
60
|
+
const indices = new indexArrayCtor(totalRows);
|
|
61
|
+
const { nullBitmap, nullCount } = concatenateNullBitmaps(buffers, columnName);
|
|
62
|
+
|
|
63
|
+
let rowOffset = 0;
|
|
64
|
+
for (const buf of buffers) {
|
|
65
|
+
const column = buf.getColumnIfAllocated(columnName);
|
|
66
|
+
if (column && Array.isArray(column)) {
|
|
67
|
+
for (let i = 0; i < buf._writeIndex; i++) {
|
|
68
|
+
const value = column[i];
|
|
69
|
+
if (typeof value === 'string') {
|
|
70
|
+
const maskedValue = originalToMasked.get(value) ?? value;
|
|
71
|
+
indices[rowOffset + i] = maskedToIndex.get(maskedValue) ?? 0;
|
|
72
|
+
} else {
|
|
73
|
+
indices[rowOffset + i] = 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
rowOffset += buf._writeIndex;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return new DictionaryBuildResult(dictionary, indices, indexArrayCtor, arrowIndexType, nullBitmap, nullCount);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Build a text dictionary from buffers (not sorted, uses frequency-based optimization)
|
|
85
|
+
*/
|
|
86
|
+
export function buildTextDictionary(
|
|
87
|
+
buffers: AnySpanBuffer[],
|
|
88
|
+
columnName: string,
|
|
89
|
+
maskTransform?: (value: string) => string,
|
|
90
|
+
): DictionaryBuildResult | null {
|
|
91
|
+
const totalRows = buffers.reduce((sum, buf) => sum + buf._writeIndex, 0);
|
|
92
|
+
|
|
93
|
+
// Build mapping from original value to masked value and track frequency of masked values
|
|
94
|
+
const frequencyMap = new Map<string, number>();
|
|
95
|
+
const originalToMasked = new Map<string, string>();
|
|
96
|
+
|
|
97
|
+
for (const buf of buffers) {
|
|
98
|
+
const column = buf.getColumnIfAllocated(columnName);
|
|
99
|
+
if (column && Array.isArray(column)) {
|
|
100
|
+
for (let i = 0; i < buf._writeIndex; i++) {
|
|
101
|
+
const value = column[i];
|
|
102
|
+
if (typeof value === 'string') {
|
|
103
|
+
let maskedValue: string;
|
|
104
|
+
if (originalToMasked.has(value)) {
|
|
105
|
+
const masked = originalToMasked.get(value);
|
|
106
|
+
if (masked === undefined) {
|
|
107
|
+
throw new Error(`Masked value not found for: ${value}`);
|
|
108
|
+
}
|
|
109
|
+
maskedValue = masked;
|
|
110
|
+
} else {
|
|
111
|
+
maskedValue = maskTransform ? maskTransform(value) : value;
|
|
112
|
+
originalToMasked.set(value, maskedValue);
|
|
113
|
+
}
|
|
114
|
+
frequencyMap.set(maskedValue, (frequencyMap.get(maskedValue) ?? 0) + 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (frequencyMap.size === 0) {
|
|
121
|
+
return new DictionaryBuildResult(
|
|
122
|
+
[],
|
|
123
|
+
new Uint32Array(totalRows),
|
|
124
|
+
Uint32Array,
|
|
125
|
+
uint32(),
|
|
126
|
+
new Uint8Array(Math.ceil(totalRows / 8)),
|
|
127
|
+
totalRows,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const dictionary = Array.from(frequencyMap.keys());
|
|
132
|
+
const maskedToIndex = new Map(dictionary.map((s, i) => [s, i]));
|
|
133
|
+
|
|
134
|
+
// Determine index type constructors based on dictionary size
|
|
135
|
+
const uniqueCount = dictionary.length;
|
|
136
|
+
const indexArrayCtor = uniqueCount <= 255 ? Uint8Array : uniqueCount <= 65535 ? Uint16Array : Uint32Array;
|
|
137
|
+
const arrowIndexType = uniqueCount <= 255 ? uint8() : uniqueCount <= 65535 ? uint16() : uint32();
|
|
138
|
+
const indices = new indexArrayCtor(totalRows);
|
|
139
|
+
const { nullBitmap, nullCount } = concatenateNullBitmaps(buffers, columnName);
|
|
140
|
+
|
|
141
|
+
let rowOffset = 0;
|
|
142
|
+
for (const buf of buffers) {
|
|
143
|
+
const column = buf.getColumnIfAllocated(columnName);
|
|
144
|
+
if (column && Array.isArray(column)) {
|
|
145
|
+
for (let i = 0; i < buf._writeIndex; i++) {
|
|
146
|
+
const value = column[i];
|
|
147
|
+
if (typeof value === 'string') {
|
|
148
|
+
const maskedValue = originalToMasked.get(value) ?? value;
|
|
149
|
+
indices[rowOffset + i] = maskedToIndex.get(maskedValue) ?? 0;
|
|
150
|
+
} else {
|
|
151
|
+
indices[rowOffset + i] = 0;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
rowOffset += buf._writeIndex;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return new DictionaryBuildResult(dictionary, indices, indexArrayCtor, arrowIndexType, nullBitmap, nullCount);
|
|
159
|
+
}
|