-
Notifications
You must be signed in to change notification settings - Fork 3k
Flink : vectorized read of orc format in flink #2566
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
66a5e11
Vectorized Reads for orc type
bbe51cc
add class ConstantColumnVectors for Constant
d9ac8c8
fix some issues
zhangjun0x01 c3c52a1
fix some issues
0aba1e0
fix the comments
081735e
add test case for Nested Type
68ca4a2
rename to isVectorizationSupported
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
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
223 changes: 223 additions & 0 deletions
223
flink/src/main/java/org/apache/iceberg/flink/data/vectorized/ConstantColumnVectors.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,223 @@ | ||
| /* | ||
| * 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.flink.data.vectorized; | ||
|
|
||
| import org.apache.flink.table.data.DecimalData; | ||
| import org.apache.flink.table.data.TimestampData; | ||
| import org.apache.flink.table.data.binary.BinaryStringData; | ||
| import org.apache.flink.table.data.vector.BooleanColumnVector; | ||
| import org.apache.flink.table.data.vector.BytesColumnVector; | ||
| import org.apache.flink.table.data.vector.ColumnVector; | ||
| import org.apache.flink.table.data.vector.DecimalColumnVector; | ||
| import org.apache.flink.table.data.vector.DoubleColumnVector; | ||
| import org.apache.flink.table.data.vector.FloatColumnVector; | ||
| import org.apache.flink.table.data.vector.IntColumnVector; | ||
| import org.apache.flink.table.data.vector.LongColumnVector; | ||
| import org.apache.flink.table.data.vector.TimestampColumnVector; | ||
|
|
||
| class ConstantColumnVectors { | ||
| private ConstantColumnVectors() { | ||
| } | ||
|
|
||
| static ColumnVector ints(Object constant) { | ||
| return new ConstantIntColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector longs(Object constant) { | ||
| return new ConstantLongColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector booleans(Object constant) { | ||
| return new ConstantBooleanColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector doubles(Object constant) { | ||
| return new ConstantDoubleColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector floats(Object constant) { | ||
| return new ConstantFloatColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector decimals(Object constant) { | ||
| return new ConstantDecimalColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector timestamps(Object constant) { | ||
| return new ConstantTimestampColumnVector(constant); | ||
| } | ||
|
|
||
| static ColumnVector bytes(Object constant) { | ||
| return new ConstantBytesColumnVector(constant); | ||
| } | ||
|
|
||
| private static class ConstantIntColumnVector implements IntColumnVector { | ||
|
|
||
| private final Object constant; | ||
|
|
||
| private ConstantIntColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public int getInt(int i) { | ||
| return (int) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantLongColumnVector implements LongColumnVector { | ||
|
|
||
| private final Object constant; | ||
|
|
||
| private ConstantLongColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public long getLong(int i) { | ||
| return (long) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantBooleanColumnVector implements BooleanColumnVector { | ||
| private final Object constant; | ||
|
|
||
| private ConstantBooleanColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean getBoolean(int i) { | ||
| return (boolean) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantDoubleColumnVector implements DoubleColumnVector { | ||
| private final Object constant; | ||
|
|
||
| private ConstantDoubleColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public double getDouble(int i) { | ||
| return (double) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantFloatColumnVector implements FloatColumnVector { | ||
| private final Object constant; | ||
|
|
||
| private ConstantFloatColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public float getFloat(int i) { | ||
| return (float) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantDecimalColumnVector implements DecimalColumnVector { | ||
| private final Object constant; | ||
|
|
||
| private ConstantDecimalColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public DecimalData getDecimal(int i, int precision, int scale) { | ||
| return (DecimalData) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantTimestampColumnVector implements TimestampColumnVector { | ||
| private final Object constant; | ||
|
|
||
| private ConstantTimestampColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public TimestampData getTimestamp(int i, int precision) { | ||
| return (TimestampData) constant; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
|
|
||
| private static class ConstantBytesColumnVector implements BytesColumnVector { | ||
| private final Object constant; | ||
|
|
||
| private ConstantBytesColumnVector(Object constant) { | ||
| this.constant = constant; | ||
| } | ||
|
|
||
| @Override | ||
| public Bytes getBytes(int i) { | ||
| byte[] bytes = null; | ||
| if (constant instanceof byte[]) { | ||
| bytes = (byte[]) constant; | ||
| } else { | ||
| BinaryStringData str = (BinaryStringData) constant; | ||
| bytes = str.toBytes(); | ||
| } | ||
| return new Bytes(bytes, 0, bytes.length); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isNullAt(int i) { | ||
| return constant == null; | ||
| } | ||
| } | ||
| } | ||
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.
Nit: Could we keep all those ConstantXXColumnVector has the same order for
getLongmethod andisNullAtmethod ? I seeConstantIntColumnVectorput theisNullAtahead ofgetInt, butConstantLongColumnVongectoris the reversed order.