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


##########
ql/src/java/org/apache/hadoop/hive/llap/ParquetCacheLayout.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.io.Allocator;
+import org.apache.hadoop.hive.common.io.DataCache.DiskRangeListFactory;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.io.orc.encoded.CacheChunk;
+
+/**
+ * How Parquet column chunks are laid out in the LLAP cache and fetched from 
the file. Everything
+ * that caches a chunk goes through this, so a reader finding only part of one 
cached re-caches
+ * the gap on the boundaries the first reader used. A reader builds one from 
the daemon's allocator
+ * and configuration and uses it for every chunk, which is what keeps its 
layout consistent.
+ */
+public final class ParquetCacheLayout {
+
+  /**
+   * An object store fetches separate ranges concurrently but never splits 
one, so cutting buys
+   * parallelism while a large range amortises the request. Measured against 
S3 the knee is here:
+   * below 4 Mb throughput drops sharply, above 8 Mb it is flat. Trino also 
splits at 8 Mb.
+   */
+  private static final int MIN_RANGE_CAP_BYTES = 8 << 20;
+
+  public static final DiskRangeListFactory CACHE_CHUNK_FACTORY = 
CacheChunk::new;
+
+  private final int maxBuffer;
+  private final int minBuffer;
+  private final int maxRange;
+
+  /** The layout for a daemon: its allocator's maximum and the grain it caches 
non-ORC data at. */
+  public ParquetCacheLayout(Allocator allocator, Configuration conf) {
+    this(allocator.getMaxAllocation(), HiveConf.getSizeVar(conf, 
HiveConf.ConfVars.LLAP_IO_ENCODE_ALLOC_SIZE));
+  }
+
+  /**
+   * @param maxAlloc   largest buffer the allocator hands out; rounded down to 
a power of two
+   * @param splitFloor size below which a remainder is left as one buffer 
rather than split further
+   */
+  public ParquetCacheLayout(int maxAlloc, long splitFloor) {
+    this.maxBuffer = Integer.highestOneBit(maxAlloc);

Review Comment:
   i think we can drop the defensive caps
   ````                                                                         
                                      
     this.maxBuffer = maxAlloc;                                                 
                                                                                
                                         
     this.minBuffer = (int) splitFloor;                                         
                                                                                
                                         
     this.rangeCap = Math.max(MIN_RANGE_CAP_BYTES, maxAlloc);  
   ````                                                                         
                                                                 
   



-- 
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