forked from apache/paimon
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
338 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...core/src/main/java/org/apache/paimon/table/source/snapshot/CompactionFollowUpScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.paimon.table.source.snapshot; | ||
|
||
import org.apache.paimon.CoreOptions; | ||
import org.apache.paimon.Snapshot; | ||
import org.apache.paimon.table.source.ScanMode; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* {@link FollowUpScanner} for {@link CoreOptions.ChangelogProducer#FULL_COMPACTION} changelog | ||
* producer. | ||
*/ | ||
public class CompactionFollowUpScanner implements FollowUpScanner { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(CompactionFollowUpScanner.class); | ||
|
||
@Override | ||
public boolean shouldScanSnapshot(Snapshot snapshot) { | ||
if (snapshot.commitKind() == Snapshot.CommitKind.COMPACT) { | ||
return true; | ||
} | ||
|
||
LOG.debug( | ||
"Next snapshot id {} is not COMPACT, but is {}, check next one.", | ||
snapshot.id(), | ||
snapshot.commitKind()); | ||
return false; | ||
} | ||
|
||
@Override | ||
public SnapshotReader.Plan scan(Snapshot snapshot, SnapshotReader snapshotReader) { | ||
return snapshotReader.withMode(ScanMode.DELTA).withSnapshot(snapshot).readChanges(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...ain/java/org/apache/paimon/table/source/splitread/IncrementalCompactDiffReadProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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.paimon.table.source.splitread; | ||
|
||
import org.apache.paimon.Snapshot; | ||
import org.apache.paimon.data.InternalRow; | ||
import org.apache.paimon.operation.MergeFileSplitRead; | ||
import org.apache.paimon.operation.SplitRead; | ||
import org.apache.paimon.table.source.DataSplit; | ||
import org.apache.paimon.utils.LazyField; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
/** A {@link SplitReadProvider} to batch incremental diff read. */ | ||
public class IncrementalCompactDiffReadProvider implements SplitReadProvider { | ||
|
||
private final LazyField<SplitRead<InternalRow>> splitRead; | ||
|
||
public IncrementalCompactDiffReadProvider( | ||
Supplier<MergeFileSplitRead> supplier, | ||
Consumer<SplitRead<InternalRow>> valuesAssigner) { | ||
this.splitRead = | ||
new LazyField<>( | ||
() -> { | ||
SplitRead<InternalRow> read = create(supplier); | ||
valuesAssigner.accept(read); | ||
return read; | ||
}); | ||
} | ||
|
||
private SplitRead<InternalRow> create(Supplier<MergeFileSplitRead> supplier) { | ||
return new IncrementalCompactDiffSplitRead(supplier.get()); | ||
} | ||
|
||
@Override | ||
public boolean match(DataSplit split, boolean forceKeepDelete) { | ||
return split.commitKind() != null | ||
&& split.commitKind() == Snapshot.CommitKind.COMPACT | ||
&& !split.beforeFiles().isEmpty() | ||
&& split.isStreaming(); | ||
} | ||
|
||
@Override | ||
public boolean initialized() { | ||
return splitRead.initialized(); | ||
} | ||
|
||
@Override | ||
public SplitRead<InternalRow> getOrCreate() { | ||
return splitRead.get(); | ||
} | ||
} |
Oops, something went wrong.