/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ package org.opensearch.knn.plugin.stats; import java.util.function.Supplier; /** * Class represents a stat the plugin keeps track of */ public class KNNStat { private Boolean clusterLevel; private Supplier supplier; /** * Constructor * * @param clusterLevel the scope of the stat * @param supplier supplier that returns the stat's value */ public KNNStat(Boolean clusterLevel, Supplier supplier) { this.clusterLevel = clusterLevel; this.supplier = supplier; } /** * Determines whether the stat is kept at the cluster level or the node level * * @return boolean that is true if the stat is clusterLevel; false otherwise */ public Boolean isClusterLevel() { return clusterLevel; } /** * Get the value of the statistic * * @return value of the stat */ public T getValue() { return supplier.get(); } }