Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InsertOnly behavior for CDC and deduplication scenarios #4294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ public void sync() throws Exception {

@Override
public void withInsertOnly(boolean insertOnly) {
if (this.isInsertOnly == insertOnly) {
return;
}
if (insertOnly && writeBuffer != null && writeBuffer.size() > 0) {
throw new IllegalStateException(
"Insert-only can only be set before any record is received.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class StoreSinkWriteImpl implements StoreSinkWrite {

@Nullable private final MetricGroup metricGroup;

@Nullable private Boolean lastInsertOnly;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insertOnly


public StoreSinkWriteImpl(
FileStoreTable table,
String commitUser,
Expand Down Expand Up @@ -154,15 +156,21 @@ private TableWriteImpl<?> newTableWrite(FileStoreTable table) {
}

if (memoryPoolFactory != null) {
return tableWrite.withMemoryPoolFactory(memoryPoolFactory);
tableWrite.withMemoryPoolFactory(memoryPoolFactory);
} else {
return tableWrite.withMemoryPool(
tableWrite.withMemoryPool(
memoryPool != null
? memoryPool
: new HeapMemorySegmentPool(
table.coreOptions().writeBufferSize(),
table.coreOptions().pageSize()));
}

if (lastInsertOnly != null) {
tableWrite.withInsertOnly(lastInsertOnly);
}

return tableWrite;
}

public void withCompactExecutor(ExecutorService compactExecutor) {
Expand All @@ -171,6 +179,7 @@ public void withCompactExecutor(ExecutorService compactExecutor) {

@Override
public void withInsertOnly(boolean insertOnly) {
this.lastInsertOnly = insertOnly;
write.withInsertOnly(insertOnly);
}

Expand Down
Loading