-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[compact]support compact unaware bucket for combine_mode #2858
Merged
leaves12138
merged 9 commits into
apache:master
from
wg1026688210:compaction/support_unaware_mode
May 16, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6e0dd45
support specify database and table for AppendOnlyCompactionTask
wg1026688210 d17dd29
add MultiTableAppendOnlyCompactionTask
wg1026688210 1120779
refactor unaware bucket compaction work operator
wg1026688210 40bd9c5
add unaware bucket compaction worker
wg1026688210 ec37857
check style
wg1026688210 50ceefb
refact the scan logic of combined mode compaction to reuse the logic …
wg1026688210 721b4a4
remove jbrain code
wg1026688210 050be0e
rebase
wg1026688210 fafc6b0
improve
wg1026688210 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
62 changes: 62 additions & 0 deletions
62
paimon-core/src/main/java/org/apache/paimon/append/MultiTableAppendOnlyCompactionTask.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,62 @@ | ||
/* | ||
* 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.append; | ||
|
||
import org.apache.paimon.catalog.Identifier; | ||
import org.apache.paimon.data.BinaryRow; | ||
import org.apache.paimon.io.DataFileMeta; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** Compaction task for multi table . */ | ||
public class MultiTableAppendOnlyCompactionTask extends AppendOnlyCompactionTask { | ||
|
||
private final Identifier tableIdentifier; | ||
|
||
public MultiTableAppendOnlyCompactionTask( | ||
BinaryRow partition, List<DataFileMeta> files, Identifier identifier) { | ||
super(partition, files); | ||
this.tableIdentifier = identifier; | ||
} | ||
|
||
public Identifier tableIdentifier() { | ||
return tableIdentifier; | ||
} | ||
|
||
public int hashCode() { | ||
return Objects.hash(partition(), compactBefore(), compactAfter(), tableIdentifier); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
MultiTableAppendOnlyCompactionTask that = (MultiTableAppendOnlyCompactionTask) o; | ||
return Objects.equals(partition(), that.partition()) | ||
&& Objects.equals(compactBefore(), that.compactBefore()) | ||
&& Objects.equals(compactAfter(), that.compactAfter()) | ||
&& Objects.equals(tableIdentifier, that.tableIdentifier); | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
paimon-core/src/main/java/org/apache/paimon/io/IdentifierSerializer.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,47 @@ | ||
/* | ||
* 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.io; | ||
|
||
import org.apache.paimon.catalog.Identifier; | ||
import org.apache.paimon.data.BinaryString; | ||
import org.apache.paimon.data.GenericRow; | ||
import org.apache.paimon.data.InternalRow; | ||
import org.apache.paimon.utils.ObjectSerializer; | ||
|
||
/** Serializer for {@link Identifier}. */ | ||
public class IdentifierSerializer extends ObjectSerializer<Identifier> { | ||
|
||
public IdentifierSerializer() { | ||
super(Identifier.schema()); | ||
} | ||
|
||
@Override | ||
public InternalRow toRow(Identifier record) { | ||
return GenericRow.of( | ||
BinaryString.fromString(record.getDatabaseName()), | ||
BinaryString.fromString(record.getObjectName())); | ||
} | ||
|
||
@Override | ||
public Identifier fromRow(InternalRow rowData) { | ||
String databaseName = rowData.isNullAt(0) ? null : rowData.getString(0).toString(); | ||
String tableName = rowData.isNullAt(1) ? null : rowData.getString(1).toString(); | ||
return Identifier.create(databaseName, tableName); | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
...n-core/src/main/java/org/apache/paimon/table/sink/MultiTableCompactionTaskSerializer.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,118 @@ | ||
/* | ||
* 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.sink; | ||
|
||
import org.apache.paimon.append.MultiTableAppendOnlyCompactionTask; | ||
import org.apache.paimon.data.serializer.VersionedSerializer; | ||
import org.apache.paimon.io.DataFileMetaSerializer; | ||
import org.apache.paimon.io.DataInputDeserializer; | ||
import org.apache.paimon.io.DataInputView; | ||
import org.apache.paimon.io.DataOutputView; | ||
import org.apache.paimon.io.DataOutputViewStreamWrapper; | ||
import org.apache.paimon.io.IdentifierSerializer; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.apache.paimon.utils.SerializationUtils.deserializeBinaryRow; | ||
import static org.apache.paimon.utils.SerializationUtils.serializeBinaryRow; | ||
|
||
/** Serializer for {@link MultiTableAppendOnlyCompactionTask}. */ | ||
public class MultiTableCompactionTaskSerializer | ||
implements VersionedSerializer<MultiTableAppendOnlyCompactionTask> { | ||
|
||
private static final int CURRENT_VERSION = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line feed |
||
|
||
private final DataFileMetaSerializer dataFileSerializer; | ||
|
||
private final IdentifierSerializer identifierSerializer; | ||
|
||
public MultiTableCompactionTaskSerializer() { | ||
this.dataFileSerializer = new DataFileMetaSerializer(); | ||
this.identifierSerializer = new IdentifierSerializer(); | ||
} | ||
|
||
@Override | ||
public int getVersion() { | ||
return CURRENT_VERSION; | ||
} | ||
|
||
@Override | ||
public byte[] serialize(MultiTableAppendOnlyCompactionTask task) throws IOException { | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
DataOutputViewStreamWrapper view = new DataOutputViewStreamWrapper(out); | ||
serialize(task, view); | ||
return out.toByteArray(); | ||
} | ||
|
||
private void serialize(MultiTableAppendOnlyCompactionTask task, DataOutputView view) | ||
throws IOException { | ||
serializeBinaryRow(task.partition(), view); | ||
dataFileSerializer.serializeList(task.compactBefore(), view); | ||
identifierSerializer.serialize(task.tableIdentifier(), view); | ||
} | ||
|
||
@Override | ||
public MultiTableAppendOnlyCompactionTask deserialize(int version, byte[] serialized) | ||
throws IOException { | ||
checkVersion(version); | ||
DataInputDeserializer view = new DataInputDeserializer(serialized); | ||
return deserialize(view); | ||
} | ||
|
||
private MultiTableAppendOnlyCompactionTask deserialize(DataInputView view) throws IOException { | ||
return new MultiTableAppendOnlyCompactionTask( | ||
deserializeBinaryRow(view), | ||
dataFileSerializer.deserializeList(view), | ||
identifierSerializer.deserialize(view)); | ||
} | ||
|
||
public List<MultiTableAppendOnlyCompactionTask> deserializeList(int version, DataInputView view) | ||
throws IOException { | ||
checkVersion(version); | ||
int length = view.readInt(); | ||
List<MultiTableAppendOnlyCompactionTask> list = new ArrayList<>(length); | ||
for (int i = 0; i < length; i++) { | ||
list.add(deserialize(view)); | ||
} | ||
return list; | ||
} | ||
|
||
public void serializeList(List<MultiTableAppendOnlyCompactionTask> list, DataOutputView view) | ||
throws IOException { | ||
view.writeInt(list.size()); | ||
for (MultiTableAppendOnlyCompactionTask commitMessage : list) { | ||
serialize(commitMessage, view); | ||
} | ||
} | ||
|
||
private void checkVersion(int version) { | ||
if (version != CURRENT_VERSION) { | ||
throw new UnsupportedOperationException( | ||
"Expecting MultiTableCompactionTaskSerializer version to be " | ||
+ CURRENT_VERSION | ||
+ ", but found " | ||
+ version | ||
+ ".\nCompactionTask is not a compatible data structure. " | ||
+ "Please restart the job afresh (do not recover from savepoint)."); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line feed