-
Notifications
You must be signed in to change notification settings - Fork 3k
ORC: Add compression properties #4273
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
642a87b
0d8ce45
44bfef9
d54c377
204a0a1
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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| package org.apache.iceberg.orc; | ||
|
|
||
| import java.io.File; | ||
| import java.util.Random; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.iceberg.FileFormat; | ||
| import org.apache.iceberg.Files; | ||
|
|
@@ -35,7 +36,9 @@ | |
| import org.apache.iceberg.io.FileAppender; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; | ||
| import org.apache.iceberg.types.Types; | ||
| import org.apache.orc.CompressionKind; | ||
| import org.apache.orc.OrcConf; | ||
| import org.apache.orc.OrcFile.CompressionStrategy; | ||
| import org.junit.Assert; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
|
|
@@ -53,12 +56,20 @@ public class TestTableProperties { | |
|
|
||
| @Test | ||
| public void testOrcTableProperties() throws Exception { | ||
| Long stripeSizeBytes = 32L * 1024 * 1024; | ||
| Long blockSizeBytes = 128L * 1024 * 1024; | ||
|
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. Changed
when using both |
||
| Random random = new Random(); | ||
| int numOfCodecs = CompressionKind.values().length; | ||
| int numOfStrategies = CompressionStrategy.values().length; | ||
|
|
||
| long stripeSizeBytes = 32L * 1024 * 1024; | ||
| long blockSizeBytes = 128L * 1024 * 1024; | ||
| String codecAsString = CompressionKind.values()[random.nextInt(numOfCodecs)].name(); | ||
| String strategyAsString = CompressionStrategy.values()[random.nextInt(numOfStrategies)].name(); | ||
|
|
||
| ImmutableMap<String, String> properties = ImmutableMap.of( | ||
| TableProperties.ORC_STRIPE_SIZE_BYTES, String.valueOf(stripeSizeBytes), | ||
| TableProperties.ORC_BLOCK_SIZE_BYTES, String.valueOf(blockSizeBytes), | ||
| TableProperties.ORC_COMPRESSION, codecAsString, | ||
| TableProperties.ORC_COMPRESSION_STRATEGY, strategyAsString, | ||
| TableProperties.DEFAULT_FILE_FORMAT, FileFormat.ORC.name()); | ||
|
|
||
| File folder = TEMPORARY_FOLDER.newFolder(); | ||
|
|
@@ -82,19 +93,29 @@ public void testOrcTableProperties() throws Exception { | |
| DynFields.builder().hiddenImpl(writer.getClass(), "conf").build(writer); | ||
|
|
||
| Configuration configuration = confField.get(); | ||
| Assert.assertEquals(String.valueOf(blockSizeBytes), configuration.get(OrcConf.BLOCK_SIZE.getAttribute())); | ||
| Assert.assertEquals(String.valueOf(stripeSizeBytes), configuration.get(OrcConf.STRIPE_SIZE.getAttribute())); | ||
|
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. Changed this to using OrcConf to get value directly so no need to know property key detail. |
||
| Assert.assertEquals(blockSizeBytes, OrcConf.BLOCK_SIZE.getLong(configuration)); | ||
| Assert.assertEquals(stripeSizeBytes, OrcConf.STRIPE_SIZE.getLong(configuration)); | ||
| Assert.assertEquals(codecAsString, OrcConf.COMPRESS.getString(configuration)); | ||
| Assert.assertEquals(strategyAsString, OrcConf.COMPRESSION_STRATEGY.getString(configuration)); | ||
| Assert.assertEquals(FileFormat.ORC.name(), configuration.get(TableProperties.DEFAULT_FILE_FORMAT)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOrcTableDeleteProperties() throws Exception { | ||
| Long stripeSizeBytes = 32L * 1024 * 1024; | ||
| Long blockSizeBytes = 128L * 1024 * 1024; | ||
| Random random = new Random(); | ||
| int numOfCodecs = CompressionKind.values().length; | ||
| int numOfStrategies = CompressionStrategy.values().length; | ||
|
|
||
| long stripeSizeBytes = 32L * 1024 * 1024; | ||
| long blockSizeBytes = 128L * 1024 * 1024; | ||
| String codecAsString = CompressionKind.values()[random.nextInt(numOfCodecs)].name(); | ||
| String strategyAsString = CompressionStrategy.values()[random.nextInt(numOfStrategies)].name(); | ||
|
|
||
| ImmutableMap<String, String> properties = ImmutableMap.of( | ||
| TableProperties.DELETE_ORC_STRIPE_SIZE_BYTES, String.valueOf(stripeSizeBytes), | ||
| TableProperties.DELETE_ORC_BLOCK_SIZE_BYTES, String.valueOf(blockSizeBytes), | ||
| TableProperties.DELETE_ORC_COMPRESSION, codecAsString, | ||
| TableProperties.DELETE_ORC_COMPRESSION_STRATEGY, strategyAsString, | ||
| TableProperties.DEFAULT_FILE_FORMAT, FileFormat.ORC.name()); | ||
|
|
||
| File folder = TEMPORARY_FOLDER.newFolder(); | ||
|
|
@@ -123,8 +144,10 @@ public void testOrcTableDeleteProperties() throws Exception { | |
| DynFields.builder().hiddenImpl(orcFileAppender.getClass(), "conf").build(orcFileAppender); | ||
|
|
||
| Configuration configuration = confField.get(); | ||
| Assert.assertEquals(String.valueOf(blockSizeBytes), configuration.get(OrcConf.BLOCK_SIZE.getAttribute())); | ||
| Assert.assertEquals(String.valueOf(stripeSizeBytes), configuration.get(OrcConf.STRIPE_SIZE.getAttribute())); | ||
| Assert.assertEquals(blockSizeBytes, OrcConf.BLOCK_SIZE.getLong(configuration)); | ||
| Assert.assertEquals(stripeSizeBytes, OrcConf.STRIPE_SIZE.getLong(configuration)); | ||
| Assert.assertEquals(codecAsString, OrcConf.COMPRESS.getString(configuration)); | ||
| Assert.assertEquals(strategyAsString, OrcConf.COMPRESSION_STRATEGY.getString(configuration)); | ||
| Assert.assertEquals(FileFormat.ORC.name(), configuration.get(TableProperties.DEFAULT_FILE_FORMAT)); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.