49
49
import com .google .common .collect .ImmutableMap ;
50
50
import com .google .common .collect .ImmutableSet ;
51
51
import com .google .common .collect .Sets ;
52
+ import io .airlift .units .DataSize ;
52
53
import org .apache .iceberg .BaseTable ;
53
54
import org .apache .iceberg .ContentFile ;
54
55
import org .apache .iceberg .ContentScanTask ;
61
62
import org .apache .iceberg .PartitionField ;
62
63
import org .apache .iceberg .PartitionSpec ;
63
64
import org .apache .iceberg .RowLevelOperationMode ;
65
+ import org .apache .iceberg .Scan ;
64
66
import org .apache .iceberg .Schema ;
65
67
import org .apache .iceberg .Snapshot ;
66
68
import org .apache .iceberg .SortOrder ;
@@ -863,10 +865,10 @@ public static long getDataSequenceNumber(ContentFile<?> file)
863
865
* @param requestedSchema If provided, only delete files with this schema will be provided
864
866
*/
865
867
public static CloseableIterable <DeleteFile > getDeleteFiles (Table table ,
866
- long snapshot ,
867
- TupleDomain <IcebergColumnHandle > filter ,
868
- Optional <Set <Integer >> requestedPartitionSpec ,
869
- Optional <Set <Integer >> requestedSchema )
868
+ long snapshot ,
869
+ TupleDomain <IcebergColumnHandle > filter ,
870
+ Optional <Set <Integer >> requestedPartitionSpec ,
871
+ Optional <Set <Integer >> requestedSchema )
870
872
{
871
873
Expression filterExpression = toIcebergExpression (filter );
872
874
CloseableIterable <FileScanTask > fileTasks = table .newScan ().useSnapshot (snapshot ).filter (filterExpression ).planFiles ();
@@ -1042,9 +1044,9 @@ private static class DeleteFilesIterator
1042
1044
private DeleteFile currentFile ;
1043
1045
1044
1046
private DeleteFilesIterator (Map <Integer , PartitionSpec > partitionSpecsById ,
1045
- CloseableIterator <FileScanTask > fileTasks ,
1046
- Optional <Set <Integer >> requestedPartitionSpec ,
1047
- Optional <Set <Integer >> requestedSchema )
1047
+ CloseableIterator <FileScanTask > fileTasks ,
1048
+ Optional <Set <Integer >> requestedPartitionSpec ,
1049
+ Optional <Set <Integer >> requestedSchema )
1048
1050
{
1049
1051
this .partitionSpecsById = partitionSpecsById ;
1050
1052
this .fileTasks = fileTasks ;
@@ -1228,8 +1230,8 @@ public static Optional<PartitionData> partitionDataFromStructLike(PartitionSpec
1228
1230
1229
1231
/**
1230
1232
* Get the metadata location for target {@link Table},
1231
- * considering iceberg table properties {@code WRITE_METADATA_LOCATION}
1232
- * * /
1233
+ * considering iceberg table properties {@code WRITE_METADATA_LOCATION}
1234
+ */
1233
1235
public static String metadataLocation (Table icebergTable )
1234
1236
{
1235
1237
String metadataLocation = icebergTable .properties ().get (TableProperties .WRITE_METADATA_LOCATION );
@@ -1244,8 +1246,8 @@ public static String metadataLocation(Table icebergTable)
1244
1246
1245
1247
/**
1246
1248
* Get the data location for target {@link Table},
1247
- * considering iceberg table properties {@code WRITE_DATA_LOCATION}, {@code OBJECT_STORE_PATH} and {@code WRITE_FOLDER_STORAGE_LOCATION}
1248
- * * /
1249
+ * considering iceberg table properties {@code WRITE_DATA_LOCATION}, {@code OBJECT_STORE_PATH} and {@code WRITE_FOLDER_STORAGE_LOCATION}
1250
+ */
1249
1251
public static String dataLocation (Table icebergTable )
1250
1252
{
1251
1253
Map <String , String > properties = icebergTable .properties ();
@@ -1261,4 +1263,16 @@ public static String dataLocation(Table icebergTable)
1261
1263
}
1262
1264
return dataLocation ;
1263
1265
}
1266
+
1267
+ public static DataSize getTargetSplitSize (long sessionValueProperty , long icebergScanTargetSplitSize )
1268
+ {
1269
+ return Optional .of (DataSize .succinctBytes (sessionValueProperty ))
1270
+ .filter (size -> !size .equals (DataSize .succinctBytes (0 )))
1271
+ .orElse (DataSize .succinctBytes (icebergScanTargetSplitSize ));
1272
+ }
1273
+
1274
+ public static DataSize getTargetSplitSize (ConnectorSession session , Scan <?, ?, ?> scan )
1275
+ {
1276
+ return getTargetSplitSize (IcebergSessionProperties .getTargetSplitSize (session ).toBytes (), scan .targetSplitSize ());
1277
+ }
1264
1278
}
0 commit comments