-
Notifications
You must be signed in to change notification settings - Fork 2.9k
ORC:ORC supports rolling writers. #3784
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
Changes from all commits
2484ed5
3682076
2942865
018ec81
1547869
fbcf9fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import java.util.stream.Collectors; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.flink.configuration.CoreOptions; | ||
|
|
@@ -50,7 +51,6 @@ | |
| import org.apache.iceberg.types.Types; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Assume; | ||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
|
|
@@ -322,7 +322,6 @@ public void testRewriteLargeTableHasResiduals() throws IOException { | |
| */ | ||
| @Test | ||
| public void testRewriteAvoidRepeateCompress() throws IOException { | ||
| Assume.assumeFalse("ORC does not support getting length when file is opening", format.equals(FileFormat.ORC)); | ||
hililiwei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| List<Record> expected = Lists.newArrayList(); | ||
| Schema schema = icebergTableUnPartitioned.schema(); | ||
| GenericAppenderFactory genericAppenderFactory = new GenericAppenderFactory(schema); | ||
|
|
@@ -331,7 +330,7 @@ public void testRewriteAvoidRepeateCompress() throws IOException { | |
| try (FileAppender<Record> fileAppender = genericAppenderFactory.newAppender(Files.localOutput(file), format)) { | ||
| long filesize = 20000; | ||
| for (; fileAppender.length() < filesize; count++) { | ||
| Record record = SimpleDataUtil.createRecord(count, "iceberg"); | ||
|
Member
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. Why do we change this ?
Contributor
Author
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. because of some optimization mechanisms, when writing a large amount of duplicate data, |
||
| Record record = SimpleDataUtil.createRecord(count, UUID.randomUUID().toString()); | ||
| fileAppender.add(record); | ||
| expected.add(record); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * 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.orc; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.apache.orc.TypeDescription; | ||
|
|
||
| public class EstimateOrcAvgWidthVisitor extends OrcSchemaVisitor<Integer> { | ||
|
|
||
| @Override | ||
| public Integer record(TypeDescription record, List<String> names, List<Integer> fieldWidths) { | ||
| return fieldWidths.stream().reduce(Integer::sum).orElse(0); | ||
| } | ||
|
|
||
| @Override | ||
| public Integer list(TypeDescription array, Integer elementWidth) { | ||
| return elementWidth; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer map(TypeDescription map, Integer keyWidth, Integer valueWidth) { | ||
| return keyWidth + valueWidth; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer primitive(TypeDescription primitive) { | ||
| Optional<Integer> icebergIdOpt = ORCSchemaUtil.icebergID(primitive); | ||
|
|
||
| if (!icebergIdOpt.isPresent()) { | ||
| return 0; | ||
| } | ||
|
|
||
| switch (primitive.getCategory()) { | ||
| case BYTE: | ||
| case CHAR: | ||
| case SHORT: | ||
| case INT: | ||
| case FLOAT: | ||
| case BOOLEAN: | ||
| case LONG: | ||
| case DOUBLE: | ||
| case DATE: | ||
| return 8; | ||
| case TIMESTAMP: | ||
| case TIMESTAMP_INSTANT: | ||
| return 12; | ||
| case STRING: | ||
| case VARCHAR: | ||
| case BINARY: | ||
| return 128; | ||
| case DECIMAL: | ||
| return primitive.getPrecision() + 2; | ||
| default: | ||
| throw new IllegalArgumentException("Can't handle " + primitive); | ||
| } | ||
| } | ||
| } |
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.
When
ORCsupport rolling writers,fileFormatis using in no where.Should we deprecated/remove it?
Uh oh!
There was an error while loading. Please reload this page.
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.
Since these methods involve multiple spark/flink versions, I suggest that a separate PR cleans it up after this is done.