Avoid a very rare case, where we might get an "IllegalArgumentException" from "Lists.partition()", in case the "sizeOfUrlReports" is <= 3.

This commit is contained in:
Lampros Smyrnaios 2024-03-29 18:12:52 +02:00
parent 08de530f03
commit bd323ad69a
1 changed files with 2 additions and 0 deletions

View File

@ -192,6 +192,8 @@ public class ParquetFileUtils {
// In case the above method returns an error, nothing happens. We just have only the initial payloads to insert to the DB.
int sizeOfEachSubList = (int)(sizeOfUrlReports * 0.33); // We want 3 sub-lists for the payloads.
if ( sizeOfEachSubList == 0 ) // If the "sizeOfUrlReports" is <= 3.
sizeOfEachSubList = 1;
// There may be 1 more with very few elements, due to non-persisted splitting. Unfortunately, we cannot st the number of splits, only the size of most splits.
if ( sizeOfEachSubList > 10 ) {
List<List<UrlReport>> finalSubLists = Lists.partition(urlReports, sizeOfEachSubList); // This needs the "sizeOfEachSubList" to be above < 0 >.