001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.io.hfile;
019
020import java.util.concurrent.atomic.LongAdder;
021import org.apache.yetus.audience.InterfaceAudience;
022
023@InterfaceAudience.Private
024public class BloomFilterMetrics {
025
026  private final LongAdder eligibleRequests = new LongAdder();
027  private final LongAdder requests = new LongAdder();
028  private final LongAdder negativeResults = new LongAdder();
029
030  /**
031   * Increment bloom request count, and negative result count if !passed
032   */
033  public void incrementRequests(boolean passed) {
034    requests.increment();
035    if (!passed) {
036      negativeResults.increment();
037    }
038  }
039
040  /**
041   * Increment for cases where bloom filter could have been used but wasn't defined or loaded.
042   */
043  public void incrementEligible() {
044    eligibleRequests.increment();
045  }
046
047  /** Returns Current value for bloom requests count */
048  public long getRequestsCount() {
049    return requests.sum();
050  }
051
052  /** Returns Current value for bloom negative results count */
053  public long getNegativeResultsCount() {
054    return negativeResults.sum();
055  }
056
057  /**
058   * Returns Current value for requests which could have used bloom filters but wasn't defined or
059   * loaded.
060   */
061  public long getEligibleRequestsCount() {
062    return eligibleRequests.sum();
063  }
064
065}