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
StatsEngine
class.Declaration
Swift
public init(storage: StorageEngine)
Parameters
storage
An instance of
StorageEngine
used 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 -> CollectionStats
Parameters
collection
The name of the collection for which to retrieve statistics.
Return Value
A
CollectionStats
object 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 -> GlobalStats
Return Value
A
GlobalStats
object containing the global statistics. -
getIndexStats()
Asynchronous -
getShardStats()
AsynchronousRetrieves statistics for all shards.
This asynchronous function fetches and returns an array of
ShardStat
objects, 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
ShardStat
objects 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 throws
Parameters
collection
The name of the collection whose metadata needs to be updated.
Return Value
This function does not return a value.