Zum Hauptinhalt springen

IStreamDataRepository

Namespace: Meshmakers.Octo.Runtime.Contracts.StreamData

Repository for stream data operations against a tenant-scoped, CrateDB-backed time-series store organised by CkArchive instances. Accessed via ITenantContext.GetStreamDataRepository(). Every operation is scoped to a single archive, addressed by its runtime id.

public interface IStreamDataRepository

Properties​

SupportsStagingCopy​

True when this repository can copy an archive's tables to and from a staging location with the data store's own bulk statements (CrateDB COPY TO / COPY FROM). When false the caller takes the row path (IStreamDataRepository.ExportRowsAsync(OctoObjectId, TimeWindow, CancellationToken) / IStreamDataRepository.ImportRowsAsync(OctoObjectId, IAsyncEnumerable<IReadOnlyDictionary<String, Object>>, ArchiveImportMode, CancellationToken), dump format 1). The other members of this section throw ArchiveCopyNotSupportedException.

public bool SupportsStagingCopy { get; }

Property Value​

Boolean

Methods​

EnsureDatabaseCreatedAsync()​

Ensures the tenant's stream data namespace (e.g. CrateDB schema) exists. Idempotent. Called when a tenant opts into stream data; per-archive tables are created later via IStreamDataRepository.EnsureArchiveCreatedAsync(ArchiveSnapshot).

Task EnsureDatabaseCreatedAsync()

Returns​

Task

DeleteDatabaseAsync()​

Drops the tenant's entire stream data namespace including every archive table. Idempotent.

Task DeleteDatabaseAsync()

Returns​

Task

EnsureArchiveCreatedAsync(ArchiveSnapshot)​

Creates the storage table for the archive described by snapshot according to its current CkArchive definition. The snapshot carries the target CK type and user-picked columns the data store needs to generate DDL — passing it directly avoids a round-trip through IArchiveRuntimeStore from inside the repository. Idempotent (uses CREATE TABLE IF NOT EXISTS) so retries after a transient Mongo update failure converge cleanly.

Task EnsureArchiveCreatedAsync(ArchiveSnapshot snapshot)

Parameters​

snapshot ArchiveSnapshot

Returns​

Task

DeleteArchiveAsync(OctoObjectId)​

Drops the storage table for the archive identified by archiveRtId. Idempotent. Called from the lifecycle service when an archive is deleted.

Task DeleteArchiveAsync(OctoObjectId archiveRtId)

Parameters​

archiveRtId OctoObjectId

Returns​

Task

ValidateComputedColumnsAsync(OctoObjectId, IReadOnlyList<CkArchiveColumnSpec>, CancellationToken)​

Validates a prospective computed-column set — syntax, reference resolution, acyclic dependencies, Path/Formula exclusivity, nullable, ResultType — without touching storage. The lifecycle service calls this before persisting an add (existing columns + the new one) or a remove (existing columns − the removed one, so a now-dangling reference is rejected). Throws a StreamDataException (stable GraphQL error code) on the first issue.

Task ValidateComputedColumnsAsync(OctoObjectId archiveRtId, IReadOnlyList<CkArchiveColumnSpec> prospectiveColumns, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

prospectiveColumns IReadOnlyList<CkArchiveColumnSpec>

cancellationToken CancellationToken

Returns​

Task

NormalizeComputedFormulaAsync(OctoObjectId, IReadOnlyList<CkArchiveColumnSpec>, String, CancellationToken)​

Rewrites a computed-column formula from the archive's logical column vocabulary — the CK attribute paths the Studio lists and the query surface uses, e.g. Amount.Value — into the physical form the evaluation path binds, e.g. amountvalue.

The lifecycle service calls this before validating and persisting, so the stored formula is always physical and every downstream consumer keeps seeing exactly what it saw before. A name that is already physical, or that matches no column at all, is left as written — the latter so validation can reject it by the spelling the caller actually used.

It lives on the storage contract rather than in the lifecycle service because the logical→physical rule belongs to the storage layer, the same reason IStreamDataRepository.ValidateComputedColumnsAsync(OctoObjectId, IReadOnlyList<CkArchiveColumnSpec>, CancellationToken) does. No I/O.

Task<string> NormalizeComputedFormulaAsync(OctoObjectId archiveRtId, IReadOnlyList<CkArchiveColumnSpec> columns, string formula, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

columns IReadOnlyList<CkArchiveColumnSpec>

formula String

cancellationToken CancellationToken

Returns​

Task<String>

AddComputedColumnStorageAsync(ArchiveSnapshot, String, CancellationToken)​

Adds the physical CrateDB column for the computed column named columnName via ALTER TABLE … ADD COLUMN. Idempotent — tolerant of the column already existing (e.g. a re-add reusing an orphaned column). The column on snapshot supplies the declared result type the physical column is typed from.

Task AddComputedColumnStorageAsync(ArchiveSnapshot snapshot, string columnName, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnName String

cancellationToken CancellationToken

Returns​

Task

AddIngestedColumnStorageAsync(ArchiveSnapshot, String, CancellationToken)​

Adds the physical column for the ingested column at path to the table of an activated archive: ALTER TABLE … ADD COLUMN, always nullable, because every existing row has no value for it. Existing rows keep their data. Idempotent (an existing column is reused). The column on snapshot is resolved against the CK model like at activation; an unresolvable path throws ArchivePathInvalidException before any DDL runs. The default re-runs the provisioning, which adds the declared columns a table lacks; a repository that can add one column directly overrides it.

Task AddIngestedColumnStorageAsync(ArchiveSnapshot snapshot, string path, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

path String

cancellationToken CancellationToken

Returns​

Task

DropIngestedColumnStorageAsync(ArchiveSnapshot, IReadOnlyCollection<String>, CancellationToken)​

Drops the physical columns of the ingested columns at columnPaths from the archive's table (IArchiveLifecycleService.RedactHiddenColumnsAsync(OctoObjectId)): ALTER TABLE … DROP COLUMN. Destructive: the values stored in these columns are lost; every other column and row is kept. Idempotent (a column that does not exist is skipped, so is a table that does not exist). The default implementation throws NotSupportedException.

Task DropIngestedColumnStorageAsync(ArchiveSnapshot snapshot, IReadOnlyCollection<string> columnPaths, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnPaths IReadOnlyCollection<String>

cancellationToken CancellationToken

Returns​

Task

AddPendingComputedColumnStorageAsync(ArchiveSnapshot, String, CancellationToken)​

Adds the physical CrateDB column for the pending version of a computed column ({base}__v{ComputedVersion+1}) via ALTER TABLE … ADD COLUMN (formula change). Idempotent. Must run before the pending formula is marked so ingest's dual-write never targets a missing column.

Task AddPendingComputedColumnStorageAsync(ArchiveSnapshot snapshot, string columnName, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnName String

cancellationToken CancellationToken

Returns​

Task

BackfillComputedColumnAsync(ArchiveSnapshot, String, CancellationToken)​

Backfills the computed column named columnName across the archive's existing rows: pages through the rows, evaluates the column's formula per row, and writes the result into its physical cell. The physical column must already exist (see IStreamDataRepository.AddComputedColumnStorageAsync(ArchiveSnapshot, String, CancellationToken)). Readers keep seeing the previous state until the lifecycle flips the column to Active, because the column is hidden while non-active. Throws on a storage failure so the lifecycle can mark the column Failed.

Task BackfillComputedColumnAsync(ArchiveSnapshot snapshot, string columnName, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnName String

cancellationToken CancellationToken

Returns​

Task

BackfillComputedColumnAsync(ArchiveSnapshot, String, IProgress<Int64>, CancellationToken)​

Same as IStreamDataRepository.BackfillComputedColumnAsync(ArchiveSnapshot, String, CancellationToken), and reports the running number of rows written to progress after every committed chunk. The background backfill job uses it as its heartbeat and to show progress on the recompute job. The default implementation reports nothing; a repository that can count its chunks overrides it.

Task BackfillComputedColumnAsync(ArchiveSnapshot snapshot, string columnName, IProgress<long> progress, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnName String

progress IProgress<Int64>

cancellationToken CancellationToken

Returns​

Task

BackfillComputedColumnAsync(ArchiveSnapshot, String, Nullable<DateTime>, IProgress<ComputedColumnBackfillProgress>, CancellationToken)​

Resumable form of the backfill: rows whose time key is before resumeFrom are skipped — an earlier run of the same job already wrote them — and progress receives the running row count and the checkpoint after every committed chunk, which the job stores so a run cut short by a restart resumes there instead of starting over. Rows that arrive behind the checkpoint during the backfill are written by ingest, which evaluates every computed column. The default implementation ignores resumeFrom (a full backfill is always correct, only slower) and reports rows without a checkpoint.

Task BackfillComputedColumnAsync(ArchiveSnapshot snapshot, string columnName, Nullable<DateTime> resumeFrom, IProgress<ComputedColumnBackfillProgress> progress, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnName String

resumeFrom Nullable<DateTime>

progress IProgress<ComputedColumnBackfillProgress>

cancellationToken CancellationToken

Returns​

Task

RepairComputedColumnAsync(ArchiveSnapshot, String, DateTime, DateTime, IProgress<ComputedColumnBackfillProgress>, CancellationToken)​

Repairs an Active computed column: within [from, to) of the archive's time key it re-evaluates the formula for every row whose cell is NULL although at least one operand the formula references is not NULL, and writes the result into the active physical column. Rows whose operands are all NULL, and formulas that legitimately yield NULL, stay NULL. The column stays readable throughout. Reports the rows re-evaluated and the checkpoint (end of the last completed time slice) like the backfill, so a run cut short resumes at the checkpoint. Throws when an evaluation is aborted by an exception (FormulaEvaluationException) — nothing is stored as NULL for it. The default implementation is not supported.

Task RepairComputedColumnAsync(ArchiveSnapshot snapshot, string columnName, DateTime from, DateTime to, IProgress<ComputedColumnBackfillProgress> progress, CancellationToken cancellationToken)

Parameters​

snapshot ArchiveSnapshot

columnName String

from DateTime

to DateTime

progress IProgress<ComputedColumnBackfillProgress>

cancellationToken CancellationToken

Returns​

Task

InsertAsync(OctoObjectId, StreamDataPoint)​

Inserts a single data point into the archive. Throws ArchiveNotActivatedException if the archive's status is not Activated; throws RequiredAttributeMissingException on a missing required path.

Task<StreamDataWriteResult> InsertAsync(OctoObjectId archiveRtId, StreamDataPoint datapoint)

Parameters​

archiveRtId OctoObjectId

datapoint StreamDataPoint

Returns​

Task<StreamDataWriteResult>
How many rows were stored and which were not, with the reason. Throws ManualStreamDataNotAppliedException when a manual row could not be stored.

InsertAsync(OctoObjectId, IEnumerable<StreamDataPoint>)​

Inserts multiple data points into the archive. Pre-validates the entire batch before any SQL is sent; on first violation no row is written and the offending point's index is surfaced via the thrown exception.

Task<StreamDataWriteResult> InsertAsync(OctoObjectId archiveRtId, IEnumerable<StreamDataPoint> datapoints)

Parameters​

archiveRtId OctoObjectId

datapoints IEnumerable<StreamDataPoint>

Returns​

Task<StreamDataWriteResult>
How many rows were stored and which were not, with the reason. Throws ManualStreamDataNotAppliedException when a manual row could not be stored.

InsertTimeRangeAsync(OctoObjectId, IEnumerable<TimeRangeStreamDataPoint>, CancellationToken)​

Inserts externally pre-aggregated time-range data points into a TimeRangeArchive. Each point carries an explicit [from, to) window; the natural key (window_start, window_end, rtid, ckTypeId) handles re-deliveries via ON CONFLICT DO UPDATE, setting the row's was_updated flag to true on every upsert. Concept §3 / §5. Throws ArchiveNotActivatedException if the archive is not in Activated state, and ArgumentException if any point has To <= From.

Task<StreamDataWriteResult> InsertTimeRangeAsync(OctoObjectId archiveRtId, IEnumerable<TimeRangeStreamDataPoint> datapoints, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

datapoints IEnumerable<TimeRangeStreamDataPoint>

cancellationToken CancellationToken

Returns​

Task<StreamDataWriteResult>
How many rows were stored and which were not, with the reason. Throws ManualStreamDataNotAppliedException when a manual row could not be stored.

ExecuteQueryAsync(OctoObjectId, StreamDataQueryOptions)​

Executes a simple stream data query against the archive.

Task<StreamDataQueryResult> ExecuteQueryAsync(OctoObjectId archiveRtId, StreamDataQueryOptions options)

Parameters​

archiveRtId OctoObjectId

options StreamDataQueryOptions

Returns​

Task<StreamDataQueryResult>

ExecuteAggregationQueryAsync(OctoObjectId, StreamDataAggregationQueryOptions)​

Executes an aggregation query (without grouping) against the archive.

Task<StreamDataQueryResult> ExecuteAggregationQueryAsync(OctoObjectId archiveRtId, StreamDataAggregationQueryOptions options)

Parameters​

archiveRtId OctoObjectId

options StreamDataAggregationQueryOptions

Returns​

Task<StreamDataQueryResult>

ExecuteGroupedAggregationQueryAsync(OctoObjectId, StreamDataGroupedAggregationQueryOptions)​

Executes a grouped aggregation query against the archive.

Task<StreamDataQueryResult> ExecuteGroupedAggregationQueryAsync(OctoObjectId archiveRtId, StreamDataGroupedAggregationQueryOptions options)

Parameters​

archiveRtId OctoObjectId

options StreamDataGroupedAggregationQueryOptions

Returns​

Task<StreamDataQueryResult>

ExecuteDownsamplingQueryAsync(OctoObjectId, StreamDataDownsamplingQueryOptions)​

Executes a downsampling query with time bins against the archive.

Task<StreamDataQueryResult> ExecuteDownsamplingQueryAsync(OctoObjectId archiveRtId, StreamDataDownsamplingQueryOptions options)

Parameters​

archiveRtId OctoObjectId

options StreamDataDownsamplingQueryOptions

Returns​

Task<StreamDataQueryResult>

ExportRowsAsync(OctoObjectId, TimeWindow, CancellationToken)​

Streams the rows of the archive in a stable key order (keyset pagination on the natural key) so the caller can serialise NDJSON without buffering the table. When window is non-null only rows whose timestamp (raw) or window_start (windowed: rollup / time-range) fall in [FromUtc, ToUtc) are emitted — the predicate rides on the already time-ordered keyset scan, so a windowed export is no more expensive than a full one (and cheaper). Each row is yielded as a dictionary of physical CrateDB column name → value (the standard columns plus the user columns). An archive without a backing table (e.g. Created) yields no rows rather than throwing. Archive data export/import concept §4.1.

IAsyncEnumerable<IReadOnlyDictionary<string, object>> ExportRowsAsync(OctoObjectId archiveRtId, TimeWindow window, CancellationToken ct)

Parameters​

archiveRtId OctoObjectId

window TimeWindow

ct CancellationToken

Returns​

IAsyncEnumerable<IReadOnlyDictionary<String, Object>>

ImportRowsAsync(OctoObjectId, IAsyncEnumerable<IReadOnlyDictionary<String, Object>>, ArchiveImportMode, CancellationToken)​

Bulk-inserts pre-parsed archive rows (the inverse of IStreamDataRepository.ExportRowsAsync(OctoObjectId, TimeWindow, CancellationToken)). Rows are streamed in batches into the existing batched insert path (the single-timestamp insert for raw archives, the (window_start, window_end) ON CONFLICT path for windowed archives). mode selects insert-only versus upsert semantics on the natural key. Each row's rtid is validated as 24-char hex; a violation surfaces a per-field error rather than a generic message. Archive data export/import concept §4.1 / §7 / §10.

Task ImportRowsAsync(OctoObjectId archiveRtId, IAsyncEnumerable<IReadOnlyDictionary<string, object>> rows, ArchiveImportMode mode, CancellationToken ct)

Parameters​

archiveRtId OctoObjectId

rows IAsyncEnumerable<IReadOnlyDictionary<String, Object>>

mode ArchiveImportMode

ct CancellationToken

Returns​

Task

PlanArchiveCopyAsync(OctoObjectId, ArchiveCopyOptions, CancellationToken)​

Cuts the archive into the slices a dump copies: time slices of about ArchiveCopyOptions.TargetSliceRows rows, each counted, in ascending time order, and for a rollup its generation map as the last slice, together with the description of every table. An archive without a backing table yields a plan without slices. Reads only.

Task<ArchiveCopyPlan> PlanArchiveCopyAsync(OctoObjectId archiveRtId, ArchiveCopyOptions options, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

options ArchiveCopyOptions

cancellationToken CancellationToken

Returns​

Task<ArchiveCopyPlan>

Exceptions​

ArchiveCopyNotSupportedException
The repository has no staging copy.

CopyToStagingAsync(OctoObjectId, ArchiveCopyPlan, ArchiveCopyStagingLocation, ArchiveCopyOptions, CancellationToken)​

Dumps the slices of plan to location, one slice at a time in plan order, into the folder ArchiveCopySlice.GetStagingPath(OctoObjectId) of each slice. Yields the result of each slice as soon as it is done. The copy ends after the first failed slice (its result says ArchiveCopySliceStatus.Failed with a redacted message; earlier slices stay valid) and stops between two slices when cancellationToken is cancelled (OperationCanceledException). Refuses to start with ArchiveCopyRefusedException while the data store would record the credential in its job log.

IAsyncEnumerable<ArchiveCopySliceResult> CopyToStagingAsync(OctoObjectId archiveRtId, ArchiveCopyPlan plan, ArchiveCopyStagingLocation location, ArchiveCopyOptions options, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

plan ArchiveCopyPlan

location ArchiveCopyStagingLocation

options ArchiveCopyOptions

cancellationToken CancellationToken

Returns​

IAsyncEnumerable<ArchiveCopySliceResult>

Exceptions​

ArchiveCopyNotSupportedException
The repository has no staging copy.

Remarks:

The tenant stays online, the dump is not a snapshot: a slice whose copied rows differ from the counted ones is reported with a warning in ArchiveCopySliceResult.Message, not as a failure. plan must have been made for archiveRtId. No text that leaves this method — result message, exception, log, trace — contains the credential of location.

CopyFromStagingAsync(OctoObjectId, ArchiveCopyPlan, ArchiveCopyStagingLocation, ArchiveCopyOptions, CancellationToken)​

Loads the slices of plan from location into the table of archiveRtId, which the caller created fresh with the platform's DDL. The files are read from ArchiveCopySlice.GetStagingPath(OctoObjectId) of the plan's archive id, so a restore into another archive id reads the source's files. Yields the result of each slice as soon as it is done; a slice counts as loaded when the loaded rows equal ArchiveCopySlice.RowCount and no row was rejected. The copy ends after the first failed slice and stops between two slices on cancellation.

IAsyncEnumerable<ArchiveCopySliceResult> CopyFromStagingAsync(OctoObjectId archiveRtId, ArchiveCopyPlan plan, ArchiveCopyStagingLocation location, ArchiveCopyOptions options, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

plan ArchiveCopyPlan

location ArchiveCopyStagingLocation

options ArchiveCopyOptions

cancellationToken CancellationToken

Returns​

IAsyncEnumerable<ArchiveCopySliceResult>

Exceptions​

ArchiveCopyNotSupportedException
The repository has no staging copy.

Remarks:

Before the first slice it refuses with ArchiveCopyRefusedException when a dumped column is missing in the target table (message names the column) or a node lacks the free disk space the load needs (message names expected and available size), and when the data store would record the credential in its job log. The bulk table settings it sets for the load (no replicas, no refresh) are restored when the enumeration ends — also after a failed slice, an exception or cancellation. After the last slice it merges the segments when ArchiveCopyOptions.OptimizeAfterLoad is set. A different storage version on source and target is logged, not refused. A NULL in a column that has a DEFAULT is not preserved (the default applies); see the concept §7.

DescribeArchiveTableAsync(OctoObjectId, ArchiveCopyTable, CancellationToken)​

Describes one physical table of the archive: every column with its backend data type, as the dump manifest records it. A table that does not exist (archive not activated, no generation map) yields an empty column list; every other storage failure propagates.

Task<ArchiveTableDescription> DescribeArchiveTableAsync(OctoObjectId archiveRtId, ArchiveCopyTable table, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

table ArchiveCopyTable

cancellationToken CancellationToken

Returns​

Task<ArchiveTableDescription>

Exceptions​

ArchiveCopyNotSupportedException
The repository has no staging copy.

GetStorageVersionAsync(CancellationToken)​

The version of the data store (CrateDB: sys.nodes version) the dump manifest records and a restore logs next to the target's.

Task<string> GetStorageVersionAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task<String>

Exceptions​

ArchiveCopyNotSupportedException
The repository has no staging copy.

CheckStagingCopyReadinessAsync(CancellationToken)​

Asks, without changing anything and without touching an archive, whether the native copy can run: the repository supports it and the job log filter is in place (the check a load otherwise makes only after the table was recreated). A restore calls it before it touches the archives of the tenant. It does not test the staging location (that needs the credential and a real file); a location that fails shows at the first slice. Never throws for a missing prerequisite - the answer says what is missing.

Task<StagingCopyReadiness> CheckStagingCopyReadinessAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task<StagingCopyReadiness>

Remarks:

The question is about the storage cluster, not the tenant. A caller that must ask before it can build a tenant context (a restore, which replaces the tenant's database first) uses the cluster-level counterpart on the factory, IStreamDataRepositoryFactory.CheckStagingCopyReadinessAsync (engine-mongodb contracts); both give the same answer .

DumpArchiveToStagingAsync(OctoObjectId, ArchiveCopyStagingLocation, ArchiveCopyOptions, CancellationToken)​

Dumps one archive completely: plans it, copies its data slices and — for a rollup — its generation map, and applies the repeat rule. For a rollup the map is read first, copied, then the data slices are copied, then the map is read again; when it moved in between (a recompute flipped a pointer) the whole rollup is copied again, up to ArchiveCopyOptions.MaxMapAttempts times. The result states the attempts and the times of the map read and of the last data slice. An archive without a generation map is copied once and its map is never read.

Task<ArchiveCopyDumpResult> DumpArchiveToStagingAsync(OctoObjectId archiveRtId, ArchiveCopyStagingLocation location, ArchiveCopyOptions options, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

location ArchiveCopyStagingLocation

options ArchiveCopyOptions

cancellationToken CancellationToken

Returns​

Task<ArchiveCopyDumpResult>

Exceptions​

ArchiveCopyRefusedException
ArchiveCopyRefusalReason.GenerationMapKeptMoving: the map moved in every attempt (the message names the rollup), or any reason of IStreamDataRepository.CopyToStagingAsync(OctoObjectId, ArchiveCopyPlan, ArchiveCopyStagingLocation, ArchiveCopyOptions, CancellationToken).

ArchiveCopyNotSupportedException
The repository has no staging copy.

LoadArchiveFromStagingAsync(OctoObjectId, ArchiveCopyPlan, ArchiveCopyStagingLocation, ArchiveCopyOptions, CancellationToken)​

Loads one archive from plan (data slices first, the generation map last, the previous version of the rollup is not involved) and states whether the tables hold exactly the counted rows (ArchiveCopyLoadResult.RowCountVerified). Same checks, bulk settings and refusals as IStreamDataRepository.CopyFromStagingAsync(OctoObjectId, ArchiveCopyPlan, ArchiveCopyStagingLocation, ArchiveCopyOptions, CancellationToken).

Task<ArchiveCopyLoadResult> LoadArchiveFromStagingAsync(OctoObjectId archiveRtId, ArchiveCopyPlan plan, ArchiveCopyStagingLocation location, ArchiveCopyOptions options, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

plan ArchiveCopyPlan

location ArchiveCopyStagingLocation

options ArchiveCopyOptions

cancellationToken CancellationToken

Returns​

Task<ArchiveCopyLoadResult>

Exceptions​

ArchiveCopyNotSupportedException
The repository has no staging copy.

SweepSupersededGenerationsAsync(CancellationToken)​

Runs the deferred sweeps of recomputed rollup ranges that are due. A recompute flips a range to a new generation and, with a sweep grace period above zero, records the sweep of the superseded generation durably instead of running it at once (a native dump that read the generation map before the flip still finds the rows its copy names); this call executes every record whose flip time plus grace period has passed, so it also works after a restart. Returns the number of recorded sweeps that were executed or dropped as obsolete. A repository that defers nothing returns 0.

Task<int> SweepSupersededGenerationsAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task<Int32>

Remarks:

Called by the host's recompute tick for every tenant, not while the tenant is marked restore reconcile pending.

ValidateRollupsAsync(IReadOnlyCollection<OctoObjectId>, CancellationToken)​

Checks rollups for the inconsistencies a restore (or a dump taken during a recompute) can leave: a pointer without rows, rows above the pointer, a watermark ahead of the rows, a missing generation map (RollupConsistencyCheck). Read only: counts and MAX/MIN statements, no row is exported, nothing is changed. Does not throw for an inconsistent rollup; the report lists it. A rollup that cannot be checked (no table, a source missing) is listed with RollupConsistencyEntry.NotChecked and makes RollupConsistencyReport.IsOk false: "nothing found" never means "not looked at". A rollup that was never activated is listed too, as information only (it has no data).

Task<RollupConsistencyReport> ValidateRollupsAsync(IReadOnlyCollection<OctoObjectId> rollupRtIds, CancellationToken cancellationToken)

Parameters​

rollupRtIds IReadOnlyCollection<OctoObjectId>
The rollups to check; null checks every rollup archive of the tenant.

cancellationToken CancellationToken
Cancels the check.

Returns​

Task<RollupConsistencyReport>

Exceptions​

ArchiveCopyNotSupportedException
The repository does not support the check.

RepairRollupsAsync(IReadOnlyCollection<OctoObjectId>, Boolean, CancellationToken)​

Validates, repairs what the validator found, and validates again (RollupRepairReport). Idempotent: a second run on a repaired tenant finds nothing to do. With dryRun it lists the planned steps and changes nothing. A failing step stops the repair of its rollup and is named in the report; the restore-reconcile marker is cleared only when the repair ended with a tenant that validates ok (IStreamDataRepository.IsRestoreReconcilePendingAsync(CancellationToken)).

Task<RollupRepairReport> RepairRollupsAsync(IReadOnlyCollection<OctoObjectId> rollupRtIds, bool dryRun, CancellationToken cancellationToken)

Parameters​

rollupRtIds IReadOnlyCollection<OctoObjectId>

dryRun Boolean

cancellationToken CancellationToken

Returns​

Task<RollupRepairReport>

Exceptions​

ArchiveCopyNotSupportedException
The repository does not support the repair.

EnqueueRollupRepairAsync(IReadOnlyCollection<OctoObjectId>, CancellationToken)​

Queues a repair (IStreamDataRepository.RepairRollupsAsync(IReadOnlyCollection<OctoObjectId>, Boolean, CancellationToken)) instead of running it under the caller: the plan is recorded durably (the request returns at once with the planned steps) and the host's recompute tick runs it, also after a restart (IStreamDataRepository.RunPendingRollupRepairsAsync(CancellationToken)). The repair clears the restore reconcile marker when its final validation is ok; if a step fails the request is RollupRepairRequestState.Failed, its report names the step, and the marker stays. For the REST, CLI and MCP surfaces, where an inline repair of a large tenant would outlive the request.

Task<RollupRepairRequest> EnqueueRollupRepairAsync(IReadOnlyCollection<OctoObjectId> rollupRtIds, CancellationToken cancellationToken)

Parameters​

rollupRtIds IReadOnlyCollection<OctoObjectId>

cancellationToken CancellationToken

Returns​

Task<RollupRepairRequest>

Exceptions​

ArchiveCopyNotSupportedException
The repository does not support the repair.

GetRollupRepairRequestAsync(String, CancellationToken)​

The state and, once it ended, the report of a queued repair; null for an unknown id.

Task<RollupRepairRequest> GetRollupRepairRequestAsync(string requestId, CancellationToken cancellationToken)

Parameters​

requestId String

cancellationToken CancellationToken

Returns​

Task<RollupRepairRequest>

Exceptions​

ArchiveCopyNotSupportedException
The repository does not support the repair.

RunPendingRollupRepairsAsync(CancellationToken)​

Runs the queued repairs of the tenant that are pending (or were left running by a process that died). Returns how many were run. Called by the host's recompute tick, which does not hold a marked tenant back from this call.

Task<int> RunPendingRollupRepairsAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task<Int32>

IsRestoreReconcilePendingAsync(CancellationToken)​

True while the tenant is marked restore reconcile pending: a restore with archive data finished and the rollups were not yet validated ok or repaired. While it is set, reclaim, forward aggregation and recompute do not run for the tenant. Absent marker = not pending, so tenants and backups from before this feature work unchanged.

Task<bool> IsRestoreReconcilePendingAsync(CancellationToken cancellationToken)

Parameters​

cancellationToken CancellationToken

Returns​

Task<Boolean>

Exceptions​

ArchiveCopyNotSupportedException
The repository does not support the marker.

SetRestoreReconcilePendingAsync(Boolean, CancellationToken)​

Sets or clears the restore reconcile pending marker (stored durably next to the rollup data).

Task SetRestoreReconcilePendingAsync(bool pending, CancellationToken cancellationToken)

Parameters​

pending Boolean

cancellationToken CancellationToken

Returns​

Task

Exceptions​

ArchiveCopyNotSupportedException
The repository does not support the marker.

AggregateBucketAsync(ArchiveSnapshot, RollupArchiveSnapshot, DateTime, DateTime, CancellationToken)​

Aggregates one bucket from sourceArchive into rollup: reads source rows with timestamp ∈ [bucketStart, bucketEnd), groups by rtId, applies the CkRollupAggregationSpec aggregations, and upserts one row per entity into the rollup archive's table with timestamp = bucketEnd. Rollup-archives concept §5.

Task<int> AggregateBucketAsync(ArchiveSnapshot sourceArchive, RollupArchiveSnapshot rollup, DateTime bucketStart, DateTime bucketEnd, CancellationToken cancellationToken)

Parameters​

sourceArchive ArchiveSnapshot

rollup RollupArchiveSnapshot

bucketStart DateTime

bucketEnd DateTime

cancellationToken CancellationToken

Returns​

Task<Int32>

Remarks:

Idempotent on the natural key (timestamp, rtId): when the same bucket is re-aggregated (e.g. after a watermark rewind, or a crash before IRollupArchiveRuntimeStore.AdvanceWatermarkAsync(OctoObjectId, DateTime, Boolean) committed), the implementation must collapse duplicates via the data store's upsert primitive (CrateDB: ON CONFLICT (timestamp, rtId) DO UPDATE) so the orchestrator can always retry safely. Returns the number of upserted target rows.

Single-source per call, unchanged: a multi-source rollup aggregates one bucket from exactly one source, and the orchestrator picks that source per bucket via RollupArchiveSnapshot.SourceForBucket(DateTime, DateTime) before calling in. A bucket no source span covers is never passed here at all — the orchestrator writes no row and advances the watermark instead.

EnsureRollupPlatformColumnsAsync(OctoObjectId, CancellationToken)​

Makes sure the table of the rollup carries the platform columns (ArchiveRowOriginFields.RollupFields). A rollup table provisioned before they existed has to offer them to readers from the platform update on, also when no bucket is due for a long time. Called by the orchestrator tick; the check is made once per table and process.

Task EnsureRollupPlatformColumnsAsync(OctoObjectId rollupRtId, CancellationToken cancellationToken)

Parameters​

rollupRtId OctoObjectId
The rollup archive.

cancellationToken CancellationToken
Cancellation token.

Returns​

Task

ClearRecomputeGenerationsAsync(OctoObjectId, DateTime, CancellationToken)​

Clears the per-window recompute generation pointers for a rollup archive at and after fromBucketEnd, so a subsequent forward re-aggregation (which writes generation 0) becomes visible again. Called when a rollup watermark is rewound over a range that was previously recomputed (Phase 6): the rewind re-aggregates forward at generation 0, but the active-generation pointer would otherwise keep readers on the stale recomputed generation. Implementations remove the generation-map entries whose range reaches past fromBucketEnd and the superseded (generation > 0) rows in that range. Idempotent — a no-op when there is no recompute state (no genmap / non-rollup).

Task ClearRecomputeGenerationsAsync(OctoObjectId rollupRtId, DateTime fromBucketEnd, CancellationToken cancellationToken)

Parameters​

rollupRtId OctoObjectId

fromBucketEnd DateTime

cancellationToken CancellationToken

Returns​

Task

GetArchiveMinTimestampAsync(OctoObjectId, CancellationToken)​

Resolves the earliest stored timestamp in the archive's backing table — MIN(window_start) for windowed (rollup / time-range) archives, MIN(timestamp) for raw archives. Used by rollup backfill to recompute a rollup over its source archive's entire history without the operator supplying a start timestamp. Returns null when the archive has no backing table yet (e.g. Created) or the table is empty.

Task<Nullable<DateTime>> GetArchiveMinTimestampAsync(OctoObjectId archiveRtId, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

cancellationToken CancellationToken

Returns​

Task<Nullable<DateTime>>

GetArchiveCoverageAsync(OctoObjectId, CancellationToken)​

Measures the archive's stored time range: MIN(window_start) / MAX(window_end) for windowed (rollup / time-range) archives and MIN(timestamp) / MAX(timestamp) for raw archives. Returns null when the archive holds no data — no backing table yet (e.g. Created), an unknown relation, or an empty table — never a sentinel range. Every other storage failure propagates.

Task<ArchiveCoverage> GetArchiveCoverageAsync(OctoObjectId archiveRtId, CancellationToken cancellationToken)

Parameters​

archiveRtId OctoObjectId

cancellationToken CancellationToken

Returns​

Task<ArchiveCoverage>

Remarks:

Coverage is archive-wide (not per entity rtId) and a single from/to pair; gaps inside the range are not represented. Callers normally go through IArchiveCoverageProvider so the answer is memoised per tenant instead of probed on every request.

GetArchiveStatsAsync(IReadOnlyList<OctoObjectId>, CancellationToken)​

Returns per-archive storage stats (row count, on-disk size, health) for each archiveRtIds entry. Bulk call so the studio's archives list can render stats columns without an N+1 round-trip per row. Archives whose backing table doesn't exist yet (not activated, or post-delete) appear in the result with ArchiveStorageStats.TableExists false and zero counters — the caller is not expected to filter the input list beforehand.

Task<IReadOnlyDictionary<OctoObjectId, ArchiveStorageStats>> GetArchiveStatsAsync(IReadOnlyList<OctoObjectId> archiveRtIds, CancellationToken cancellationToken)

Parameters​

archiveRtIds IReadOnlyList<OctoObjectId>

cancellationToken CancellationToken

Returns​

Task<IReadOnlyDictionary<OctoObjectId, ArchiveStorageStats>>

Remarks:

Implementations may issue a single underlying query against their introspection surface (e.g. CrateDB sys.shards + sys.health) and return one entry per requested rtId. Order of returned entries is implementation-defined; callers must look up by rtId.