-
Notifications
You must be signed in to change notification settings - Fork 988
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
[core] Introduce data-file.thin-mode in primary key table write #4666
Merged
Merged
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
7f0442e
[core] Write thin mode
7461d43
fix comment
b1aa915
fix comment
5ddc7ac
fix comment
6272678
fix comment
068824b
fix comment
29f9056
fix comment
2cf0a0d
fix comment
ddca0f9
fix comment
1adbe5c
fix comment
d10a3b2
fix comment
df6c353
fix comment
e019053
fix comment
51e9da8
fix comment
52b1601
fix comment
fe09553
fix comment
4124716
fix comment
d796980
fix comment
23a2637
fix comment
b6bf207
fix comment
03c6621
fix comment
52c448f
fix comment
24d9828
fix comment
cae6c75
comment
ceb989b
[core] Retry if snapshot commit hint failed.
52808db
fix comment
93a77bf
comment
952b3a5
fix comment
8269a41
fix comment
04e6ea0
fix comment
78ac5db
fix comment
a3b68b2
comment
cf626f8
fix comment
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
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
58 changes: 58 additions & 0 deletions
58
paimon-core/src/main/java/org/apache/paimon/KeyValueThinSerializer.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,58 @@ | ||
/* | ||
* 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; | ||
|
||
import org.apache.paimon.data.GenericRow; | ||
import org.apache.paimon.data.InternalRow; | ||
import org.apache.paimon.data.JoinedRow; | ||
import org.apache.paimon.types.RowKind; | ||
import org.apache.paimon.types.RowType; | ||
import org.apache.paimon.utils.ObjectSerializer; | ||
|
||
/** Serialize KeyValue to InternalRow with ignorance of key. Only used to write KeyValue to disk. */ | ||
public class KeyValueThinSerializer extends ObjectSerializer<KeyValue> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final GenericRow reusedMeta; | ||
private final JoinedRow reusedKeyWithMeta; | ||
|
||
public KeyValueThinSerializer(RowType keyType, RowType valueType) { | ||
super(KeyValue.schema(keyType, valueType)); | ||
|
||
this.reusedMeta = new GenericRow(2); | ||
this.reusedKeyWithMeta = new JoinedRow(); | ||
} | ||
|
||
public InternalRow toRow(KeyValue record) { | ||
return toRow(record.sequenceNumber(), record.valueKind(), record.value()); | ||
} | ||
|
||
public InternalRow toRow(long sequenceNumber, RowKind valueKind, InternalRow value) { | ||
reusedMeta.setField(0, sequenceNumber); | ||
reusedMeta.setField(1, valueKind.toByteValue()); | ||
return reusedKeyWithMeta.replace(reusedMeta, value); | ||
} | ||
|
||
@Override | ||
public KeyValue fromRow(InternalRow row) { | ||
throw new UnsupportedOperationException( | ||
"KeyValue cannot be deserialized from InternalRow by this serializer."); | ||
} | ||
} |
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
80 changes: 80 additions & 0 deletions
80
paimon-core/src/main/java/org/apache/paimon/io/KeyValueDataFileWriterImpl.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,80 @@ | ||
/* | ||
* 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.CoreOptions; | ||
import org.apache.paimon.KeyValue; | ||
import org.apache.paimon.data.InternalRow; | ||
import org.apache.paimon.fileindex.FileIndexOptions; | ||
import org.apache.paimon.format.FormatWriterFactory; | ||
import org.apache.paimon.format.SimpleColStats; | ||
import org.apache.paimon.format.SimpleStatsExtractor; | ||
import org.apache.paimon.fs.FileIO; | ||
import org.apache.paimon.fs.Path; | ||
import org.apache.paimon.manifest.FileSource; | ||
import org.apache.paimon.types.RowType; | ||
import org.apache.paimon.utils.Pair; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import java.util.Arrays; | ||
import java.util.function.Function; | ||
|
||
/** Write data files containing {@link KeyValue}s. */ | ||
public class KeyValueDataFileWriterImpl extends KeyValueDataFileWriter { | ||
|
||
public KeyValueDataFileWriterImpl( | ||
FileIO fileIO, | ||
FormatWriterFactory factory, | ||
Path path, | ||
Function<KeyValue, InternalRow> converter, | ||
RowType keyType, | ||
RowType valueType, | ||
@Nullable SimpleStatsExtractor simpleStatsExtractor, | ||
long schemaId, | ||
int level, | ||
String compression, | ||
CoreOptions options, | ||
FileSource fileSource, | ||
FileIndexOptions fileIndexOptions) { | ||
super( | ||
fileIO, | ||
factory, | ||
path, | ||
converter, | ||
keyType, | ||
valueType, | ||
KeyValue.schema(keyType, valueType), | ||
simpleStatsExtractor, | ||
schemaId, | ||
level, | ||
compression, | ||
options, | ||
fileSource, | ||
fileIndexOptions); | ||
} | ||
|
||
@Override | ||
Pair<SimpleColStats[], SimpleColStats[]> fetchKeyValueStats(SimpleColStats[] rowStats) { | ||
int numKeyFields = keyType.getFieldCount(); | ||
return Pair.of( | ||
Arrays.copyOfRange(rowStats, 0, numKeyFields), | ||
Arrays.copyOfRange(rowStats, numKeyFields + 2, rowStats.length)); | ||
} | ||
} |
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.
Suggest add a comment here.
record.key() is not write into row
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.
Already comment before class definition.