Skip to content

Instantly share code, notes, and snippets.

@a2l007
Created August 26, 2022 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a2l007/3d813cc5e44c45100dda169dc6245ae4 to your computer and use it in GitHub Desktop.
Save a2l007/3d813cc5e44c45100dda169dc6245ae4 to your computer and use it in GitHub Desktop.
package org.apache.parquet.hadoop;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.parquet.example.data.Group;
import org.apache.parquet.hadoop.example.GroupReadSupport;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
public class TestEncryptionWithBuilder
{
@Test
public void testThis() throws IOException
{
Configuration conf = new Configuration();
conf.setClassLoader(getClass().getClassLoader());
conf.set("parquet.crypto.factory.class", "org.custom.CustomCryptoFactory");
conf.set("parquet.encryption.kms.client.class", "org.custom.CustomKmsBridge");
conf.set("parquet.encryption.key.file", "/path/to/master_keys_v0");
ParquetReader<Group> builderReader = ParquetReader.builder(
new GroupReadSupport(),
new Path(
"path/to/c000.snappy.parquet"))
.withConf(conf)
.build();
ParquetReader<Group> deprecatedReader = new ParquetReader<>(conf, new Path(
"path/to/c000.snappy.parquet"), new GroupReadSupport());
//throws Nullpointer exception
Group builderValue = builderReader.read();
//works fine
Group deprecatedValue = deprecatedReader.read();
Assert.assertTrue(builderValue != null);
Assert.assertTrue(deprecatedValue != null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment