Class BatchSizePredictorImpl
java.lang.Object
org.apache.drill.exec.physical.impl.join.BatchSizePredictorImpl
- All Implemented Interfaces:
BatchSizePredictor
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBatchSizePredictorImpl(RecordBatch batch, double fragmentationFactor, double safetyFactor) -
Method Summary
Modifier and TypeMethodDescriptionstatic longcomputeMaxBatchSize(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords, double fragmentationFactor, double safetyFactor, boolean reserveHash) static longcomputeMaxBatchSizeNoHash(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords, double fragmentationFactor, double safetyFactor) static longcomputePartitionBatchSize(long incomingBatchSize, int incomingNumRecords, int desiredNumRecords) static longcomputeValueVectorSize(long numRecords, long byteSize) static longcomputeValueVectorSize(long numRecords, long byteSize, double safetyFactor) longGets the batchSize computed in the call toBatchSizePredictor.updateStats().static longgetBatchSizeEstimate(RecordBatch recordBatch) intGets the number of records computed in the call toBatchSizePredictor.updateStats().booleanTrue if the input batch had records in the last call toBatchSizePredictor.updateStats().longpredictBatchSize(int desiredNumRecords, boolean reserveHash) Predicts the size of a batch using the current collected stats.static longroundUpToPowerOf2(long num) voidThis 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:BatchSizePredictorGets the batchSize computed in the call toBatchSizePredictor.updateStats(). Returns 0 ifBatchSizePredictor.hadDataLastTime()is false.- Specified by:
getBatchSizein 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:BatchSizePredictorGets the number of records computed in the call toBatchSizePredictor.updateStats(). Returns 0 ifBatchSizePredictor.hadDataLastTime()is false.- Specified by:
getNumRecordsin 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:BatchSizePredictorTrue if the input batch had records in the last call toBatchSizePredictor.updateStats(). False otherwise.- Specified by:
hadDataLastTimein 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:BatchSizePredictorThis 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:
updateStatsin interfaceBatchSizePredictor
-
predictBatchSize
public long predictBatchSize(int desiredNumRecords, boolean reserveHash) Description copied from interface:BatchSizePredictorPredicts the size of a batch using the current collected stats.- Specified by:
predictBatchSizein 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
-