Skip to content

feat(dpp): add documents_countable to DocumentTypeV2 for O(1) total document counts#3457

Merged
QuantumExplorer merged 15 commits into
v3.1-devfrom
feat/documents-countable
May 8, 2026
Merged

feat(dpp): add documents_countable to DocumentTypeV2 for O(1) total document counts#3457
QuantumExplorer merged 15 commits into
v3.1-devfrom
feat/documents-countable

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Apr 8, 2026

Copy link
Copy Markdown
Member

Summary

Adds two new fields to DocumentTypeV2 for O(1) document counting:

  • documents_countable: bool — primary key tree uses CountTree, enabling O(1) total document count queries
  • blast_syncable: bool — primary key tree uses ProvableCountTree for BLAST sync support. Implies documents_countable = true.

Changes

  • DocumentTypeV2: New struct with both fields
  • DocumentType enum: Added V2 variant with full match arm coverage
  • Accessor traits: DocumentTypeV2Getters / DocumentTypeV2Setters
  • Schema parsing: try_from_schema v2 parses both "documentsCountable" and "blastSyncable" (protocol version 12+ required)
  • Drive: CountTree for countable, ProvableCountTree for blast_syncable
  • Platform version: CONTRACT_VERSIONS_V4 with try_from_schema: 2, used in v12

Schema example

{
  "person": {
    "type": "object",
    "documentsCountable": true,
    "properties": { ... }
  }
}

Or with BLAST sync:

{
  "person": {
    "type": "object",
    "blastSyncable": true,
    "properties": { ... }
  }
}

NOT in this PR

Count query extensions — follow-up to PR #3435.

Test plan

  • cargo check -p dpp -p drive passes
  • cargo fmt --all clean
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for marking document types as countable, enabling O(1) total document count queries.
    • Added support for range countable documents, enabling efficient range counting operations.
    • Implemented protocol version 12 support with optimized primary key storage tree types based on document configuration.
  • Chores

    • Updated schema to include new countability configuration properties.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants