You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ljz2051 (via GitHub)" <gi...@apache.org> on 2024/04/16 12:23:04 UTC
[PR] [FLINK-35125][state] Implement ValueState for ForStStateBackend [flink]
ljz2051 opened a new pull request, #24671:
URL: https://github.com/apache/flink/pull/24671
## What is the purpose of the change
This pull request implements the ValueState for ForStStateBackend.
## Brief change log
- Define the InternalSyncState interfaces in flink-runtime layer
- Implement ForStValueState
## Verifying this change
This change added tests and can be verified by ForStValueStateTest.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35125][state] Implement ValueState for ForStStateBackend [flink]
Posted by "ljz2051 (via GitHub)" <gi...@apache.org>.
ljz2051 closed pull request #24671: [FLINK-35125][state] Implement ValueState for ForStStateBackend
URL: https://github.com/apache/flink/pull/24671
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35125][state] Implement ValueState for ForStStateBackend [flink]
Posted by "fredia (via GitHub)" <gi...@apache.org>.
fredia commented on code in PR #24671:
URL: https://github.com/apache/flink/pull/24671#discussion_r1568129118
##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/InternalSyncState.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.v2;
+
+import org.apache.flink.annotation.Internal;
+
+import java.io.IOException;
+
+/**
+ * Internal state interface for the stateBackend layer, where state requests are executed
+ * synchronously. Unlike the user-facing state interface, {@code InternalSyncState}'s interfaces
+ * provide the key directly in the method signature, so there is no need to pass the keyContext
+ * information for these interfaces.
+ *
+ * @param <K> Type of the key in the state.
+ */
+@Internal
+public interface InternalSyncState<K> {
Review Comment:
`SyncState` is a little bit strange, I'm not sure if `InternalUnderlyingState` would be better, maybe we can seek other people’s opinions.
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/state/AbstractForStState.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.state.forst.state;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputDeserializer;
+import org.apache.flink.core.memory.DataOutputSerializer;
+import org.apache.flink.runtime.state.CompositeKeySerializationUtils;
+import org.apache.flink.runtime.state.KeyGroupRangeAssignment;
+import org.apache.flink.runtime.state.SerializedCompositeKeyBuilder;
+import org.apache.flink.runtime.state.v2.InternalSyncState;
+
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.WriteOptions;
+
+import java.io.IOException;
+
+/**
+ * Base class for {@link InternalSyncState} implementations that store state in a ForSt database.
+ *
+ * @param <K> Type of the key in the state.
+ * @param <V> Type of the value in the state.
+ */
+public class AbstractForStState<K, V> implements InternalSyncState<K> {
+
+ protected final RocksDB db;
+
+ protected final ColumnFamilyHandle columnFamily;
+
+ private final int maxParallelism;
+
+ protected final WriteOptions writeOptions;
+
+ protected final TypeSerializer<K> keySerializer;
Review Comment:
Is`namespaceSerializer` needed here?
##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/InternalSyncState.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.v2;
+
+import org.apache.flink.annotation.Internal;
+
+import java.io.IOException;
+
+/**
+ * Internal state interface for the stateBackend layer, where state requests are executed
+ * synchronously. Unlike the user-facing state interface, {@code InternalSyncState}'s interfaces
+ * provide the key directly in the method signature, so there is no need to pass the keyContext
+ * information for these interfaces.
+ *
+ * @param <K> Type of the key in the state.
+ */
+@Internal
+public interface InternalSyncState<K> {
+
+ /**
+ * Removes the value mapped under the given key.
+ *
+ * @param key The key to be deleted.
+ * @throws IOException Thrown when the performed I/O operation fails.
+ */
+ void clear(K key) throws IOException;
+
+ /**
+ * Indicates whether MultiGet API is supported.
+ *
+ * @return True if supported, false if not.
+ */
+ default boolean isSupportMultiGet() {
Review Comment:
IIUC, `InternalSyncState` is a high-level base interface for different state backend, `isSupportMultiGet()` seems to be bound to a specific implementation. I think `supportBatchGet/supportBatchPut` may be better, WDYT?
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/state/AbstractForStState.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.state.forst.state;
+
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.core.memory.DataInputDeserializer;
+import org.apache.flink.core.memory.DataOutputSerializer;
+import org.apache.flink.runtime.state.CompositeKeySerializationUtils;
+import org.apache.flink.runtime.state.KeyGroupRangeAssignment;
+import org.apache.flink.runtime.state.SerializedCompositeKeyBuilder;
+import org.apache.flink.runtime.state.v2.InternalSyncState;
+
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.rocksdb.WriteOptions;
+
+import java.io.IOException;
+
+/**
+ * Base class for {@link InternalSyncState} implementations that store state in a ForSt database.
+ *
+ * @param <K> Type of the key in the state.
+ * @param <V> Type of the value in the state.
+ */
+public class AbstractForStState<K, V> implements InternalSyncState<K> {
+
+ protected final RocksDB db;
+
+ protected final ColumnFamilyHandle columnFamily;
+
+ private final int maxParallelism;
+
+ protected final WriteOptions writeOptions;
+
+ protected final TypeSerializer<K> keySerializer;
+
+ protected final TypeSerializer<V> valueSerializer;
+
+ private final ThreadLocal<SerializedCompositeKeyBuilder<K>> serializedKeyBuilder;
Review Comment:
Will `serializedKeyBuilder` be accessed concurrently? How about adding some comments about `ThreadLocal`?
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35125][state] Implement ValueState for ForStStateBackend [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #24671:
URL: https://github.com/apache/flink/pull/24671#issuecomment-2058974205
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "f4b1a4374cc6c579ff50e5b09bb5715b386645d2",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "f4b1a4374cc6c579ff50e5b09bb5715b386645d2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* f4b1a4374cc6c579ff50e5b09bb5715b386645d2 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org