@@ -135,19 +135,19 @@ public void testRebalanceCompactionOfNotPartitionedImplicitlyBucketedTable() thr
135135 conf .setBoolVar (HiveConf .ConfVars .HIVE_COMPACTOR_GATHER_STATS , false );
136136 conf .setBoolVar (HiveConf .ConfVars .HIVE_STATS_AUTOGATHER , false );
137137
138- //set grouping size to have 3 buckets, and re-create driver with the new config
138+ // set grouping size to have 3 buckets, and re-create driver with the new config
139139 conf .set ("tez.grouping.min-size" , "400" );
140140 conf .set ("tez.grouping.max-size" , "5000" );
141141 driver = new Driver (conf );
142142
143143 final String tableName = "rebalance_test" ;
144144 TestDataProvider testDataProvider = prepareRebalanceTestData (tableName );
145145
146- //Try to do a rebalancing compaction
146+ // Run rebalance compaction
147147 executeStatementOnDriver ("ALTER TABLE " + tableName + " COMPACT 'rebalance'" , driver );
148148 runWorker (conf );
149149
150- //Check if the compaction succeed
150+ // Check if the compaction succeed
151151 verifyCompaction (1 , TxnStore .CLEANING_RESPONSE );
152152
153153 String [][] expectedBuckets = new String [][] {
@@ -522,8 +522,7 @@ private void verifyDataAfterCompaction(String tableName, Set<RowData> expectedDa
522522 - all the required value present
523523 */
524524
525- int optimalRecordsInBucket = expectedData .size () / bucketCount ;
526- int maximumRecordCountInABucket = optimalRecordsInBucket + bucketCount - 1 ;
525+ int maximumRecordCountInABucket = (expectedData .size () + bucketCount - 1 ) / bucketCount ;
527526
528527 long previousValueForColB = Long .MAX_VALUE ;
529528
@@ -620,11 +619,6 @@ private boolean isBalanced(String tableName, TestDataProvider testDataProvider)
620619
621620 int bucketCount = bucketFilenames .size ();
622621
623- if (bucketCount == 1 ) {
624- // nothing to rebalance with a single bucket
625- return true ;
626- }
627-
628622 AcidOutputFormat .Options options = new AcidOutputFormat .Options (conf );
629623 List <String >[] bucketData = new ArrayList [bucketCount ];
630624 for (int i = 0 ; i < bucketCount ; i ++) {
@@ -637,7 +631,7 @@ private boolean isBalanced(String tableName, TestDataProvider testDataProvider)
637631 .reduce (0 , Integer ::sum );
638632
639633 int optimalRecordsInBucket = allRecordCount / bucketCount ;
640- int maximumRecordCountInABucket = optimalRecordsInBucket + bucketCount - 1 ;
634+ int maximumRecordCountInABucket = ( allRecordCount + bucketCount - 1 ) / bucketCount ;
641635
642636 for (int i = 0 ; i < bucketCount ; i ++) {
643637 if (bucketData [i ].size () > maximumRecordCountInABucket || bucketData [i ].size () < optimalRecordsInBucket ) {
0 commit comments