@@ -71,7 +71,7 @@ public static boolean hasDeletes(FileScanTask task) {
7171
7272 public static CloseableIterable <FileScanTask > splitFiles (
7373 CloseableIterable <FileScanTask > tasks , long splitSize ) {
74- Preconditions .checkArgument (splitSize > 0 , "Invalid split size (negative or 0) : %s" , splitSize );
74+ Preconditions .checkArgument (splitSize > 0 , "Split size must be > 0 : %s" , splitSize );
7575
7676 Iterable <FileScanTask > splitTasks =
7777 FluentIterable .from (tasks ).transformAndConcat (input -> input .split (splitSize ));
@@ -81,11 +81,8 @@ public static CloseableIterable<FileScanTask> splitFiles(
8181
8282 public static CloseableIterable <CombinedScanTask > planTasks (
8383 CloseableIterable <FileScanTask > splitFiles , long splitSize , int lookback , long openFileCost ) {
84- Preconditions .checkArgument (splitSize > 0 , "Invalid split size (negative or 0): %s" , splitSize );
85- Preconditions .checkArgument (
86- lookback > 0 , "Invalid split planning lookback (negative or 0): %s" , lookback );
87- Preconditions .checkArgument (
88- openFileCost >= 0 , "Invalid file open cost (negative): %s" , openFileCost );
84+
85+ validatePlanningArguments (splitSize , lookback , openFileCost );
8986
9087 // Check the size of delete file as well to avoid unbalanced bin-packing
9188 Function <FileScanTask , Long > weightFunc =
@@ -106,11 +103,7 @@ public static CloseableIterable<CombinedScanTask> planTasks(
106103 public static <T extends ScanTask > CloseableIterable <ScanTaskGroup <T >> planTaskGroups (
107104 CloseableIterable <T > tasks , long splitSize , int lookback , long openFileCost ) {
108105
109- Preconditions .checkArgument (splitSize > 0 , "Invalid split size (negative or 0): %s" , splitSize );
110- Preconditions .checkArgument (
111- lookback > 0 , "Invalid split planning lookback (negative or 0): %s" , lookback );
112- Preconditions .checkArgument (
113- openFileCost >= 0 , "Invalid file open cost (negative): %s" , openFileCost );
106+ validatePlanningArguments (splitSize , lookback , openFileCost );
114107
115108 // capture manifests which can be closed after scan planning
116109 CloseableIterable <T > splitTasks =
@@ -144,11 +137,7 @@ public static <T extends PartitionScanTask> List<ScanTaskGroup<T>> planTaskGroup
144137 long openFileCost ,
145138 Types .StructType groupingKeyType ) {
146139
147- Preconditions .checkArgument (splitSize > 0 , "Invalid split size (negative or 0): %s" , splitSize );
148- Preconditions .checkArgument (
149- lookback > 0 , "Invalid split planning lookback (negative or 0): %s" , lookback );
150- Preconditions .checkArgument (
151- openFileCost >= 0 , "Invalid file open cost (negative): %s" , openFileCost );
140+ validatePlanningArguments (splitSize , lookback , openFileCost );
152141
153142 Function <T , Long > weightFunc =
154143 task -> Math .max (task .sizeBytes (), task .filesCount () * openFileCost );
@@ -250,4 +239,10 @@ public static <T extends ScanTask> List<T> mergeTasks(List<T> tasks) {
250239
251240 return mergedTasks ;
252241 }
242+
243+ private static void validatePlanningArguments (long splitSize , int lookback , long openFileCost ) {
244+ Preconditions .checkArgument (splitSize > 0 , "Split size must be > 0: %s" , splitSize );
245+ Preconditions .checkArgument (lookback > 0 , "Split planning lookback must be > 0: %s" , lookback );
246+ Preconditions .checkArgument (openFileCost >= 0 , "File open cost must be >= 0: %s" , openFileCost );
247+ }
253248}
0 commit comments