Class BatchSizePredictorImpl
java.lang.Object
org.apache.drill.exec.physical.impl.join.BatchSizePredictorImpl
- All Implemented Interfaces:
BatchSizePredictor
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionBatchSizePredictorImpl
(RecordBatch batch, double fragmentationFactor, double safetyFactor) -
Method Summary
Modifier and TypeMethodDescriptionstatic long
computeMaxBatchSize
(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords, double fragmentationFactor, double safetyFactor, boolean reserveHash) static long
computeMaxBatchSizeNoHash
(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords, double fragmentationFactor, double safetyFactor) static long
computePartitionBatchSize
(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords) static long
computeValueVectorSize
(long numRecords, long byteSize) static long
computeValueVectorSize
(long numRecords, long byteSize, double safetyFactor) long
Gets the batchSize computed in the call toBatchSizePredictor.updateStats()
.static long
getBatchSizeEstimate
(RecordBatch recordBatch) int
Gets the number of records computed in the call toBatchSizePredictor.updateStats()
.boolean
True if the input batch had records in the last call toBatchSizePredictor.updateStats()
.long
predictBatchSize
(int desiredNumRecords, boolean reserveHash) Predicts the size of a batch using the current collected stats.static long
roundUpToPowerOf2
(long num) void
This method can be called multiple times to collect stats about the latest data in the provided record batch.
-
Constructor Details
-
BatchSizePredictorImpl
-
-
Method Details
-
getBatchSize
public long getBatchSize()Description copied from interface:BatchSizePredictor
Gets the batchSize computed in the call toBatchSizePredictor.updateStats()
. Returns 0 ifBatchSizePredictor.hadDataLastTime()
is false.- Specified by:
getBatchSize
in interfaceBatchSizePredictor
- Returns:
- Gets the batchSize computed in the call to
BatchSizePredictor.updateStats()
. Returns 0 ifBatchSizePredictor.hadDataLastTime()
is false.
-
getNumRecords
public int getNumRecords()Description copied from interface:BatchSizePredictor
Gets the number of records computed in the call toBatchSizePredictor.updateStats()
. Returns 0 ifBatchSizePredictor.hadDataLastTime()
is false.- Specified by:
getNumRecords
in interfaceBatchSizePredictor
- Returns:
- Gets the number of records computed in the call to
BatchSizePredictor.updateStats()
. Returns 0 ifBatchSizePredictor.hadDataLastTime()
is false.
-
hadDataLastTime
public boolean hadDataLastTime()Description copied from interface:BatchSizePredictor
True if the input batch had records in the last call toBatchSizePredictor.updateStats()
. False otherwise.- Specified by:
hadDataLastTime
in interfaceBatchSizePredictor
- Returns:
- True if the input batch had records in the last call to
BatchSizePredictor.updateStats()
. False otherwise.
-
updateStats
public void updateStats()Description copied from interface:BatchSizePredictor
This method can be called multiple times to collect stats about the latest data in the provided record batch. These stats are used to predict batch sizes. If the batch currently has no data, this method is a noop. This method must be called at least once beforeBatchSizePredictor.predictBatchSize(int, boolean)
.- Specified by:
updateStats
in interfaceBatchSizePredictor
-
predictBatchSize
public long predictBatchSize(int desiredNumRecords, boolean reserveHash) Description copied from interface:BatchSizePredictor
Predicts the size of a batch using the current collected stats.- Specified by:
predictBatchSize
in interfaceBatchSizePredictor
- Parameters:
desiredNumRecords
- The number of records contained in the batch whose size we want to predict.reserveHash
- Whether or not to include a column containing hash values.- Returns:
- The size of the predicted batch.
-
computeValueVectorSize
public static long computeValueVectorSize(long numRecords, long byteSize) -
computeValueVectorSize
public static long computeValueVectorSize(long numRecords, long byteSize, double safetyFactor) -
roundUpToPowerOf2
public static long roundUpToPowerOf2(long num) -
computeMaxBatchSizeNoHash
public static long computeMaxBatchSizeNoHash(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords, double fragmentationFactor, double safetyFactor) -
computeMaxBatchSize
public static long computeMaxBatchSize(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords, double fragmentationFactor, double safetyFactor, boolean reserveHash) -
computePartitionBatchSize
public static long computePartitionBatchSize(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords) -
getBatchSizeEstimate
-