You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "jerqi (via GitHub)" <gi...@apache.org> on 2025/06/04 13:24:53 UTC
[PR] [#7332] feat(api): Support statistic interfaces [gravitino]
jerqi opened a new pull request, #7333:
URL: https://github.com/apache/gravitino/pull/7333
### What changes were proposed in this pull request?
Support statistic interfaces
### Why are the changes needed?
Fix: #7332
### Does this PR introduce _any_ user-facing change?
Yes, I will add the document
### How was this patch tested?
Code review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134763329
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ *
+ * <p>For different statistics, Gravitino will use different storage solution for them. Table
+ * statistics will be stored in Gravitino metadata store, usually the Gravitino's metadata is
+ * relational database, it's difficult to store millions rows of records.
+ *
+ * <p>But for partition statistics, there may be millions of partitions in a large table. So
+ * Gravitino will use a external storage solution. Gravitino will use a file to store all
+ * partitions. The partition statistics may be several megabytes. If a partition is stored as a
+ * file, it will cause millions of small files in the storage system. It will cause high pressure
+ * for HDFS if you choose HDFS as external storage. If the partition statistic is requested for
+ * multiple times, Gravitino will use cache to improve performance.
Review Comment:
OK, I can remove them later. Just to let reviewers to realize of my solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137406167
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
Literal interfaces is as below
```
public interface Literal<T> extends Expression {
/** @return The literal value. */
T value();
/** @return The data type of the literal. */
Type dataType();
@Override
default Expression[] children() {
return EMPTY_EXPRESSION;
}
}
```
It has the method `expression`. It may cause users confused. But it's ok for me if we can use the concepts of `rel` module.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134759813
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ *
+ * <p>For different statistics, Gravitino will use different storage solution for them. Table
+ * statistics will be stored in Gravitino metadata store, usually the Gravitino's metadata is
+ * relational database, it's difficult to store millions rows of records.
+ *
+ * <p>But for partition statistics, there may be millions of partitions in a large table. So
+ * Gravitino will use a external storage solution. Gravitino will use a file to store all
+ * partitions. The partition statistics may be several megabytes. If a partition is stored as a
+ * file, it will cause millions of small files in the storage system. It will cause high pressure
+ * for HDFS if you choose HDFS as external storage. If the partition statistic is requested for
+ * multiple times, Gravitino will use cache to improve performance.
Review Comment:
You don't have to explain the implementation here. The javadoc here is mainly for the users about the functionality and how to use about the `statistic`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134761104
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
Review Comment:
What's the meaning of your comment?
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
Review Comment:
What's the meaning of your comment?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2135919213
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
package `rel` doesn't mean that it can only be used by the relational catalog, not to say most of statistics users are relational type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2165922764
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValues.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.gravitino.stats;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.rel.types.Types;
+
+/** A class representing a collection of statistic values. */
+public class StatisticValues {
+
+ private StatisticValues() {}
+
+ /**
+ * Creates a statistic value that holds a boolean value.
+ *
+ * @param value the boolean value to be held by this statistic value
+ * @return a BooleanValue instance containing the provided boolean value
+ */
+ public static BooleanValue booleanValue(boolean value) {
+ return new BooleanValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a long value.
+ *
+ * @param value the long value to be held by this statistic value
+ * @return a LongValue instance containing the provided long value
+ */
+ public static LongValue longValue(long value) {
+ return new LongValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a double value.
+ *
+ * @param value the double value to be held by this statistic value
+ * @return a DoubleValue instance containing the provided double value
+ */
+ public static DoubleValue doubleValue(double value) {
+ return new DoubleValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a string value.
+ *
+ * @param value the string value to be held by this statistic value
+ * @return a StringValue instance containing the provided string value
+ */
+ public static StringValue stringValue(String value) {
+ return new StringValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a list of other statistic values.
+ *
+ * @param values the list of statistic values to be held by this statistic value
+ * @return a ListValue instance containing the provided list of statistic values
+ */
+ public static ListValue listValue(List<StatisticValue> values) {
+ return new ListValue(values);
+ }
+
+ /**
+ * Creates a statistic value that holds a map of string keys to other statistic values.
+ *
+ * @param values the map of string keys to statistic values to be held by this statistic value
+ * @return an ObjectValue instance containing the provided map of statistic values
+ */
+ public static ObjectValue objectValue(Map<String, StatisticValue> values) {
+ return new ObjectValue(values);
+ }
+
+ /** A statistic value that holds a Boolean value. */
+ public static class BooleanValue implements StatisticValue<Boolean> {
+ private final Boolean value;
+
+ private BooleanValue(Boolean value) {
+ this.value = value;
+ }
+
+ @Override
+ public Boolean value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.BooleanType.get();
+ }
+ }
+
+ /** A statistic value that holds a Long value. */
+ public static class LongValue implements StatisticValue<Long> {
+ private final Long value;
+
+ private LongValue(Long value) {
+ this.value = value;
+ }
+
+ @Override
+ public Long value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.LongType.get();
+ }
+ }
+
+ /** A statistic value that holds a Double value. */
+ public static class DoubleValue implements StatisticValue<Double> {
+ private final Double value;
+
+ private DoubleValue(Double value) {
+ this.value = value;
+ }
+
+ @Override
+ public Double value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.DoubleType.get();
+ }
+ }
+
+ /** A statistic value that holds a String value. */
+ public static class StringValue implements StatisticValue<String> {
+ private final String value;
+
+ private StringValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.StringType.get();
+ }
+ }
+
+ /** A statistic value that holds a List of other statistic values. */
+ public static class ListValue implements StatisticValue<List<StatisticValue>> {
+ private final List<StatisticValue> valueList;
+
+ private ListValue(List<StatisticValue> valueList) {
+ Preconditions.checkArgument(
+ valueList != null && !valueList.isEmpty(), "Values cannot be null or empty");
+
+ Type dataType = valueList.get(0).dataType();
+ Preconditions.checkArgument(
+ valueList.stream().allMatch(value -> value.dataType().equals(dataType)),
+ "All values in the list must have the same data type");
+
+ this.valueList = valueList;
+ }
+
+ @Override
+ public List<StatisticValue> value() {
+ return valueList;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.ListType.nullable(valueList.get(0).dataType());
+ }
+ }
+
+ /** A statistic value that holds a Map of String keys to other statistic values. */
+ public static class ObjectValue implements StatisticValue<Map<String, StatisticValue>> {
Review Comment:
Why call it `ObjectValue`, not `MapValue`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #7333:
URL: https://github.com/apache/gravitino/pull/7333
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137299602
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
`Literal` don't create struct value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137406167
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
Literal interfaces is as below
```
public interface Literal<T> extends Expression {
/** @return The literal value. */
T value();
/** @return The data type of the literal. */
Type dataType();
@Override
default Expression[] children() {
return EMPTY_EXPRESSION;
}
}
```
It has the method `expression`. It may cause users confused. But it's ok for me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134761314
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
I think we can use the existing type system in Gravitino to represent the type, what do you think? cc @mchades .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2168239260
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ */
+@Evolving
+public interface Statistic {
+
+ /**
+ * Get the name of the statistic.
+ *
+ * @return The name of the statistic.
+ */
+ String name();
+
+ /**
+ * Get the value of the statistic. The value is optional. If the statistic is not set, the value
+ * will be empty.
+ *
+ * @return An optional containing the value of the statistic if it is set, otherwise empty.
+ */
+ Optional<StatisticValue> value();
+
+ /**
+ * The statistic is predefined by Gravitino if the value is true. The statistic is defined by
+ * users if the value if false. For example, the statistic "row_count" is a reserved statistic, A
+ * custom statistic name must start with "custom." prefix to avoid name conflict with reserved
Review Comment:
OK.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134985551
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
It's weird for fileset statistics to use `rel/type`. The statistic isn't only used for `table` and `partition`. May we need to add model statisitcs in the future. Maybe the types of statisitic are only the subset of rel types.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134987142
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
Review Comment:
I got your meaning. I can modify the comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2135414237
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
At least they are in the package `rel`. If statistic depends on it, we should move them to a common module.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137126478
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
Compared to `rel` type, `rel` type gave more constraints.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2138343669
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
What is the pros and cons of using `Literal`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134971076
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
I think it is acceptable. For the table / partition statistics, they're mainly related to `rel`. Besides, for the nested type, your definition here doesn't have the nested type, do you need to specify that type? If so, the type system already defined that, it is much easier to leverage than building from ground.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137108783
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
I tried to reuse `rel` type. But I raised an issues. Statistic map type can have different types of values.
For example, I have an map of column statistic.
{
min: integer,
max: integer,
ndv: object
}
But it's difficult to use `rel` type. Because it will need to specifify value type.
If I use struct type, it seems complex , too. Because we need to use field to explain every fields.
cc @mchades
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2135414237
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
At least they are in the package `rel`. If statistic depends on it, we should move them to a common module.
Another concern is that struct type. It is hard to extract concrete value from a struct type variable according to API definition. For example, we can't get a map from a struct type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2165920524
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValues.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.gravitino.stats;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.rel.types.Types;
+
+/** A class representing a collection of statistic values. */
+public class StatisticValues {
+
+ private StatisticValues() {}
+
+ /**
+ * Creates a statistic value that holds a boolean value.
+ *
+ * @param value the boolean value to be held by this statistic value
+ * @return a BooleanValue instance containing the provided boolean value
+ */
+ public static BooleanValue booleanValue(boolean value) {
+ return new BooleanValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a long value.
+ *
+ * @param value the long value to be held by this statistic value
+ * @return a LongValue instance containing the provided long value
+ */
+ public static LongValue longValue(long value) {
+ return new LongValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a double value.
+ *
+ * @param value the double value to be held by this statistic value
+ * @return a DoubleValue instance containing the provided double value
+ */
+ public static DoubleValue doubleValue(double value) {
+ return new DoubleValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a string value.
+ *
+ * @param value the string value to be held by this statistic value
+ * @return a StringValue instance containing the provided string value
+ */
+ public static StringValue stringValue(String value) {
+ return new StringValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a list of other statistic values.
+ *
+ * @param values the list of statistic values to be held by this statistic value
+ * @return a ListValue instance containing the provided list of statistic values
+ */
+ public static ListValue listValue(List<StatisticValue> values) {
Review Comment:
Should you change to `ListValue<T>`, what is the type of `StatisticValue` in the list?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2168234335
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValues.java:
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.gravitino.stats;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.rel.types.Types;
+
+/** A class representing a collection of statistic values. */
+public class StatisticValues {
+
+ private StatisticValues() {}
+
+ /**
+ * Creates a statistic value that holds a boolean value.
+ *
+ * @param value the boolean value to be held by this statistic value
+ * @return a BooleanValue instance containing the provided boolean value
+ */
+ public static BooleanValue booleanValue(boolean value) {
+ return new BooleanValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a long value.
+ *
+ * @param value the long value to be held by this statistic value
+ * @return a LongValue instance containing the provided long value
+ */
+ public static LongValue longValue(long value) {
+ return new LongValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a double value.
+ *
+ * @param value the double value to be held by this statistic value
+ * @return a DoubleValue instance containing the provided double value
+ */
+ public static DoubleValue doubleValue(double value) {
+ return new DoubleValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a string value.
+ *
+ * @param value the string value to be held by this statistic value
+ * @return a StringValue instance containing the provided string value
+ */
+ public static StringValue stringValue(String value) {
+ return new StringValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a list of other statistic values.
+ *
+ * @param values the list of statistic values to be held by this statistic value
+ * @return a ListValue instance containing the provided list of statistic values
+ */
+ public static ListValue listValue(List<StatisticValue> values) {
+ return new ListValue(values);
+ }
+
+ /**
+ * Creates a statistic value that holds a map of string keys to other statistic values.
+ *
+ * @param values the map of string keys to statistic values to be held by this statistic value
+ * @return an ObjectValue instance containing the provided map of statistic values
+ */
+ public static ObjectValue objectValue(Map<String, StatisticValue> values) {
+ return new ObjectValue(values);
+ }
+
+ /** A statistic value that holds a Boolean value. */
+ public static class BooleanValue implements StatisticValue<Boolean> {
+ private final Boolean value;
+
+ private BooleanValue(Boolean value) {
+ this.value = value;
+ }
+
+ @Override
+ public Boolean value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.BooleanType.get();
+ }
+ }
+
+ /** A statistic value that holds a Long value. */
+ public static class LongValue implements StatisticValue<Long> {
+ private final Long value;
+
+ private LongValue(Long value) {
+ this.value = value;
+ }
+
+ @Override
+ public Long value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.LongType.get();
+ }
+ }
+
+ /** A statistic value that holds a Double value. */
+ public static class DoubleValue implements StatisticValue<Double> {
+ private final Double value;
+
+ private DoubleValue(Double value) {
+ this.value = value;
+ }
+
+ @Override
+ public Double value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.DoubleType.get();
+ }
+ }
+
+ /** A statistic value that holds a String value. */
+ public static class StringValue implements StatisticValue<String> {
+ private final String value;
+
+ private StringValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.StringType.get();
+ }
+ }
+
+ /** A statistic value that holds a List of other statistic values. */
+ public static class ListValue implements StatisticValue<List<StatisticValue>> {
+ private final List<StatisticValue> valueList;
+
+ private ListValue(List<StatisticValue> valueList) {
+ Preconditions.checkArgument(
+ valueList != null && !valueList.isEmpty(), "Values cannot be null or empty");
+
+ Type dataType = valueList.get(0).dataType();
+ Preconditions.checkArgument(
+ valueList.stream().allMatch(value -> value.dataType().equals(dataType)),
+ "All values in the list must have the same data type");
+
+ this.valueList = valueList;
+ }
+
+ @Override
+ public List<StatisticValue> value() {
+ return valueList;
+ }
+
+ @Override
+ public Type dataType() {
+ return Types.ListType.nullable(valueList.get(0).dataType());
+ }
+ }
+
+ /** A statistic value that holds a Map of String keys to other statistic values. */
+ public static class ObjectValue implements StatisticValue<Map<String, StatisticValue>> {
Review Comment:
In our type system, MapValue need the same value type. I refer to the json style, named it to objectValue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137299602
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
`Literal` don't create struct value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2128099137
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ *
+ * <p>For different statistics, Gravitino will use different storage solution for them. Table
+ * statistics will be stored in Gravitino metadata store, usually the Gravitino's metadata is
+ * relational database, it's difficult to store millions rows of records.
+ *
+ * <p>But for partition statistics, there may be millions of partitions in a large table. So
+ * Gravitino will use a external storage solution. Gravitino will use a file to store all
+ * partitions. The partition statistics may be several megabytes. If a partition is stored as a
+ * file, it will cause millions of small files in the storage system. It will cause high pressure
+ * for HDFS if you choose HDFS as external storage. If the partition statistic is requested for
+ * multiple times, Gravitino will use cache to improve performance.
+ *
+ * <p>The file format of partition statistics is Json, Iceberg isn't design for small files. It will
+ * read multiple files in a single read operation. It will append many small data files if users
+ * update a partition every time. The relational database will record the pointer of the partition
+ * statistics file.
Review Comment:
It seems you describe some issues with statistics storage but don't provide a solution.
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
Review Comment:
When would we use string? Can you give an example?
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
Review Comment:
`Integer` and `Double` are not defined in your definition
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134761104
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
Review Comment:
What's the meaning of your comment?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#issuecomment-3021536014
I don't have further comments, @mchades @FANNG1 can you please take a review also.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2177323160
##########
api/src/test/java/org/apache/gravitino/stats/TestStatisticValue.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.gravitino.stats;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.rel.types.Types;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestStatisticValue {
+
+ @Test
+ public void testLiterals() {
+ StatisticValues.BooleanValue booleanValue = StatisticValues.booleanValue(true);
+ Assertions.assertTrue(booleanValue.value());
+ Assertions.assertEquals(booleanValue.dataType(), Types.BooleanType.get());
Review Comment:
I added the `equals` and `hashCode` to fix this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2174347455
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValues.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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.gravitino.stats;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.rel.types.Types;
+
+/** A class representing a collection of statistic values. */
+public class StatisticValues {
+
+ private StatisticValues() {}
+
+ /**
+ * Creates a statistic value that holds a boolean value.
+ *
+ * @param value the boolean value to be held by this statistic value
+ * @return a BooleanValue instance containing the provided boolean value
+ */
+ public static BooleanValue booleanValue(boolean value) {
+ return new BooleanValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a long value.
+ *
+ * @param value the long value to be held by this statistic value
+ * @return a LongValue instance containing the provided long value
+ */
+ public static LongValue longValue(long value) {
+ return new LongValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a double value.
+ *
+ * @param value the double value to be held by this statistic value
+ * @return a DoubleValue instance containing the provided double value
+ */
+ public static DoubleValue doubleValue(double value) {
+ return new DoubleValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a string value.
+ *
+ * @param value the string value to be held by this statistic value
+ * @return a StringValue instance containing the provided string value
+ */
+ public static StringValue stringValue(String value) {
+ return new StringValue(value);
+ }
+
+ /**
+ * Creates a statistic value that holds a list of other statistic values.
+ *
+ * @param <T> the type of the values in the list
+ * @param values the list of statistic values to be held by this statistic value
+ * @return a ListValue instance containing the provided list of statistic values
+ */
+ public static <T> ListValue<T> listValue(List<StatisticValue<T>> values) {
+ return new ListValue<T>(values);
+ }
+
+ /**
+ * Creates a statistic value that holds a map of string keys to other statistic values.
+ *
+ * @param values the map of string keys to statistic values to be held by this statistic value
+ * @return an ObjectValue instance containing the provided map of statistic values
+ */
+ public static ObjectValue objectValue(Map<String, StatisticValue> values) {
Review Comment:
I addressed the warning.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134763382
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
It will depends `rel` module. Statistic shouldn't be bind to `rel` module.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134985551
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
It's weird for fileset statistics to use `rel/type`. The statistic isn't only used for `table` and `partition`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2135414237
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
At least they are in the package `rel`. If statistic depends on it, we should move them to a common module.
Another concern is that struct type. It is hard to extract concrete field value from a struct type variable according to API definition. For example,
we have a struct { a int}; I can't get the field a.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2177305456
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ */
+@Evolving
+public interface Statistic {
+
+ /** The prefix for custom statistics. Custom statistics are user-defined statistics. */
+ String CUSTOM_PREFIX = "custom.";
+
+ /**
+ * Get the name of the statistic.
+ *
+ * @return The name of the statistic.
+ */
+ String name();
+
+ /**
+ * Get the value of the statistic. The value is optional. If the statistic is not set, the value
+ * will be empty.
+ *
+ * @return An optional containing the value of the statistic if it is set, otherwise empty.
+ */
+ Optional<StatisticValue> value();
+
+ /**
+ * The statistic is predefined by Gravitino if the value is true. The statistic is defined by
+ * users if the value if false. For example, the statistic "row_count" is a reserved statistic, A
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2128102860
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ *
+ * <p>For different statistics, Gravitino will use different storage solution for them. Table
+ * statistics will be stored in Gravitino metadata store, usually the Gravitino's metadata is
+ * relational database, it's difficult to store millions rows of records.
+ *
+ * <p>But for partition statistics, there may be millions of partitions in a large table. So
+ * Gravitino will use a external storage solution. Gravitino will use a file to store all
+ * partitions. The partition statistics may be several megabytes. If a partition is stored as a
+ * file, it will cause millions of small files in the storage system. It will cause high pressure
+ * for HDFS if you choose HDFS as external storage. If the partition statistic is requested for
+ * multiple times, Gravitino will use cache to improve performance.
+ *
+ * <p>The file format of partition statistics is Json, Iceberg isn't design for small files. It will
+ * read multiple files in a single read operation. It will append many small data files if users
+ * update a partition every time. The relational database will record the pointer of the partition
+ * statistics file.
Review Comment:
We use Json as the solution. The following words explain why not to choose other file formats.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2128111054
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
Review Comment:
But Integer and Double is defined in Java.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134990121
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
> It will depends `rel` module. Statistic shouldn't be bind to `rel` module.
It does not rely on the `rel` module, and the Gravitino type definitions are in the API module.
Is there any data type in statistics that cannot be covered by Gravitino Type? If not, reusing Gravitino Type can improve user experience with a unified interface.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2139052532
##########
api/src/main/java/org/apache/gravitino/stats/SupportsStatistics.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.exceptions.IllegalStatisticNameException;
+import org.apache.gravitino.exceptions.UnmodifiableStatisticException;
+import org.apache.gravitino.rel.expressions.literals.Literal;
+
+/**
+ * SupportsStatistics provides methods to list and update statistics. A table, a partition or a
+ * fileset can implement this interface to manage its statistics.
+ */
+@Evolving
+public interface SupportsStatistics {
+
+ /**
+ * Lists all statistics.
+ *
+ * @return a list of statistics
+ */
+ List<Statistic> listStatistics();
+
+ /**
+ * Updates statistics with the provided values. If the statistic exists, it will be updated with
+ * the new value. If the statistic does not exist, it will be created. If the provided statistic
+ * value is null and the statistic is custom, the statistic will be deleted. If the provided
+ * statistic value is null and the statistic is reserved, the statistic will set value null. If
+ * the statistic is unmodifiable, it will throw an UnmodifiableStatisticException. If the
+ * statistic name is illegal, it will throw an IllegalStatisticNameException.
+ *
+ * @param statistics a map of statistic names to their values
+ * @return a list of updated statistics
+ */
+ List<Statistic> updateStatistics(Map<String, Literal> statistics)
+ throws UnmodifiableStatisticException, IllegalStatisticNameException;
+}
Review Comment:
I seems more clear to add `dropStatistics`. I can add it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2139053686
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
Pros:
We can reuse the most of code. It will reduce rebundant code. Because `Literal` a similar concept to `StatisticValue`.
Cons:
The concept is coupled with rel module expression. It may increase the cost of user understanding.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2138338878
##########
api/src/main/java/org/apache/gravitino/stats/SupportsStatistics.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.exceptions.IllegalStatisticNameException;
+import org.apache.gravitino.exceptions.UnmodifiableStatisticException;
+import org.apache.gravitino.rel.expressions.literals.Literal;
+
+/**
+ * SupportsStatistics provides methods to list and update statistics. A table, a partition or a
+ * fileset can implement this interface to manage its statistics.
+ */
+@Evolving
+public interface SupportsStatistics {
+
+ /**
+ * Lists all statistics.
+ *
+ * @return a list of statistics
+ */
+ List<Statistic> listStatistics();
+
+ /**
+ * Updates statistics with the provided values. If the statistic exists, it will be updated with
+ * the new value. If the statistic does not exist, it will be created. If the provided statistic
+ * value is null and the statistic is custom, the statistic will be deleted. If the provided
+ * statistic value is null and the statistic is reserved, the statistic will set value null. If
+ * the statistic is unmodifiable, it will throw an UnmodifiableStatisticException. If the
+ * statistic name is illegal, it will throw an IllegalStatisticNameException.
+ *
+ * @param statistics a map of statistic names to their values
+ * @return a list of updated statistics
+ */
+ List<Statistic> updateStatistics(Map<String, Literal> statistics)
+ throws UnmodifiableStatisticException, IllegalStatisticNameException;
+}
Review Comment:
Do we need an interface to drop the statistics?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2177237192
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ */
+@Evolving
+public interface Statistic {
+
+ /** The prefix for custom statistics. Custom statistics are user-defined statistics. */
+ String CUSTOM_PREFIX = "custom.";
+
+ /**
+ * Get the name of the statistic.
+ *
+ * @return The name of the statistic.
+ */
+ String name();
+
+ /**
+ * Get the value of the statistic. The value is optional. If the statistic is not set, the value
+ * will be empty.
+ *
+ * @return An optional containing the value of the statistic if it is set, otherwise empty.
+ */
+ Optional<StatisticValue> value();
+
+ /**
+ * The statistic is predefined by Gravitino if the value is true. The statistic is defined by
+ * users if the value if false. For example, the statistic "row_count" is a reserved statistic, A
Review Comment:
`if the value is false`
##########
api/src/test/java/org/apache/gravitino/stats/TestStatisticValue.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.gravitino.stats;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.rel.types.Types;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestStatisticValue {
+
+ @Test
+ public void testLiterals() {
+ StatisticValues.BooleanValue booleanValue = StatisticValues.booleanValue(true);
+ Assertions.assertTrue(booleanValue.value());
+ Assertions.assertEquals(booleanValue.dataType(), Types.BooleanType.get());
Review Comment:
```
StatisticValues.BooleanValue b1 = StatisticValues.booleanValue(true);
StatisticValues.BooleanValue b2 = StatisticValues.booleanValue(true);
```
Will these two statistic values be equals?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2128109486
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
Review Comment:
For example, we can represent date.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2134985551
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
It's weird for fileset statistics to use `rel/type`. The statistic isn't only used for `table` and `partition`. May we need to add model statisitcs in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137268174
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
After offline discussion with @mchades , I will try to use `interal` to rewrite these interfaces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2137268174
##########
api/src/main/java/org/apache/gravitino/stats/StatisticValue.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.gravitino.stats;
+
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Represents a statistic value in statistics. The value can be of different types, such as Integer,
+ * Double, String, etc.
+ *
+ * @param <T> the type of the statistic value, which can be Long, Double, String, List, Map, or
+ * Boolean.
+ */
+@Evolving
+public interface StatisticValue<T> {
+
+ /**
+ * Returns the type of the statistic value.
+ *
+ * @return The type of the statistic value.
+ */
+ Type type();
+
+ /**
+ * Returns the actual value of the statistic.
+ *
+ * @return The actual value of the statistic.
+ */
+ T value();
+
+ /** Enumeration representing the different types of statistic values. */
+ enum Type {
+ /** Represents an integer value. */
+ LONG,
+ /** Represents a decimal value. */
+ DECIMAL,
+ /** Represents a string value. */
+ STRING,
+ /** Represents a list of statistic values. */
+ LIST,
+ /** Represents a map of statistic values. */
+ MAP,
+ /** Represents a boolean value. */
+ BOOLEAN
Review Comment:
After offline discussion with @mchades , I will try to use `Literal` to rewrite these interfaces.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2174347063
##########
api/src/main/java/org/apache/gravitino/stats/SupportsStatistics.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.gravitino.stats;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.exceptions.IllegalStatisticNameException;
+import org.apache.gravitino.exceptions.UnmodifiableStatisticException;
+
+/**
+ * SupportsStatistics provides methods to list and update statistics. A table, a partition or a
+ * fileset can implement this interface to manage its statistics.
+ */
+@Evolving
+public interface SupportsStatistics {
+
+ /**
+ * Lists all statistics.
+ *
+ * @return a list of statistics
+ */
+ List<Statistic> listStatistics();
+
+ /**
+ * Updates statistics with the provided values. If the statistic exists, it will be updated with
+ * the new value. If the statistic does not exist, it will be created. If the statistic is
+ * unmodifiable, it will throw an UnmodifiableStatisticException. If the statistic name is
+ * illegal, it will throw an IllegalStatisticNameException.
+ *
+ * @param statistics a map of statistic names to their values
+ * @return a list of updated statistics
+ */
+ List<Statistic> updateStatistics(Map<String, StatisticValue> statistics)
Review Comment:
I added the type to address the warning.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerqi (via GitHub)" <gi...@apache.org>.
jerqi commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2174347063
##########
api/src/main/java/org/apache/gravitino/stats/SupportsStatistics.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.gravitino.stats;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.annotation.Evolving;
+import org.apache.gravitino.exceptions.IllegalStatisticNameException;
+import org.apache.gravitino.exceptions.UnmodifiableStatisticException;
+
+/**
+ * SupportsStatistics provides methods to list and update statistics. A table, a partition or a
+ * fileset can implement this interface to manage its statistics.
+ */
+@Evolving
+public interface SupportsStatistics {
+
+ /**
+ * Lists all statistics.
+ *
+ * @return a list of statistics
+ */
+ List<Statistic> listStatistics();
+
+ /**
+ * Updates statistics with the provided values. If the statistic exists, it will be updated with
+ * the new value. If the statistic does not exist, it will be created. If the statistic is
+ * unmodifiable, it will throw an UnmodifiableStatisticException. If the statistic name is
+ * illegal, it will throw an IllegalStatisticNameException.
+ *
+ * @param statistics a map of statistic names to their values
+ * @return a list of updated statistics
+ */
+ List<Statistic> updateStatistics(Map<String, StatisticValue> statistics)
Review Comment:
I addressed the warning.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7332] feat(api): Support statistic interfaces [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #7333:
URL: https://github.com/apache/gravitino/pull/7333#discussion_r2165908753
##########
api/src/main/java/org/apache/gravitino/stats/Statistic.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.gravitino.stats;
+
+import java.util.Optional;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Statistic interface represents a statistic that can be associated with a metadata object. It can
+ * be used to store various types of statistics, for example, table statistics, partition
+ * statistics, fileset statistics, etc.
+ */
+@Evolving
+public interface Statistic {
+
+ /**
+ * Get the name of the statistic.
+ *
+ * @return The name of the statistic.
+ */
+ String name();
+
+ /**
+ * Get the value of the statistic. The value is optional. If the statistic is not set, the value
+ * will be empty.
+ *
+ * @return An optional containing the value of the statistic if it is set, otherwise empty.
+ */
+ Optional<StatisticValue> value();
+
+ /**
+ * The statistic is predefined by Gravitino if the value is true. The statistic is defined by
+ * users if the value if false. For example, the statistic "row_count" is a reserved statistic, A
+ * custom statistic name must start with "custom." prefix to avoid name conflict with reserved
Review Comment:
You'd better define a constant for "custom." here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org