Ben-Zvi commented on a change in pull request #1606: Drill 6845: Semi-Hash-Join 
to skip incoming build duplicates, automatically stop skipping if too few
URL: https://github.com/apache/drill/pull/1606#discussion_r247029094
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/HashJoinSpillControlImpl.java
 ##########
 @@ -0,0 +1,52 @@
+/*
+ * 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.drill.exec.physical.impl.join;
+
+  import org.apache.drill.exec.memory.BufferAllocator;
+  import org.apache.drill.exec.record.RecordBatchSizer;
+  import org.apache.drill.exec.record.VectorContainer;
+
+/**
+ * This class is currently used only for Semi-Hash-Join that avoids duplicates 
by the use of a hash table
+ * The method {@link 
HashJoinMemoryCalculator.HashJoinSpillControl#shouldSpill(VectorContainer)} 
returns true if the memory available now to the allocator if not enough
+ * to hold (a multiple of, for safety) a new allocated batch
+ */
+public class HashJoinSpillControlImpl implements 
HashJoinMemoryCalculator.HashJoinSpillControl {
+  private BufferAllocator allocator;
+  private int recordsPerBatch;
+  private int minBatchesInAvailableMemory;
+
+  HashJoinSpillControlImpl(BufferAllocator allocator, int recordsPerBatch, int 
minBatchesInAvailableMemory) {
+    this.allocator = allocator;
+    this.recordsPerBatch = recordsPerBatch;
+    this.minBatchesInAvailableMemory = minBatchesInAvailableMemory;
+  }
+
+  @Override
+  public boolean shouldSpill(VectorContainer currentVectorContainer) {
+    assert currentVectorContainer.hasRecordCount();
 
 Review comment:
   * Yes, you are correct. The single probe batch per spilled partition is not 
accounted for. The cleanest solution is to put this logic into the post Build 
calculator, and restore the "if" order (on line 1121) that was there initially 
- first check the postBuild and spill the partition if needed, and second check 
for semiSkipDuplicates.
   Here again it would be simple to just check if the available memory is large 
enough (for 3 probe batches, etc).
   * The term "partial" is confusing. Should it be: Need the memory calculator 
to adjust (down) the number of partitions so that each partition has enough 
memory to start working ? (unlike the regular case, a minimal hash-table needs 
to be accounted for here, for each partition).
    

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to