Skip to content

Commit 55ab5d2

Browse files
committed
[#7332] feat(api): Support statistic interfaces
1 parent 5fa0b10 commit 55ab5d2

File tree

11 files changed

+686
-0
lines changed

11 files changed

+686
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.gravitino.exceptions;
20+
21+
import com.google.errorprone.annotations.FormatMethod;
22+
import com.google.errorprone.annotations.FormatString;
23+
24+
/** An exception thrown when statistic has an illegal name */
25+
public class IllegalStatisticNameException extends GravitinoRuntimeException {
26+
/**
27+
* Constructs a new exception with the specified detail message.
28+
*
29+
* @param message the detail message.
30+
* @param args the arguments to the message.
31+
*/
32+
@FormatMethod
33+
public IllegalStatisticNameException(@FormatString String message, Object... args) {
34+
super(message, args);
35+
}
36+
37+
/**
38+
* Constructs a new exception with the specified detail message and cause.
39+
*
40+
* @param cause the cause.
41+
* @param message the detail message.
42+
* @param args the arguments to the message.
43+
*/
44+
@FormatMethod
45+
public IllegalStatisticNameException(
46+
Throwable cause, @FormatString String message, Object... args) {
47+
super(cause, message, args);
48+
}
49+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.gravitino.exceptions;
20+
21+
import com.google.errorprone.annotations.FormatMethod;
22+
import com.google.errorprone.annotations.FormatString;
23+
24+
/** An exception thrown when users modify an unmodifiable statistic */
25+
public class UnmodifiableStatisticException extends GravitinoRuntimeException {
26+
/**
27+
* Constructs a new exception with the specified detail message.
28+
*
29+
* @param message the detail message.
30+
* @param args the arguments to the message.
31+
*/
32+
@FormatMethod
33+
public UnmodifiableStatisticException(@FormatString String message, Object... args) {
34+
super(message, args);
35+
}
36+
37+
/**
38+
* Constructs a new exception with the specified detail message and cause.
39+
*
40+
* @param cause the cause.
41+
* @param message the detail message.
42+
* @param args the arguments to the message.
43+
*/
44+
@FormatMethod
45+
public UnmodifiableStatisticException(
46+
Throwable cause, @FormatString String message, Object... args) {
47+
super(cause, message, args);
48+
}
49+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.gravitino.stats;
20+
21+
import java.util.Objects;
22+
23+
/** Represents a boolean value in statistics. */
24+
public class BooleanValue implements StatisticValue<Boolean> {
25+
private final Boolean value;
26+
27+
/**
28+
* Constructor for BooleanValue.
29+
*
30+
* @param value the boolean value to be represented
31+
*/
32+
public BooleanValue(Boolean value) {
33+
this.value = value;
34+
}
35+
36+
@Override
37+
public Type type() {
38+
return Type.BOOLEAN;
39+
}
40+
41+
@Override
42+
public Boolean value() {
43+
return value;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return "BooleanValue{" + "value=" + value + '}';
49+
}
50+
51+
@Override
52+
public int hashCode() {
53+
return Objects.hash(value);
54+
}
55+
56+
@Override
57+
public boolean equals(Object obj) {
58+
if (!(obj instanceof BooleanValue)) {
59+
return false;
60+
}
61+
BooleanValue that = (BooleanValue) obj;
62+
return Objects.equals(value, that.value);
63+
}
64+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.gravitino.stats;
20+
21+
import java.util.Objects;
22+
23+
/** Represents a decimal value in statistics. */
24+
public class DecimalValue implements StatisticValue<Double> {
25+
private final Double value;
26+
27+
/**
28+
* Constructor for DecimalValue.
29+
*
30+
* @param value the decimal value to be represented
31+
*/
32+
public DecimalValue(Double value) {
33+
this.value = value;
34+
}
35+
36+
@Override
37+
public Type type() {
38+
return Type.DECIMAL;
39+
}
40+
41+
@Override
42+
public Double value() {
43+
return value;
44+
}
45+
46+
@Override
47+
public String toString() {
48+
return "DecimalValue{" + "value=" + value + '}';
49+
}
50+
51+
@Override
52+
public int hashCode() {
53+
return Objects.hash(value);
54+
}
55+
56+
@Override
57+
public boolean equals(Object obj) {
58+
if (!(obj instanceof DecimalValue)) {
59+
return false;
60+
}
61+
DecimalValue that = (DecimalValue) obj;
62+
63+
return Objects.equals(value, that.value);
64+
}
65+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.gravitino.stats;
20+
21+
import java.util.List;
22+
import java.util.Objects;
23+
24+
/** Represents a list of statistic values in statistics. */
25+
public class ListValue implements StatisticValue<List<StatisticValue>> {
26+
private final List<StatisticValue> values;
27+
28+
/**
29+
* Constructs a ListValue with the given list of statistic values.
30+
*
31+
* @param values a list of StatisticValue objects
32+
*/
33+
public ListValue(List<StatisticValue> values) {
34+
this.values = values;
35+
}
36+
37+
@Override
38+
public Type type() {
39+
return Type.LIST;
40+
}
41+
42+
@Override
43+
public List<StatisticValue> value() {
44+
return values;
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "ArrayValue{" + "value=" + values + '}';
50+
}
51+
52+
@Override
53+
public int hashCode() {
54+
return Objects.hashCode(values);
55+
}
56+
57+
@Override
58+
public boolean equals(Object obj) {
59+
if (!(obj instanceof ListValue)) {
60+
return false;
61+
}
62+
ListValue that = (ListValue) obj;
63+
return Objects.equals(values, that.values);
64+
}
65+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.gravitino.stats;
20+
21+
import java.util.Objects;
22+
23+
/** Represents a long value in statistics. */
24+
public class LongValue implements StatisticValue<Long> {
25+
26+
private final Long value;
27+
28+
/**
29+
* Constructor for LongValue.
30+
*
31+
* @param value the long value to be represented
32+
*/
33+
public LongValue(Long value) {
34+
this.value = value;
35+
}
36+
37+
@Override
38+
public Type type() {
39+
return Type.LONG;
40+
}
41+
42+
@Override
43+
public Long value() {
44+
return value;
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "LongValue{" + "value=" + value + '}';
50+
}
51+
52+
@Override
53+
public int hashCode() {
54+
return Objects.hash(value);
55+
}
56+
57+
@Override
58+
public boolean equals(Object obj) {
59+
if (!(obj instanceof LongValue)) {
60+
return false;
61+
}
62+
63+
LongValue that = (LongValue) obj;
64+
65+
return Objects.equals(this.value, that.value);
66+
}
67+
}

0 commit comments

Comments
 (0)