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() Asynchronous

    Retrieves 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

    Asynchronously retrieves statistics for all indexes.

    Declaration

    Swift

    public func getIndexStats() async -> [String : IndexStat]

    Return Value

    A dictionary where the keys are index names (String) and the values are IndexStat objects containing the statistics for each index.

  • getShardStats() Asynchronous

    Retrieves 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.

  • 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.