deniskuzZ commented on code in PR #6793:
URL: https://github.com/apache/hive/pull/6793#discussion_r4030091140


##########
llap-server/src/java/org/apache/hadoop/hive/llap/io/decode/ParquetCachedPageReadStore.java:
##########
@@ -0,0 +1,231 @@
+/*
+ * 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.hadoop.hive.llap.io.decode;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+
+import org.apache.hadoop.hive.llap.io.encoded.ParquetEncodedColumnBatch;
+import org.apache.parquet.bytes.ByteBufferInputStream;
+import org.apache.parquet.bytes.BytesInput;
+import org.apache.parquet.column.ColumnDescriptor;
+import org.apache.parquet.column.page.DataPage;
+import org.apache.parquet.column.page.DataPageV1;
+import org.apache.parquet.column.page.DataPageV2;
+import org.apache.parquet.column.page.DictionaryPage;
+import org.apache.parquet.column.page.PageReadStore;
+import org.apache.parquet.column.page.PageReader;
+import org.apache.parquet.compression.CompressionCodecFactory;
+import 
org.apache.parquet.compression.CompressionCodecFactory.BytesInputDecompressor;
+import org.apache.parquet.format.DataPageHeader;
+import org.apache.parquet.format.DataPageHeaderV2;
+import org.apache.parquet.format.DictionaryPageHeader;
+import org.apache.parquet.format.PageHeader;
+import org.apache.parquet.format.Util;
+import org.apache.parquet.format.converter.ParquetMetadataConverter;
+import org.apache.parquet.hadoop.metadata.BlockMetaData;
+import org.apache.parquet.hadoop.metadata.ColumnChunkMetaData;
+import org.apache.parquet.hadoop.metadata.ColumnPath;
+import org.apache.parquet.hadoop.metadata.ParquetMetadata;
+import org.apache.parquet.io.ParquetDecodingException;
+import org.apache.parquet.schema.PrimitiveType;
+
+/**
+ * {@link PageReadStore} over one row group's cached column-chunk buffers: 
page headers are parsed in
+ * place, page bytes are views of the cache buffers and are decompressed 
lazily on readPage, mirroring
+ * parquet-mr's ParquetFileReader.Chunk.readAllPages and ColumnChunkPageReader 
(no offset index, no decryption).
+ */
+class ParquetCachedPageReadStore implements PageReadStore {
+
+  private final Map<ColumnPath, PageReader> readers = new HashMap<>();
+  private final long rowCount;
+
+  ParquetCachedPageReadStore(ParquetMetadata footer, ParquetEncodedColumnBatch 
batch,
+      CompressionCodecFactory codecFactory, ParquetMetadataConverter 
converter) throws IOException {
+    BlockMetaData block = footer.getBlocks().get(batch.rowGroupIx);
+    this.rowCount = block.getRowCount();
+    String createdBy = footer.getFileMetaData().getCreatedBy();
+    for (int pc = 0; pc < batch.chunks.length; ++pc) {
+      ColumnChunkMetaData chunk = batch.chunks[pc];
+      readers.put(chunk.getPath(), readAllPages(chunk, chunkBuffers(batch, 
pc), createdBy,
+          codecFactory.getDecompressor(chunk.getCodec()), converter));
+    }
+  }
+
+  /** Slices of the cached buffers covering exactly the chunk's byte region, 
in file order. */
+  private static List<ByteBuffer> chunkBuffers(ParquetEncodedColumnBatch 
batch, int pc) {
+    long start = batch.chunks[pc].getStartingPos(), end = start + 
batch.chunks[pc].getTotalSize();

Review Comment:
   please move `env` var on a new line



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to