You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/08/01 12:38:02 UTC

[jira] [Commented] (FLINK-9938) State TTL cleanup during full state scan upon checkpointing

    [ https://issues.apache.org/jira/browse/FLINK-9938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16565221#comment-16565221 ] 

ASF GitHub Bot commented on FLINK-9938:
---------------------------------------

StefanRRichter commented on a change in pull request #6460: [FLINK-9938] Clean up full snapshot from expired state with TTL
URL: https://github.com/apache/flink/pull/6460#discussion_r206813225
 
 

 ##########
 File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/StateSnapshotFilter.java
 ##########
 @@ -0,0 +1,74 @@
+/*
+ * 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.flink.runtime.state;
+
+import javax.annotation.Nonnull;
+
+import java.util.Optional;
+
+/**
+ * Filter of snapshot state values.
+ *
+ * <p>This filter can be applied to state values
+ * to decide which entries should be included into the snapshot (can be modified before),
+ * others should be dropped (returns {@code Optional.empty()}).
+ */
+public interface StateSnapshotFilter<T> {
+	StateSnapshotFilter<?> SNAPSHOT_ALL = createSnapshotAll();
+
+	@SuppressWarnings("unchecked")
+	@Nonnull
+	static <T> StateSnapshotFilter<T> snapshotAll() {
+		return (StateSnapshotFilter<T>) SNAPSHOT_ALL;
+	}
+
+	static <T> StateSnapshotFilter<T> createSnapshotAll() {
+		return new StateSnapshotFilter<T>() {
+			@Override
+			@Nonnull
+			public Optional<T> filter(@Nonnull T value) {
+				return Optional.of(value);
+			}
+
+			@Override
+			@Nonnull
+			public Optional<byte[]> filterSerialized(@Nonnull byte[] value) {
+				return Optional.of(value);
+			}
+		};
+	}
+
+	/**
+	 * Filter by non-serialized form of value.
+	 *
+	 * @param value non-serialized form of value
+	 * @return Optional.of(value to snapshot) or Optional.empty() to drop
+	 */
+	@Nonnull
+	Optional<T> filter(@Nonnull T value);
 
 Review comment:
   What is the benefit of having an `Optional` here? I think the it gives not added value over making this simply `@Nullable`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> State TTL cleanup during full state scan upon checkpointing
> -----------------------------------------------------------
>
>                 Key: FLINK-9938
>                 URL: https://issues.apache.org/jira/browse/FLINK-9938
>             Project: Flink
>          Issue Type: Improvement
>          Components: State Backends, Checkpointing
>    Affects Versions: 1.6.0
>            Reporter: Andrey Zagrebin
>            Assignee: Andrey Zagrebin
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.6.0
>
>
> We can try to piggyback full state scan during certain checkpoint processes in backends, check TTL expiration for every entry and evict expired to speed up cleanup.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)