guiyanakuang commented on a change in pull request #915: URL: https://github.com/apache/orc/pull/915#discussion_r713694228
########## File path: java/core/src/test/org/apache/orc/impl/TestDigest.java ########## @@ -0,0 +1,109 @@ +/* + * Licensed to Ted Dunning 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.orc.impl; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector; +import org.apache.hadoop.hive.ql.exec.vector.LongColumnVector; +import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch; +import org.apache.orc.ColumnStatistics; +import org.apache.orc.OrcConf; +import org.apache.orc.OrcFile; +import org.apache.orc.Reader; +import org.apache.orc.TypeDescription; +import org.apache.orc.Writer; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class TestDigest { + + Path workDir = new Path(System.getProperty("test.tmp.dir")); + Configuration conf; + FileSystem fs; + Path testFilePath; + TypeDescription schema; + + @BeforeEach + public void openFileSystem() throws Exception { + conf = new Configuration(); + conf.set(OrcConf.DIGEST_COLUMNS.getAttribute(), "id:100"); + fs = FileSystem.getLocal(conf); + fs.setWorkingDirectory(workDir); + testFilePath = new Path("testWriterImpl.orc"); + fs.create(testFilePath, true); + schema = TypeDescription.fromString("struct<id:int,name:string>"); + } + + @AfterEach + public void deleteTestFile() throws Exception { + fs.delete(testFilePath, false); + } + + private void write() throws IOException { + Writer writer = OrcFile.createWriter(testFilePath, + OrcFile.writerOptions(conf) + .overwrite(true) + .setSchema(schema) + ); + VectorizedRowBatch batch = schema.createRowBatch(); + LongColumnVector id = (LongColumnVector) batch.cols[0]; + BytesColumnVector name = (BytesColumnVector) batch.cols[1]; + for (int r = 1; r < 20; ++r) { + int row = batch.size++; + id.vector[row] = r; + byte[] buffer = String.valueOf(r).getBytes(StandardCharsets.UTF_8); + name.setRef(row, buffer, 0, buffer.length); + } + int row = batch.size++; + id.vector[row] = 1_000_000; + byte[] buffer = String.valueOf(1_000_000).getBytes(StandardCharsets.UTF_8); + name.setRef(row, buffer, 0, buffer.length); + writer.addRowBatch(batch); + writer.close(); + } + + private void read() throws IOException { Review comment: Current statistics already support encryption. https://github.com/apache/orc/blob/cf720d7b2333618c652445299486cb9600bdbe4f/java/core/src/java/org/apache/orc/impl/ReaderImpl.java#L355-L382 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@orc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org