@@ -39,32 +39,36 @@ void testEstimator() {
3939 assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (1000 );
4040
4141 estimator = new DynamicWriteBatchSizeEstimator (true , 1000 , 100 );
42- // test decrease 10 %
42+ // test decrease 5 %
4343 estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , 450 );
44- assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (900 );
44+ int expectedSize = 950 ;
45+ assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH ))
46+ .isEqualTo (expectedSize );
4547
46- // test decrease 5%
47- estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , (int ) (900 * 0.9 ) - 10 );
48- assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (855 );
48+ // test increase 5%
49+ estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , 350 );
50+ expectedSize = (int ) (950 * 0.95 );
51+ assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH ))
52+ .isEqualTo (expectedSize );
4953
50- // test increase 1 %
51- estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , 852 );
54+ // test increase 10 %
55+ estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , 930 );
5256 assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH ))
53- .isEqualTo ((int ) (855 * 1.1 ));
57+ .isEqualTo ((int ) (expectedSize * 1.1 ));
5458 }
5559
5660 @ Test
5761 void testMinDecreaseToPageSize () {
5862 int estimatedSize = estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH );
5963 estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , 1000 );
60- while (estimatedSize > 100 ) {
64+ while (estimatedSize > 2 * 100 ) {
6165 estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , (int ) (estimatedSize * 0.5 ) - 10 );
6266 estimatedSize = estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH );
6367 }
6468
65- assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (100 );
69+ assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (200 );
6670 estimator .updateEstimation (DATA1_PHYSICAL_TABLE_PATH , 0 );
67- assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (100 );
71+ assertThat (estimator .getEstimatedBatchSize (DATA1_PHYSICAL_TABLE_PATH )).isEqualTo (200 );
6872 }
6973
7074 @ Test
0 commit comments