You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/12 12:27:45 UTC
[GitHub] [flink-table-store] tsreaper opened a new pull request, #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
tsreaper opened a new pull request, #433:
URL: https://github.com/apache/flink-table-store/pull/433
In this ticket we refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store. The old ALTER TABLE COMPACT will also be disabled in this ticket due to various restrictions.
--
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
[GitHub] [flink-table-store] tsreaper merged pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
tsreaper merged PR #433:
URL: https://github.com/apache/flink-table-store/pull/433
--
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
[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #433:
URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046674425
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreCompactOperator.java:
##########
@@ -18,99 +18,70 @@
package org.apache.flink.table.store.connector.sink;
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.table.data.RowData;
import org.apache.flink.table.data.binary.BinaryRowData;
-import org.apache.flink.table.store.file.predicate.PredicateConverter;
-import org.apache.flink.table.store.file.utils.FileStorePathFactory;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.store.CoreOptions;
+import org.apache.flink.table.store.file.utils.OffsetRowData;
import org.apache.flink.table.store.table.FileStoreTable;
-import org.apache.flink.table.store.table.sink.TableWrite;
-import org.apache.flink.table.store.table.source.DataSplit;
-import org.apache.flink.table.store.table.source.Split;
-import org.apache.flink.table.store.table.source.TableScan;
-import org.apache.flink.table.types.logical.RowType;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
+import org.apache.flink.util.Preconditions;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
/** A dedicated operator for manual triggered compaction. */
public class StoreCompactOperator extends PrepareCommitOperator {
- private static final Logger LOG = LoggerFactory.getLogger(StoreCompactOperator.class);
-
private final FileStoreTable table;
- private final String commitUser;
- @Nullable private final Map<String, String> compactPartitionSpec;
+ private final StoreSinkWrite.Provider storeSinkWriteProvider;
+ private final boolean isStreaming;
- private TableScan scan;
- private TableWrite write;
+ private transient StoreSinkWrite write;
+ private transient RowDataSerializer partitionSerializer;
+ private transient OffsetRowData reusedPartition;
public StoreCompactOperator(
FileStoreTable table,
- String commitUser,
- @Nullable Map<String, String> compactPartitionSpec) {
+ StoreSinkWrite.Provider storeSinkWriteProvider,
+ boolean isStreaming) {
+ Preconditions.checkArgument(
Review Comment:
Does this expected? The user manually starts a compaction job. Does user need to set the option?
--
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
[GitHub] [flink-table-store] tsreaper commented on a diff in pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
tsreaper commented on code in PR #433:
URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046796807
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreSinkWriteImpl.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.table.store.connector.sink;
+
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.runtime.state.StateSnapshotContext;
+import org.apache.flink.table.data.binary.BinaryRowData;
+import org.apache.flink.table.store.table.FileStoreTable;
+import org.apache.flink.table.store.table.sink.FileCommittable;
+import org.apache.flink.table.store.table.sink.TableWrite;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/** Default implementation of {@link StoreSinkWrite}. This writer does not have states. */
+public class StoreSinkWriteImpl implements StoreSinkWrite {
+
+ protected final FileStoreTable table;
+ protected final String commitUser;
+ protected final TableWrite write;
+
+ public StoreSinkWriteImpl(
+ StateInitializationContext context, FileStoreTable table, String initialCommitUser)
+ throws Exception {
+ this.table = table;
+
+ // each job can only have one user name and this name must be consistent across restarts
+ // we cannot use job id as commit user name here because user may change job id by creating
+ // a savepoint, stop the job and then resume from savepoint
+ commitUser =
+ StateUtils.getSingleValueFromState(
+ context, "commit_user_state", String.class, initialCommitUser);
+
+ // see comments of StateUtils.getSingleValueFromState for why commitUser may be null
+ if (commitUser == null) {
+ write = null;
Review Comment:
More comments added.
--
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
[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #433:
URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046673855
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreCompactOperator.java:
##########
@@ -18,99 +18,70 @@
package org.apache.flink.table.store.connector.sink;
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.table.data.RowData;
import org.apache.flink.table.data.binary.BinaryRowData;
-import org.apache.flink.table.store.file.predicate.PredicateConverter;
-import org.apache.flink.table.store.file.utils.FileStorePathFactory;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.store.CoreOptions;
+import org.apache.flink.table.store.file.utils.OffsetRowData;
import org.apache.flink.table.store.table.FileStoreTable;
-import org.apache.flink.table.store.table.sink.TableWrite;
-import org.apache.flink.table.store.table.source.DataSplit;
-import org.apache.flink.table.store.table.source.Split;
-import org.apache.flink.table.store.table.source.TableScan;
-import org.apache.flink.table.types.logical.RowType;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
+import org.apache.flink.util.Preconditions;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
/** A dedicated operator for manual triggered compaction. */
Review Comment:
Add comments: Records from where.
--
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
[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #433:
URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046652886
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreSinkWrite.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.table.store.connector.sink;
+
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.runtime.state.StateSnapshotContext;
+import org.apache.flink.table.data.binary.BinaryRowData;
+import org.apache.flink.table.store.table.FileStoreTable;
+import org.apache.flink.table.store.table.sink.TableWrite;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.List;
+
+/** Helper class of {@link StoreWriteOperator} for different types of table store sinks. */
+interface StoreSinkWrite {
+
+ @Nullable
+ TableWrite getTableWrite();
+
+ void touchBucket(BinaryRowData partition, int bucket);
Review Comment:
Can we just provide:
```
SinkRecord write(RowData rowData) throws Exception;
void compact(BinaryRowData partition, int bucket, boolean fullCompaction) throws Exception;
```
We don't need this `touchBucket`. `IOManager` and `Overwrite` can be prepared in `Provider.provide`.
--
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
[GitHub] [flink-table-store] JingsongLi commented on a diff in pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
JingsongLi commented on code in PR #433:
URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046677047
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreSinkWriteImpl.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.table.store.connector.sink;
+
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.runtime.state.StateSnapshotContext;
+import org.apache.flink.table.data.binary.BinaryRowData;
+import org.apache.flink.table.store.table.FileStoreTable;
+import org.apache.flink.table.store.table.sink.FileCommittable;
+import org.apache.flink.table.store.table.sink.TableWrite;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/** Default implementation of {@link StoreSinkWrite}. This writer does not have states. */
+public class StoreSinkWriteImpl implements StoreSinkWrite {
+
+ protected final FileStoreTable table;
+ protected final String commitUser;
+ protected final TableWrite write;
+
+ public StoreSinkWriteImpl(
+ StateInitializationContext context, FileStoreTable table, String initialCommitUser)
+ throws Exception {
+ this.table = table;
+
+ // each job can only have one user name and this name must be consistent across restarts
+ // we cannot use job id as commit user name here because user may change job id by creating
+ // a savepoint, stop the job and then resume from savepoint
+ commitUser =
+ StateUtils.getSingleValueFromState(
+ context, "commit_user_state", String.class, initialCommitUser);
+
+ // see comments of StateUtils.getSingleValueFromState for why commitUser may be null
+ if (commitUser == null) {
+ write = null;
Review Comment:
if the write is null, What happens next?
--
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
[GitHub] [flink-table-store] tsreaper commented on a diff in pull request #433: [FLINK-30210] Refactor StoreCompactOperator to accept records containing partitions and buckets in Table Store
Posted by GitBox <gi...@apache.org>.
tsreaper commented on code in PR #433:
URL: https://github.com/apache/flink-table-store/pull/433#discussion_r1046746710
##########
flink-table-store-connector/src/main/java/org/apache/flink/table/store/connector/sink/StoreCompactOperator.java:
##########
@@ -18,99 +18,70 @@
package org.apache.flink.table.store.connector.sink;
+import org.apache.flink.runtime.state.StateInitializationContext;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.table.data.RowData;
import org.apache.flink.table.data.binary.BinaryRowData;
-import org.apache.flink.table.store.file.predicate.PredicateConverter;
-import org.apache.flink.table.store.file.utils.FileStorePathFactory;
+import org.apache.flink.table.runtime.typeutils.RowDataSerializer;
+import org.apache.flink.table.store.CoreOptions;
+import org.apache.flink.table.store.file.utils.OffsetRowData;
import org.apache.flink.table.store.table.FileStoreTable;
-import org.apache.flink.table.store.table.sink.TableWrite;
-import org.apache.flink.table.store.table.source.DataSplit;
-import org.apache.flink.table.store.table.source.Split;
-import org.apache.flink.table.store.table.source.TableScan;
-import org.apache.flink.table.types.logical.RowType;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.Nullable;
+import org.apache.flink.util.Preconditions;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
/** A dedicated operator for manual triggered compaction. */
public class StoreCompactOperator extends PrepareCommitOperator {
- private static final Logger LOG = LoggerFactory.getLogger(StoreCompactOperator.class);
-
private final FileStoreTable table;
- private final String commitUser;
- @Nullable private final Map<String, String> compactPartitionSpec;
+ private final StoreSinkWrite.Provider storeSinkWriteProvider;
+ private final boolean isStreaming;
- private TableScan scan;
- private TableWrite write;
+ private transient StoreSinkWrite write;
+ private transient RowDataSerializer partitionSerializer;
+ private transient OffsetRowData reusedPartition;
public StoreCompactOperator(
FileStoreTable table,
- String commitUser,
- @Nullable Map<String, String> compactPartitionSpec) {
+ StoreSinkWrite.Provider storeSinkWriteProvider,
+ boolean isStreaming) {
+ Preconditions.checkArgument(
Review Comment:
We'll introduce a `TableStoreCompactJob` so user can submit this job class to Flink. This job class will disable "write.compaction-skip" so user does not need to care about it.
This `checkArgument` is just for sanity check.
--
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