StatsEngine
public actor StatsEngine
An actor responsible for managing and processing statistical data within the database.
The StatsEngine interacts with the underlying storage engine to perform its operations.
-
Initializes a new instance of the
StatsEngineclass.Declaration
Swift
public init(storage: StorageEngine)Parameters
storageAn instance of
StorageEngineused to manage the underlying storage for the stats engine. -
getCollectionStats(_:Asynchronous) Retrieves statistical information about a specified collection.
Throws
An error if the operation fails.Note
This is an asynchronous function and must be awaited.Declaration
Swift
public func getCollectionStats(_ collection: String) async throws -> CollectionStatsParameters
collectionThe name of the collection for which to retrieve statistics.
Return Value
A
CollectionStatsobject containing the statistics of the specified collection. -
getGlobalStats()AsynchronousRetrieves the global statistics for the database.
This asynchronous function fetches and returns an instance of
GlobalStats, which contains aggregated statistical data about the database.Throws
An error if the operation fails during the retrieval process.Declaration
Swift
public func getGlobalStats() async throws -> GlobalStatsReturn Value
A
GlobalStatsobject containing the global statistics. -
getIndexStats()Asynchronous -
getShardStats()AsynchronousRetrieves statistics for all shards.
This asynchronous function fetches and returns an array of
ShardStatobjects, which contain statistical information about each shard in the database.Throws
An error if the operation fails during the retrieval process.Declaration
Swift
public func getShardStats() async throws -> [ShardStat]Return Value
An array of
ShardStatobjects representing the statistics of each shard. -
updateCollectionMetadata(for:Asynchronous) Updates the metadata for a specified collection.
This asynchronous function performs an update operation on the metadata associated with the given collection. It may throw an error if the update process encounters any issues.
Throws
An error if the metadata update fails.Declaration
Swift
public func updateCollectionMetadata(for collection: String) async throwsParameters
collectionThe name of the collection whose metadata needs to be updated.
Return Value
This function does not return a value.
View on GitHub