-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WIP][format] Add paimon-mosaic module with reader and writer #7917
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
Open
JingsongLi
wants to merge
11
commits into
apache:master
Choose a base branch
from
JingsongLi:mosaic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6bf7f8e
[format] Add paimon-mosaic-format module with reader, writer, stats e…
JingsongLi 9bd655f
[format] Address review comments for paimon-mosaic-format
JingsongLi 35d3476
Fix comments
JingsongLi 7cd4579
fix
JingsongLi a7a7bea
fix
JingsongLi 9ae2aa0
fix with new API
JingsongLi ca344ff
fix
JingsongLi 9a2ef63
fix
JingsongLi 83bb48f
fix
JingsongLi fe157b5
fix
JingsongLi 9e1d737
vectoredReadable
JingsongLi 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 hidden or 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,86 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| 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. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <artifactId>paimon-parent</artifactId> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <version>1.5-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>paimon-mosaic</artifactId> | ||
| <name>Paimon : Mosaic Format</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>mosaic</artifactId> | ||
| <version>0.1.0-SNAPSHOT</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>paimon-arrow</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>paimon-common</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>paimon-core</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <!-- test dependencies --> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>paimon-common</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>test-jar</type> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>paimon-test-utils</artifactId> | ||
| <version>${project.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.apache.paimon</groupId> | ||
| <artifactId>paimon-core</artifactId> | ||
| <version>${project.version}</version> | ||
| <type>test-jar</type> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
238 changes: 238 additions & 0 deletions
238
paimon-mosaic/src/main/java/org/apache/paimon/format/mosaic/MosaicFileFormat.java
This file contains hidden or 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,238 @@ | ||
| /* | ||
| * 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.format.mosaic; | ||
|
|
||
| import org.apache.paimon.format.FileFormat; | ||
| import org.apache.paimon.format.FileFormatFactory; | ||
| import org.apache.paimon.format.FormatReaderFactory; | ||
| import org.apache.paimon.format.FormatWriterFactory; | ||
| import org.apache.paimon.format.SimpleStatsExtractor; | ||
| import org.apache.paimon.options.ConfigOption; | ||
| import org.apache.paimon.options.ConfigOptions; | ||
| import org.apache.paimon.predicate.Predicate; | ||
| import org.apache.paimon.statistics.SimpleColStatsCollector; | ||
| import org.apache.paimon.types.ArrayType; | ||
| import org.apache.paimon.types.BigIntType; | ||
| import org.apache.paimon.types.BinaryType; | ||
| import org.apache.paimon.types.BlobType; | ||
| import org.apache.paimon.types.BooleanType; | ||
| import org.apache.paimon.types.CharType; | ||
| import org.apache.paimon.types.DataType; | ||
| import org.apache.paimon.types.DataTypeVisitor; | ||
| import org.apache.paimon.types.DateType; | ||
| import org.apache.paimon.types.DecimalType; | ||
| import org.apache.paimon.types.DoubleType; | ||
| import org.apache.paimon.types.FloatType; | ||
| import org.apache.paimon.types.IntType; | ||
| import org.apache.paimon.types.LocalZonedTimestampType; | ||
| import org.apache.paimon.types.MapType; | ||
| import org.apache.paimon.types.MultisetType; | ||
| import org.apache.paimon.types.RowType; | ||
| import org.apache.paimon.types.SmallIntType; | ||
| import org.apache.paimon.types.TimeType; | ||
| import org.apache.paimon.types.TimestampType; | ||
| import org.apache.paimon.types.TinyIntType; | ||
| import org.apache.paimon.types.VarBinaryType; | ||
| import org.apache.paimon.types.VarCharType; | ||
| import org.apache.paimon.types.VariantType; | ||
| import org.apache.paimon.types.VectorType; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** Mosaic {@link FileFormat}. */ | ||
| public class MosaicFileFormat extends FileFormat { | ||
|
|
||
| public static final ConfigOption<String> STATS_COLUMNS = | ||
| ConfigOptions.key("mosaic.stats-columns") | ||
| .stringType() | ||
| .defaultValue("") | ||
| .withDescription( | ||
| "Comma-separated list of column names to collect statistics for. " | ||
| + "Empty means no statistics collection."); | ||
|
|
||
| public static final ConfigOption<Integer> NUM_BUCKETS = | ||
| ConfigOptions.key("mosaic.num-buckets") | ||
| .intType() | ||
| .noDefaultValue() | ||
| .withDescription("Number of column buckets for parallel IO."); | ||
|
|
||
| static { | ||
| System.setProperty("arrow.enable_unsafe_memory_access", "true"); | ||
| } | ||
|
|
||
| private final FileFormatFactory.FormatContext formatContext; | ||
|
|
||
| public MosaicFileFormat(FileFormatFactory.FormatContext formatContext) { | ||
| super("mosaic"); | ||
| this.formatContext = formatContext; | ||
| } | ||
|
|
||
| @Override | ||
| public FormatReaderFactory createReaderFactory( | ||
| RowType dataSchemaRowType, | ||
| RowType projectedRowType, | ||
| @Nullable List<Predicate> predicates) { | ||
| return new MosaicReaderFactory(dataSchemaRowType, projectedRowType, predicates); | ||
| } | ||
|
|
||
| @Override | ||
| public FormatWriterFactory createWriterFactory(RowType type) { | ||
| return new MosaicWriterFactory(type, formatContext); | ||
| } | ||
|
|
||
| @Override | ||
| public void validateDataFields(RowType rowType) { | ||
| MosaicRowTypeVisitor visitor = new MosaicRowTypeVisitor(); | ||
| for (DataType fieldType : rowType.getFieldTypes()) { | ||
| fieldType.accept(visitor); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Optional<SimpleStatsExtractor> createStatsExtractor( | ||
| RowType type, SimpleColStatsCollector.Factory[] statsCollectors) { | ||
| return Optional.of(new MosaicSimpleStatsExtractor(type, statsCollectors)); | ||
| } | ||
|
|
||
| static class MosaicRowTypeVisitor implements DataTypeVisitor<Void> { | ||
|
|
||
| @Override | ||
| public Void visit(CharType charType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(VarCharType varCharType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(BooleanType booleanType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(BinaryType binaryType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(VarBinaryType varBinaryType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(DecimalType decimalType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(TinyIntType tinyIntType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(SmallIntType smallIntType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(IntType intType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(BigIntType bigIntType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(FloatType floatType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(DoubleType doubleType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(DateType dateType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(TimeType timeType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(TimestampType timestampType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(LocalZonedTimestampType localZonedTimestampType) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(VariantType variantType) { | ||
| throw new UnsupportedOperationException( | ||
| "Mosaic file format does not support type VARIANT"); | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(BlobType blobType) { | ||
| throw new UnsupportedOperationException( | ||
| "Mosaic file format does not support type BLOB"); | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(ArrayType arrayType) { | ||
| throw new UnsupportedOperationException( | ||
| "Mosaic file format does not support type ARRAY"); | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(VectorType vectorType) { | ||
| throw new UnsupportedOperationException( | ||
| "Mosaic file format does not support type VECTOR"); | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(MultisetType multisetType) { | ||
| throw new UnsupportedOperationException( | ||
| "Mosaic file format does not support type MULTISET"); | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(MapType mapType) { | ||
| throw new UnsupportedOperationException("Mosaic file format does not support type MAP"); | ||
| } | ||
|
|
||
| @Override | ||
| public Void visit(RowType rowType) { | ||
| throw new UnsupportedOperationException("Mosaic file format does not support type ROW"); | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
paimon-mosaic/src/main/java/org/apache/paimon/format/mosaic/MosaicFileFormatFactory.java
This file contains hidden or 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,38 @@ | ||
| /* | ||
| * 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.format.mosaic; | ||
|
|
||
| import org.apache.paimon.format.FileFormat; | ||
| import org.apache.paimon.format.FileFormatFactory; | ||
|
|
||
| /** Factory to create {@link MosaicFileFormat}. */ | ||
| public class MosaicFileFormatFactory implements FileFormatFactory { | ||
|
|
||
| public static final String IDENTIFIER = "mosaic"; | ||
|
|
||
| @Override | ||
| public String identifier() { | ||
| return IDENTIFIER; | ||
| } | ||
|
|
||
| @Override | ||
| public FileFormat create(FormatContext formatContext) { | ||
| return new MosaicFileFormat(formatContext); | ||
| } | ||
| } |
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.
This still makes the default Paimon reactor depend on an external SNAPSHOT artifact. Since
paimon-mosaicis listed in the root<modules>, a cleanmvn -pl paimon-mosaic -am ... compilefails withCould not find artifact org.apache.paimon:mosaic:jar:0.1.0-SNAPSHOT. Please use a released artifact, build/include this dependency in the same releaseable reactor, or keep this module out of the default root reactor/profile-gated until the Mosaic Java artifact is released.