xtern commented on code in PR #6563: URL: https://github.com/apache/ignite-3/pull/6563#discussion_r2343063936
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PartitionModificationCounterFactory.java: ########## @@ -0,0 +1,52 @@ +/* + * 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.ignite.internal.table.distributed; + +import java.util.function.LongSupplier; +import java.util.function.Supplier; +import org.apache.ignite.internal.hlc.HybridTimestamp; + +/** + * Factory for producing {@link PartitionModificationCounter}. + */ +public class PartitionModificationCounterFactory { + public static final long DEFAULT_MIN_STALE_ROWS_COUNT = 500L; Review Comment: Yes, they will be in `sql.statistics.` configuration, but we decided to add configuration a little bit later ########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/PartitionModificationCounter.java: ########## @@ -0,0 +1,111 @@ +/* + * 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.ignite.internal.table.distributed; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.LongSupplier; +import org.apache.ignite.internal.hlc.HybridTimestamp; + +/** + * Keeps track of the number of modifications of a partition. + * + * <p>When the configured threshold value of the number of modifications is reached, a timestamp corresponding + * to the commit time of the transaction that made this update is stored in {@link #lastMilestoneReachedTimestamp}. + * + * <p>The timestamp value is used to determine the staleness of related SQL statistics. + */ +public class PartitionModificationCounter { + private final LongSupplier partitionSizeSupplier; + private final double staleRowsFraction; + private final long minStaleRowsCount; + + private final AtomicLong counter = new AtomicLong(0); + private volatile long nextMilestone; + private volatile HybridTimestamp lastMilestoneReachedTimestamp; + + /** Constructor. */ + public PartitionModificationCounter( + HybridTimestamp initTimestamp, + LongSupplier partitionSizeSupplier, + double staleRowsFraction, + long minStaleRowsCount + ) { + assert staleRowsFraction >= 0 && staleRowsFraction <= 1 : "staleRowsFraction must be in [0, 1] range."; Review Comment: Done -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
