This is an automated email from the ASF dual-hosted git repository.
czweng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 94e146a5b [core] Introduce paimon metric interfaces (#1467)
94e146a5b is described below
commit 94e146a5bc724d73e8c164b773ea55594f80be45
Author: GuojunLi <[email protected]>
AuthorDate: Wed Jul 5 12:12:28 2023 +0800
[core] Introduce paimon metric interfaces (#1467)
This closes #1467.
---
paimon-core/pom.xml | 6 +
.../java/org/apache/paimon/metrics/Counter.java | 62 ++++++
.../metrics/DescriptiveStatisticsHistogram.java | 90 +++++++++
.../DescriptiveStatisticsHistogramStatistics.java | 223 +++++++++++++++++++++
.../main/java/org/apache/paimon/metrics/Gauge.java | 42 ++++
.../java/org/apache/paimon/metrics/Histogram.java | 57 ++++++
.../apache/paimon/metrics/HistogramStatistics.java | 83 ++++++++
.../java/org/apache/paimon/metrics/Metric.java | 33 +++
.../java/org/apache/paimon/metrics/MetricType.java | 33 +++
.../org/apache/paimon/metrics/SimpleCounter.java | 68 +++++++
10 files changed, 697 insertions(+)
diff --git a/paimon-core/pom.xml b/paimon-core/pom.xml
index cb8ca12ff..aee4f2aaf 100644
--- a/paimon-core/pom.xml
+++ b/paimon-core/pom.xml
@@ -168,6 +168,12 @@ under the License.
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-math3</artifactId>
+ <version>3.6.1</version>
+ </dependency>
+
</dependencies>
<build>
diff --git a/paimon-core/src/main/java/org/apache/paimon/metrics/Counter.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/Counter.java
new file mode 100644
index 000000000..b76b9807c
--- /dev/null
+++ b/paimon-core/src/main/java/org/apache/paimon/metrics/Counter.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.Public;
+
+/**
+ * A Counter is a {@link Metric} that measures a count.
+ *
+ * @since 0.5.0
+ */
+@Public
+public interface Counter extends Metric {
+
+ /** Increment the current count by 1. */
+ void inc();
+
+ /**
+ * Increment the current count by the given value.
+ *
+ * @param n value to increment the current count by
+ */
+ void inc(long n);
+
+ /** Decrement the current count by 1. */
+ void dec();
+
+ /**
+ * Decrement the current count by the given value.
+ *
+ * @param n value to decrement the current count by
+ */
+ void dec(long n);
+
+ /**
+ * Returns the current count.
+ *
+ * @return current count
+ */
+ long getCount();
+
+ @Override
+ default MetricType getMetricType() {
+ return MetricType.COUNTER;
+ }
+}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/metrics/DescriptiveStatisticsHistogram.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/DescriptiveStatisticsHistogram.java
new file mode 100644
index 000000000..6246418b6
--- /dev/null
+++
b/paimon-core/src/main/java/org/apache/paimon/metrics/DescriptiveStatisticsHistogram.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
+
+import java.io.Serializable;
+
+/**
+ * The {@link DescriptiveStatisticsHistogram} use a {@link
DescriptiveStatistics} as a Paimon {@link
+ * Histogram}.
+ */
+public class DescriptiveStatisticsHistogram implements Histogram, Serializable
{
+ private static final long serialVersionUID = 1L;
+
+ private final CircularDoubleArray descriptiveStatistics;
+
+ public DescriptiveStatisticsHistogram(int windowSize) {
+ this.descriptiveStatistics = new CircularDoubleArray(windowSize);
+ }
+
+ @Override
+ public void update(long value) {
+ this.descriptiveStatistics.addValue(value);
+ }
+
+ @Override
+ public long getCount() {
+ return this.descriptiveStatistics.getElementsSeen();
+ }
+
+ @Override
+ public HistogramStatistics getStatistics() {
+ return new
DescriptiveStatisticsHistogramStatistics(this.descriptiveStatistics);
+ }
+
+ /** Fixed-size array that wraps around at the end and has a dynamic start
position. */
+ static class CircularDoubleArray implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final double[] backingArray;
+ private int nextPos = 0;
+ private boolean fullSize = false;
+ private long elementsSeen = 0;
+
+ CircularDoubleArray(int windowSize) {
+ this.backingArray = new double[windowSize];
+ }
+
+ synchronized void addValue(double value) {
+ backingArray[nextPos] = value;
+ ++elementsSeen;
+ ++nextPos;
+ if (nextPos == backingArray.length) {
+ nextPos = 0;
+ fullSize = true;
+ }
+ }
+
+ synchronized double[] toUnsortedArray() {
+ final int size = getSize();
+ double[] result = new double[size];
+ System.arraycopy(backingArray, 0, result, 0, result.length);
+ return result;
+ }
+
+ private synchronized int getSize() {
+ return fullSize ? backingArray.length : nextPos;
+ }
+
+ private synchronized long getElementsSeen() {
+ return elementsSeen;
+ }
+ }
+}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/metrics/DescriptiveStatisticsHistogramStatistics.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/DescriptiveStatisticsHistogramStatistics.java
new file mode 100644
index 000000000..816ce325b
--- /dev/null
+++
b/paimon-core/src/main/java/org/apache/paimon/metrics/DescriptiveStatisticsHistogramStatistics.java
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.VisibleForTesting;
+
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
+import org.apache.commons.math3.stat.descriptive.UnivariateStatistic;
+import org.apache.commons.math3.stat.descriptive.moment.SecondMoment;
+import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
+import org.apache.commons.math3.stat.descriptive.rank.Percentile;
+import org.apache.commons.math3.stat.ranking.NaNStrategy;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+/**
+ * DescriptiveStatistics histogram statistics implementation returned by {@link
+ * DescriptiveStatisticsHistogram}.
+ *
+ * <p>The statistics takes a point-in-time snapshot of a {@link
DescriptiveStatistics} instance and
+ * allows optimised metrics retrieval from this.
+ */
+public class DescriptiveStatisticsHistogramStatistics extends
HistogramStatistics
+ implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final CommonMetricsSnapshot statisticsSummary = new
CommonMetricsSnapshot();
+
+ public DescriptiveStatisticsHistogramStatistics(
+ DescriptiveStatisticsHistogram.CircularDoubleArray
histogramValues) {
+ this(histogramValues.toUnsortedArray());
+ }
+
+ public DescriptiveStatisticsHistogramStatistics(final double[] values) {
+ statisticsSummary.evaluate(values);
+ }
+
+ @Override
+ public double getQuantile(double quantile) {
+ return statisticsSummary.getPercentile(quantile * 100);
+ }
+
+ @Override
+ public long[] getValues() {
+ return Arrays.stream(statisticsSummary.getValues()).mapToLong(i ->
(long) i).toArray();
+ }
+
+ @Override
+ public int size() {
+ return (int) statisticsSummary.getCount();
+ }
+
+ @Override
+ public double getMean() {
+ return statisticsSummary.getMean();
+ }
+
+ @Override
+ public double getStdDev() {
+ return statisticsSummary.getStandardDeviation();
+ }
+
+ @Override
+ public long getMax() {
+ return (long) statisticsSummary.getMax();
+ }
+
+ @Override
+ public long getMin() {
+ return (long) statisticsSummary.getMin();
+ }
+
+ /**
+ * Function to extract several commonly used metrics in an optimised way,
i.e. with as few runs
+ * over the data / calculations as possible.
+ *
+ * <p>Note that calls to {@link #evaluate(double[])} or {@link
#evaluate(double[], int, int)}
+ * will not return a value but instead populate this class so that further
values can be
+ * retrieved from it.
+ */
+ @VisibleForTesting
+ static class CommonMetricsSnapshot implements UnivariateStatistic,
Serializable {
+ private static final long serialVersionUID = 2L;
+
+ private double[] data;
+ private double min = Double.NaN;
+ private double max = Double.NaN;
+ private double mean = Double.NaN;
+ private double stddev = Double.NaN;
+ private transient Percentile percentilesImpl;
+
+ @Override
+ public double evaluate(final double[] values) throws
MathIllegalArgumentException {
+ return evaluate(values, 0, values.length);
+ }
+
+ @Override
+ public double evaluate(double[] values, int begin, int length)
+ throws MathIllegalArgumentException {
+ this.data = values;
+
+ SimpleStats secondMoment = new SimpleStats();
+ secondMoment.evaluate(values, begin, length);
+ this.mean = secondMoment.getMean();
+ this.min = secondMoment.getMin();
+ this.max = secondMoment.getMax();
+
+ this.stddev = new StandardDeviation(secondMoment).getResult();
+
+ return Double.NaN;
+ }
+
+ @Override
+ public CommonMetricsSnapshot copy() {
+ CommonMetricsSnapshot result = new CommonMetricsSnapshot();
+ result.data = Arrays.copyOf(data, data.length);
+ result.min = min;
+ result.max = max;
+ result.mean = mean;
+ result.stddev = stddev;
+ return result;
+ }
+
+ long getCount() {
+ return data.length;
+ }
+
+ double getMin() {
+ return min;
+ }
+
+ double getMax() {
+ return max;
+ }
+
+ double getMean() {
+ return mean;
+ }
+
+ double getStandardDeviation() {
+ return stddev;
+ }
+
+ double getPercentile(double p) {
+ maybeInitPercentile();
+ return percentilesImpl.evaluate(p);
+ }
+
+ double[] getValues() {
+ maybeInitPercentile();
+ return percentilesImpl.getData();
+ }
+
+ private void maybeInitPercentile() {
+ if (percentilesImpl == null) {
+ percentilesImpl = new
Percentile().withNaNStrategy(NaNStrategy.FIXED);
+ }
+ if (data != null) {
+ percentilesImpl.setData(data);
+ }
+ }
+ }
+
+ /**
+ * Calculates min, max, mean (first moment), as well as the second moment
in one go over the
+ * value array.
+ */
+ private static class SimpleStats extends SecondMoment {
+ private static final long serialVersionUID = 1L;
+
+ private double min = Double.NaN;
+ private double max = Double.NaN;
+
+ @Override
+ public void increment(double d) {
+ if (d < min || Double.isNaN(min)) {
+ min = d;
+ }
+ if (d > max || Double.isNaN(max)) {
+ max = d;
+ }
+ super.increment(d);
+ }
+
+ @Override
+ public SecondMoment copy() {
+ SimpleStats result = new SimpleStats();
+ SecondMoment.copy(this, result);
+ result.min = min;
+ result.max = max;
+ return result;
+ }
+
+ public double getMin() {
+ return min;
+ }
+
+ public double getMax() {
+ return max;
+ }
+
+ public double getMean() {
+ return m1;
+ }
+ }
+}
diff --git a/paimon-core/src/main/java/org/apache/paimon/metrics/Gauge.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/Gauge.java
new file mode 100644
index 000000000..d574099cb
--- /dev/null
+++ b/paimon-core/src/main/java/org/apache/paimon/metrics/Gauge.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.Public;
+
+/**
+ * A Gauge is a {@link Metric} that calculates a specific value at a point in
time.
+ *
+ * @since 0.5.0
+ */
+@Public
+public interface Gauge<T> extends Metric {
+
+ /**
+ * Calculates and returns the measured value.
+ *
+ * @return calculated value
+ */
+ T getValue();
+
+ @Override
+ default MetricType getMetricType() {
+ return MetricType.GAUGE;
+ }
+}
diff --git a/paimon-core/src/main/java/org/apache/paimon/metrics/Histogram.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/Histogram.java
new file mode 100644
index 000000000..9fb2b71e1
--- /dev/null
+++ b/paimon-core/src/main/java/org/apache/paimon/metrics/Histogram.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.Public;
+
+/**
+ * The histogram allows to record values, get the current count of recorded
values and create
+ * histogram statistics for the currently seen elements.
+ *
+ * @since 0.5.0
+ */
+@Public
+public interface Histogram extends Metric {
+
+ /**
+ * Update the histogram with the given value.
+ *
+ * @param value Value to update the histogram with
+ */
+ void update(long value);
+
+ /**
+ * Get the count of seen elements.
+ *
+ * @return Count of seen elements
+ */
+ long getCount();
+
+ /**
+ * Create statistics for the currently recorded elements.
+ *
+ * @return Statistics about the currently recorded elements
+ */
+ HistogramStatistics getStatistics();
+
+ @Override
+ default MetricType getMetricType() {
+ return MetricType.HISTOGRAM;
+ }
+}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/metrics/HistogramStatistics.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/HistogramStatistics.java
new file mode 100644
index 000000000..1d8041b9c
--- /dev/null
+++
b/paimon-core/src/main/java/org/apache/paimon/metrics/HistogramStatistics.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.Public;
+
+/**
+ * Histogram statistics represent the current snapshot of elements recorded in
the histogram.
+ *
+ * <p>The histogram statistics allow to calculate values for quantiles, the
mean, the standard
+ * deviation, the minimum and the maximum.
+ *
+ * @since 0.5.0
+ */
+@Public
+public abstract class HistogramStatistics {
+
+ /**
+ * Returns the value for the given quantile based on the represented
histogram statistics.
+ *
+ * @param quantile Quantile to calculate the value for
+ * @return Value for the given quantile
+ */
+ public abstract double getQuantile(double quantile);
+
+ /**
+ * Returns the elements of the statistics' sample.
+ *
+ * @return Elements of the statistics' sample
+ */
+ public abstract long[] getValues();
+
+ /**
+ * Returns the size of the statistics' sample.
+ *
+ * @return Size of the statistics' sample
+ */
+ public abstract int size();
+
+ /**
+ * Returns the mean of the histogram values.
+ *
+ * @return Mean of the histogram values
+ */
+ public abstract double getMean();
+
+ /**
+ * Returns the standard deviation of the distribution reflected by the
histogram statistics.
+ *
+ * @return Standard deviation of histogram distribution
+ */
+ public abstract double getStdDev();
+
+ /**
+ * Returns the maximum value of the histogram.
+ *
+ * @return Maximum value of the histogram
+ */
+ public abstract long getMax();
+
+ /**
+ * Returns the minimum value of the histogram.
+ *
+ * @return Minimum value of the histogram
+ */
+ public abstract long getMin();
+}
diff --git a/paimon-core/src/main/java/org/apache/paimon/metrics/Metric.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/Metric.java
new file mode 100644
index 000000000..c882211ed
--- /dev/null
+++ b/paimon-core/src/main/java/org/apache/paimon/metrics/Metric.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.Public;
+
+/**
+ * An interface to indicate a class is a metric.
+ *
+ * @since 0.5.0
+ */
+@Public
+public interface Metric {
+ default MetricType getMetricType() {
+ throw new UnsupportedOperationException("Custom metric types are not
supported.");
+ }
+}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/metrics/MetricType.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/MetricType.java
new file mode 100644
index 000000000..811322ea7
--- /dev/null
+++ b/paimon-core/src/main/java/org/apache/paimon/metrics/MetricType.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+import org.apache.paimon.annotation.Public;
+
+/**
+ * Enum describing the different metric types.
+ *
+ * @since 0.5.0
+ */
+@Public
+public enum MetricType {
+ COUNTER,
+ GAUGE,
+ HISTOGRAM
+}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/metrics/SimpleCounter.java
b/paimon-core/src/main/java/org/apache/paimon/metrics/SimpleCounter.java
new file mode 100644
index 000000000..a5ae861cb
--- /dev/null
+++ b/paimon-core/src/main/java/org/apache/paimon/metrics/SimpleCounter.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.metrics;
+
+/** A simple low-overhead {@link org.apache.paimon.metrics.Counter}. */
+public class SimpleCounter implements Counter {
+
+ /** the current count. */
+ private long count;
+
+ /** Increment the current count by 1. */
+ @Override
+ public void inc() {
+ count++;
+ }
+
+ /**
+ * Increment the current count by the given value.
+ *
+ * @param n value to increment the current count by
+ */
+ @Override
+ public void inc(long n) {
+ count += n;
+ }
+
+ /** Decrement the current count by 1. */
+ @Override
+ public void dec() {
+ count--;
+ }
+
+ /**
+ * Decrement the current count by the given value.
+ *
+ * @param n value to decrement the current count by
+ */
+ @Override
+ public void dec(long n) {
+ count -= n;
+ }
+
+ /**
+ * Returns the current count.
+ *
+ * @return current count
+ */
+ @Override
+ public long getCount() {
+ return count;
+ }
+}