masteryhx commented on code in PR #21835:
URL: https://github.com/apache/flink/pull/21835#discussion_r1128940896


##########
flink-core/src/main/java/org/apache/flink/api/common/state/StateTtlConfig.java:
##########
@@ -298,12 +298,40 @@ public Builder cleanupInRocksdbCompactFilter(long 
queryTimeAfterNumEntries) {
             return this;
         }
 
+        /**
+         * Cleanup expired state while Rocksdb compaction is running.
+         *
+         * <p>RocksDB compaction filter will query current timestamp, used to 
check expiration, from
+         * Flink every time after processing {@code queryTimeAfterNumEntries} 
number of state
+         * entries. Updating the timestamp more often can improve cleanup 
speed but it decreases
+         * compaction performance because it uses JNI call from native code.
+         *
+         * <p>Periodic compaction could speed up expired state entries 
cleanup, especially for state
+         * entries rarely accessed. Files older than this value will be picked 
up for compaction,
+         * and re-written to the same level as they were before. It makes sure 
a file goes through
+         * compaction filters periodically.
+         *
+         * @param queryTimeAfterNumEntries number of state entries to process 
by compaction filter
+         *     before updating current timestamp
+         * @param periodicCompactionSeconds periodic compaction per seconds 
which could speed up
+         *     expired state cleanup. 0 means turning off periodic compaction.
+         */
+        @Nonnull
+        public Builder cleanupInRocksdbCompactFilter(
+                long queryTimeAfterNumEntries, long periodicCompactionSeconds) 
{

Review Comment:
   Sorry for the delayed update due to my personal business last month.
   Thanks for the suggestion. I replaced `long` with `Time` which is also the 
type of TTL.



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to