Skip to content

Group storage annotations per storage and per BanyanDB engine - #14274

Merged
wu-sheng merged 1 commit into
masterfrom
storage-annotation-breakdown
Nov 27, 2026
Merged

wu-sheng merged 1 commit into
masterfrom
storage-annotation-breakdown

Conversation

@wu-sheng

@wu-sheng wu-sheng commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Implements #14270: storage annotations grouped per storage and per BanyanDB engine. The issue lists where every annotation now lives; in short:

  • An attribute only one storage reads moves under that storage's annotation, and its value into that storage's extension of the model: @Column(indexOnly) → @ElasticSearch.IndexOnly; @Stream(allowBootReshape) → @BanyanDB.Stream.AllowBootReshape, for streams only (the installer's boot-reshape path for measures, which no production measure used, is removed, with its BanyanDBIT case).
  • BanyanDB annotations are grouped by engine: @BanyanDB.Measure.*, @BanyanDB.IndexMode.*, @BanyanDB.Stream.*, @BanyanDB.Trace.*. MeasureField → Measure.Field; a trace's NoIndexing → Trace.InSpanPayloadOnly; the two EnableSort on trace models, which BanyanDB never read, are removed.
  • @BanyanDB.Trace.StoreAsAttachmentOf(Target.class) replaces the BanyanDBTrace.MergeTable interface for the two span-attached-event models: their rows go into the target's trace, and its query returns them. The target model gives the trace, its group and its columns, and BanyanDB's write path for those events reads them from the model.
  • OAL code generation emits @BanyanDB.Measure.SeriesID / @BanyanDB.Measure.ShardingKey.

Besides the annotations, the change touches the model definition, the installers and schema builders, BanyanDB's write path for the attached events, and the annotation names OAL code generation emits. No config, query or analysis change.

Also fixes OAL maxDouble() / minDouble(): their double column was named value, which Elasticsearch without logic sharding refused at boot (Class type conflict in index: metrics-all). It is now double_value, as doubleAvg()'s. No bundled rule uses either function.

Tests and how the change was verified

The change must leave every schema as it was, so most of the verification compares master and this branch.

  1. Unit tests: the full suite, 5,113 tests, pass. Build with checkstyle and the javadoc check pass.
  2. Storage ITs: every storage-plugin IT passes, 2,684 tests: BanyanDB (26 classes), JDBC on MariaDB and PostgreSQL (35), Elasticsearch 8 / 9 / 9 sharded and OpenSearch 1 / 2 / 3 / 3 sharded (7). In the full run, BanyanDBPropertyIT's setup failed to connect to its container before any test ran; re-run alone on the same code, its three tests pass. BanyanDBIT was first changed on master to assert the full measure, stream, index rule and binding shapes (it passes there), then kept unchanged through the refactor; the only other test changes are the constructor and annotation migration, and the removed testMeasureAdditiveBootReshape.
  3. Schemas on fresh storage: the OAP was booted with every bundled OAL, MAL, LAL and TAL rule, Zipkin and OTLP, plus five OAL and five MAL verification-only rules so that every one of the 35 OAL and MAL functions has a metric, on BanyanDB, MySQL, PostgreSQL, and Elasticsearch with and without logic sharding. Everything each storage holds was dumped twice, 60 seconds apart (both stable): every table with its columns, types, defaults and indexes (column order included); every index, template and mapping field (type, index, doc_values, analyzer, _source excludes) and the index settings; every BanyanDB group, measure (entity, sharding key, tags, fields), stream, trace, property, TopN, index rule (type, analyzer, tags) and binding; and the OAP's metric catalog. Master's and this branch's dumps were compared object by object, attribute by attribute.
    • Annotation changes alone: on every storage the schemas and the catalog are identical to master's. (The raw BanyanDB and Elasticsearch responses differ only in values the server assigns itself, such as creation times, revisions and index UUIDs, and in listing order.) Master can't boot Elasticsearch without logic sharding with the maxDouble() / minDouble() rules, so that comparison ran without them; there, 49 of the 57 models share the metrics-all, records-all and management indices.
    • With the maxDouble() / minDouble() fix: only those two functions' tables, templates, indices and measures change, by the column name; Elasticsearch without logic sharding boots with both rules on.
  4. Model definitions: each build's own StorageModels was run over every hand-written model class and every OAL / MAL function class (172 definitions, 1,217 columns), and its output compared: every field of Model, ModelColumn and each storage's extension, and every class's annotations. The definitions are identical to master's but for the two removed trace EnableSort and the double_value rename; the annotations differ by exactly the moves above. OAL-generated classes are built at boot, so they are not in this export; their storage is in the dumps of 3.
  5. Upgrade from master: master booted on a fresh storage, then this branch on the same storage, with the installers' logs and the JDBC client's DDL at DEBUG. Master's boot logged every schema it created, which shows the logs fire. On every storage this branch created, updated or refused no schema, except for the two maxDouble() / minDouble() verification metrics (JDBC: double_value column and index added; Elasticsearch with logic sharding: double_value mapping appended; BanyanDB: shape mismatch at boot, so the metric stays off until reshaped). The dumps after each boot, with the values the server assigns itself kept, differ only there. (Elasticsearch without logic sharding re-puts an identical records-all template for two record models on every boot; master rebooted on its own storage does the same.)
  • Closes [Feature] Break down storage annotations by storage and BanyanDB engine #14270.

  • Update the CHANGES log.

  • GraalVM distro impact:

    • Impacted, by: a DSL engine (OAL). OALClassGeneratorV2 now emits BanyanDB.Measure.SeriesID and BanyanDB.Measure.ShardingKey. The distro's precompiler runs this generator, so the generated classes take the new names without a distro change; the generator's source is pinned in the distro's staleness checksums, so its next sync flags it for a re-check.

@wu-sheng
wu-sheng requested a balanced review from Copilot November 26, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@wu-sheng

wu-sheng commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

Storage annotations after this PR, by catalog

Every storage annotation, grouped as #14270 groups them: core (storage-neutral), then each storage. Status says whether it stays or where it moved from. Uses counts the declarations in production code on this branch. OAL-generated metrics also get @BanyanDB.Measure.SeriesID / @BanyanDB.Measure.ShardingKey from OALClassGeneratorV2. Read into is where StorageModels keeps the value.

Core (storage-neutral)

Annotation Read by Status Uses Read into
@Stream(name, scopeId, builder, processor) core stays 57 Model.name, scopeId, streamClass; the processor registers one model per downsampling
@MetricsExtension(supportDownSampling, supportUpdate, timeRelativeID) core; timeRelativeID also Elasticsearch stays 22 one Model per downsampling; Model.timeRelativeID
@SuperDataset Elasticsearch, JDBC stays 8 Model.superDataset
@Column(name, storageOnly, length, dataType, defaultValue, multiIntValues) core (MQE) and all three storages; length JDBC and Elasticsearch stays 466 ModelColumn.columnName, storageOnly, length; ValueColumnMetadata
@Column(indexOnly) Elasticsearch only removed: moved to @ElasticSearch.IndexOnly — was ModelColumn.indexOnly
@Stream(allowBootReshape) BanyanDB only removed: moved to @BanyanDB.Stream.AllowBootReshape — was Model.allowBootReshape

Elasticsearch: @ElasticSearch.*

Annotation Status Uses Read into
@ElasticSearch.IndexOnly new, from @Column(indexOnly = true) 5 ElasticSearchExtension.isIndexOnly
@ElasticSearch.MatchQuery(analyzer) stays 4 ElasticSearchExtension.analyzer
@ElasticSearch.Keyword stays 2 ElasticSearchExtension.isKeyword
@ElasticSearch.Routing stays 3 ElasticSearchExtension.isRouting, rolled up into ElasticSearchModelExtension.routing
@ElasticSearch.EnableDocValues stays 112 ElasticSearchExtension.isDocValuesEnabled
@ElasticSearch.Column(legacyName) stays 19 ElasticSearchExtension.legacyColumnName

JDBC: @SQLDatabase.* (unchanged)

Annotation Status Uses Read into
@SQLDatabase.CompositeIndex(withColumns) (repeatable; @SQLDatabase.CompositeIndices is its container) stays 3: one on ProfileThreadSnapshotRecord.taskId, two on segmentId, which Java stores as one CompositeIndices SQLDatabaseExtension.indices; StorageModels reads the single annotation and the container's values
@SQLDatabase.AdditionalEntity(additionalTables, reserveOriginalColumns) stays 9 SQLDatabaseModelExtension.additionalTables, excludeColumns
@SQLDatabase.ExtraColumn4AdditionalEntity (repeatable; @SQLDatabase.MultipleExtraColumn4AdditionalEntity is its container) stays 5, one per class, so no container SQLDatabaseModelExtension.additionalTables; read the same way

BanyanDB measure: @BanyanDB.Measure.*

Annotation Status Uses Read into
@BanyanDB.Measure.SeriesID(index) from @BanyanDB.SeriesID 27, plus every OAL metric BanyanDBExtension.seriesIDIdx
@BanyanDB.Measure.ShardingKey(index) from @BanyanDB.ShardingKey every OAL metric (generated) BanyanDBExtension.shardingKeyIdx
@BanyanDB.Measure.Field from @BanyanDB.MeasureField 73 BanyanDBExtension.isMeasureField
@BanyanDB.Measure.EnableSort from @BanyanDB.EnableSort 0 in production; BanyanDBIT uses it BanyanDBExtension.enableSort
@BanyanDB.Measure.MatchQuery(analyzer) from @BanyanDB.MatchQuery 0 in production; BanyanDBIT uses it BanyanDBExtension.analyzer

BanyanDB index-mode measure: @BanyanDB.IndexMode.*

Annotation Status Uses Read into
@BanyanDB.IndexMode (class marker) stays 16 BanyanDBModelExtension.indexMode
@BanyanDB.IndexMode.EnableSort from @BanyanDB.EnableSort 1 BanyanDBExtension.enableSort
@BanyanDB.IndexMode.MatchQuery(analyzer) from @BanyanDB.MatchQuery 1 BanyanDBExtension.analyzer

BanyanDB stream: @BanyanDB.Stream.*

Annotation Status Uses Read into
@BanyanDB.Stream.Group(StreamGroup) from @BanyanDB.Group(streamGroup = X) 26 BanyanDBModelExtension.streamGroup
@BanyanDB.Stream.TimestampColumn(column) from @BanyanDB.TimestampColumn 26 BanyanDBModelExtension.timestampColumn
@BanyanDB.Stream.AllowBootReshape from @Stream(allowBootReshape = true) 3 BanyanDBModelExtension.allowBootReshape
@BanyanDB.Stream.SeriesID(index) from @BanyanDB.SeriesID 28 BanyanDBExtension.seriesIDIdx
@BanyanDB.Stream.IndexRule(indexType) from @BanyanDB.IndexRule 4 BanyanDBExtension.indexType
@BanyanDB.Stream.EnableSort from @BanyanDB.EnableSort 6 BanyanDBExtension.enableSort
@BanyanDB.Stream.MatchQuery(analyzer) from @BanyanDB.MatchQuery 1 BanyanDBExtension.analyzer
@BanyanDB.Stream.NoIndexing from @BanyanDB.NoIndexing 2 BanyanDBExtension.shouldIndex = false

BanyanDB trace: @BanyanDB.Trace.*

Annotation Status Uses Read into
@BanyanDB.Trace.Group(TraceGroup) from @BanyanDB.Group(traceGroup = X) 3 BanyanDBModelExtension.traceGroup
@BanyanDB.Trace.StoreAsAttachmentOf(Target.class) from implements BanyanDBTrace.MergeTable (seven getMerge* / get*ColumnValue methods) and the model's own @BanyanDB.Group(traceGroup = X) 2 (SWSpanAttachedEventRecord into SegmentRecord, SpanAttachedEventRecord into ZipkinSpanRecord) BanyanDBModelExtension.attachmentTarget; the rows go into the target's trace, whose query returns them; the trace group comes from the target
@BanyanDB.Trace.TimestampColumn(column) from @BanyanDB.TimestampColumn 5 BanyanDBModelExtension.timestampColumn
@BanyanDB.Trace.TraceIdColumn(column) stays 5 BanyanDBModelExtension.traceIdColumn
@BanyanDB.Trace.SpanIdColumn(column) stays 5 BanyanDBModelExtension.spanIdColumn
@BanyanDB.Trace.IndexRule(name, columns, orderByColumn) (repeatable; @BanyanDB.Trace.IndexRule.List is its container) stays 5: one on ZipkinSpanRecord, two each on SegmentRecord and OTLPSpanRecord, stored as IndexRule.List BanyanDBModelExtension.traceIndexRules; the installer always builds each as a tree index (TYPE_TREE), the order-by column last
@BanyanDB.Trace.InSpanPayloadOnly from @BanyanDB.NoIndexing 1 BanyanDBExtension.shouldIndex = false: no trace tag; the value is only in the span payload
@BanyanDB.EnableSort on a trace field removed: BanyanDB never read it for traces was 2 (SegmentRecord.latency, OTLPSpanRecord.duration) —

Enums

Old New
BanyanDB.MatchQuery.AnalyzerType.X BanyanDB.AnalyzerType.X, shared by the three BanyanDB MatchQuery
BanyanDB.IndexRule.IndexType.X BanyanDB.Stream.IndexRule.IndexType.X

Removed

  • Column#indexOnly(), Stream#allowBootReshape(), Model#isAllowBootReshape(), ModelColumn#isIndexOnly() and the BanyanDBTrace.MergeTable interface.
  • The flat @BanyanDB.SeriesID, ShardingKey, MeasureField, EnableSort, MatchQuery, IndexRule, NoIndexing, TimestampColumn and Group.

The old BanyanDB forms this PR removes add up to the new ones: SeriesID 55 = 27 measure + 28 stream; TimestampColumn 31 = 26 + 5; Group 31 = 26 stream + 3 trace + 2 attached models; EnableSort 9 = 1 + 6 + 2 removed; MatchQuery 2 = 1 + 1; NoIndexing 3 = 2 + 1.

@wu-sheng wu-sheng added this to the 11.2.0 milestone Nov 26, 2026
@wu-sheng wu-sheng added core feature Core and important feature. Sometimes, break backwards compatibility. enhancement Enhancement on performance or codes labels Nov 26, 2026
@wu-sheng
wu-sheng force-pushed the storage-annotation-breakdown branch from b6d1e11 to 9f35ad1 Compare November 27, 2026 00:17
An attribute only one storage reads now lives under that storage's annotation, and its value in that storage's
extension of the model:
- `@Column(indexOnly)` becomes `@ElasticSearch.IndexOnly` (`ElasticSearchExtension`).
- `@Stream(allowBootReshape)` becomes `@BanyanDB.Stream.AllowBootReshape` (`BanyanDBModelExtension`). It is for
  streams only: the BanyanDB installer's boot-reshape path for measures, which no production measure used, is
  removed.

BanyanDB annotations are grouped by the engine that reads them: `@BanyanDB.Measure.*`, `@BanyanDB.IndexMode.*`,
`@BanyanDB.Stream.*` and `@BanyanDB.Trace.*`. `MeasureField` becomes `Measure.Field`, and a trace's `NoIndexing`
becomes `Trace.InSpanPayloadOnly`; the two `EnableSort` on trace models, which BanyanDB never read, are removed.
`@BanyanDB.Trace.StoreAsAttachmentOf(Target.class)` replaces the `BanyanDBTrace.MergeTable` interface: the rows go
into the target's trace and its query returns them; the target model gives the trace, its group and its columns.

The annotation changes leave every schema as it was: with every bundled OAL, MAL, LAL and TAL rule, Zipkin and
OTLP active, plus verification-only rules for every OAL and MAL function, the schemas dumped from BanyanDB, MySQL,
PostgreSQL, and Elasticsearch with and without logic sharding are identical to master's (Elasticsearch without
logic sharding ran without the `maxDouble()` / `minDouble()` rules, as master can't boot with them there). So are
the model definitions each build's `StorageModels` produces for the hand-written models and the function classes,
but for the two removed `EnableSort`.

Also fix OAL `maxDouble()` / `minDouble()`: their double column was named `value`, which Elasticsearch without
logic sharding refused at boot ("Class type conflict in index: metrics-all"). It is now `double_value`, as
`doubleAvg()`'s.
@wu-sheng
wu-sheng force-pushed the storage-annotation-breakdown branch from 9f35ad1 to 6b63121 Compare November 27, 2026 00:51
@wu-sheng
wu-sheng merged commit 410c5ed into master Nov 27, 2026
276 of 277 checks passed
@wankai123
wankai123 deleted the storage-annotation-breakdown branch November 27, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core feature Core and important feature. Sometimes, break backwards compatibility. enhancement Enhancement on performance or codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Break down storage annotations by storage and BanyanDB engine

3 participants