-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Core: Refactor variants to enable moving interfaces to API module #12167
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
Merged
Merged
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions
34
core/src/main/java/org/apache/iceberg/variants/LogicalType.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,34 @@ | ||
| /* | ||
| * 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.iceberg.variants; | ||
|
|
||
| enum LogicalType { | ||
| NULL, | ||
| BOOLEAN, | ||
| EXACT_NUMERIC, | ||
| FLOAT, | ||
| DOUBLE, | ||
| DATE, | ||
| TIMESTAMPTZ, | ||
| TIMESTAMPNTZ, | ||
| BINARY, | ||
| STRING, | ||
| ARRAY, | ||
| OBJECT | ||
| } |
103 changes: 103 additions & 0 deletions
103
core/src/main/java/org/apache/iceberg/variants/PhysicalType.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,103 @@ | ||
| /* | ||
| * 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.iceberg.variants; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.nio.ByteBuffer; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public enum PhysicalType { | ||
| NULL(LogicalType.NULL, Void.class), | ||
| BOOLEAN_TRUE(LogicalType.BOOLEAN, Boolean.class), | ||
| BOOLEAN_FALSE(LogicalType.BOOLEAN, Boolean.class), | ||
| INT8(LogicalType.EXACT_NUMERIC, Byte.class), | ||
| INT16(LogicalType.EXACT_NUMERIC, Short.class), | ||
| INT32(LogicalType.EXACT_NUMERIC, Integer.class), | ||
| INT64(LogicalType.EXACT_NUMERIC, Long.class), | ||
| DOUBLE(LogicalType.DOUBLE, Double.class), | ||
| DECIMAL4(LogicalType.EXACT_NUMERIC, BigDecimal.class), | ||
| DECIMAL8(LogicalType.EXACT_NUMERIC, BigDecimal.class), | ||
| DECIMAL16(LogicalType.EXACT_NUMERIC, BigDecimal.class), | ||
| DATE(LogicalType.DATE, Integer.class), | ||
| TIMESTAMPTZ(LogicalType.TIMESTAMPTZ, Long.class), | ||
| TIMESTAMPNTZ(LogicalType.TIMESTAMPNTZ, Long.class), | ||
| FLOAT(LogicalType.FLOAT, Float.class), | ||
| BINARY(LogicalType.BINARY, ByteBuffer.class), | ||
| STRING(LogicalType.STRING, String.class), | ||
| ARRAY(LogicalType.ARRAY, List.class), | ||
| OBJECT(LogicalType.OBJECT, Map.class); | ||
|
|
||
| private final LogicalType logicalType; | ||
| private final Class<?> javaClass; | ||
|
|
||
| PhysicalType(LogicalType logicalType, Class<?> javaClass) { | ||
| this.logicalType = logicalType; | ||
| this.javaClass = javaClass; | ||
| } | ||
|
|
||
| LogicalType toLogicalType() { | ||
| return logicalType; | ||
| } | ||
|
|
||
| public Class<?> javaClass() { | ||
| return javaClass; | ||
| } | ||
|
|
||
| public static PhysicalType from(int primitiveType) { | ||
| switch (primitiveType) { | ||
| case Primitives.TYPE_NULL: | ||
| return NULL; | ||
| case Primitives.TYPE_TRUE: | ||
| return BOOLEAN_TRUE; | ||
| case Primitives.TYPE_FALSE: | ||
| return BOOLEAN_FALSE; | ||
| case Primitives.TYPE_INT8: | ||
| return INT8; | ||
| case Primitives.TYPE_INT16: | ||
| return INT16; | ||
| case Primitives.TYPE_INT32: | ||
| return INT32; | ||
| case Primitives.TYPE_INT64: | ||
| return INT64; | ||
| case Primitives.TYPE_DATE: | ||
| return DATE; | ||
| case Primitives.TYPE_TIMESTAMPTZ: | ||
| return TIMESTAMPTZ; | ||
| case Primitives.TYPE_TIMESTAMPNTZ: | ||
| return TIMESTAMPNTZ; | ||
| case Primitives.TYPE_FLOAT: | ||
| return FLOAT; | ||
| case Primitives.TYPE_DOUBLE: | ||
| return DOUBLE; | ||
| case Primitives.TYPE_DECIMAL4: | ||
| return DECIMAL4; | ||
| case Primitives.TYPE_DECIMAL8: | ||
| return DECIMAL8; | ||
| case Primitives.TYPE_DECIMAL16: | ||
| return DECIMAL16; | ||
| case Primitives.TYPE_BINARY: | ||
| return BINARY; | ||
| case Primitives.TYPE_STRING: | ||
| return STRING; | ||
| } | ||
|
|
||
| throw new UnsupportedOperationException("Unknown primitive physical type: " + primitiveType); | ||
| } | ||
| } |
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
43 changes: 43 additions & 0 deletions
43
core/src/main/java/org/apache/iceberg/variants/Primitives.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,43 @@ | ||
| /* | ||
| * 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.iceberg.variants; | ||
|
|
||
| class Primitives { | ||
| static final int TYPE_NULL = 0; | ||
| static final int TYPE_TRUE = 1; | ||
| static final int TYPE_FALSE = 2; | ||
| static final int TYPE_INT8 = 3; | ||
| static final int TYPE_INT16 = 4; | ||
| static final int TYPE_INT32 = 5; | ||
| static final int TYPE_INT64 = 6; | ||
| static final int TYPE_DOUBLE = 7; | ||
| static final int TYPE_DECIMAL4 = 8; | ||
| static final int TYPE_DECIMAL8 = 9; | ||
| static final int TYPE_DECIMAL16 = 10; | ||
| static final int TYPE_DATE = 11; | ||
| static final int TYPE_TIMESTAMPTZ = 12; // equivalent to timestamptz | ||
| static final int TYPE_TIMESTAMPNTZ = 13; // equivalent to timestamp | ||
| static final int TYPE_FLOAT = 14; | ||
| static final int TYPE_BINARY = 15; | ||
| static final int TYPE_STRING = 16; | ||
|
|
||
| static final int PRIMITIVE_TYPE_SHIFT = 2; | ||
|
|
||
| private Primitives() {} | ||
| } |
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
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
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
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.