rdblue commented on a change in pull request #3073: URL: https://github.com/apache/iceberg/pull/3073#discussion_r706874065
########## File path: core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java ########## @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.util; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.iceberg.BaseCombinedScanTask; +import org.apache.iceberg.CombinedScanTask; +import org.apache.iceberg.DataFile; +import org.apache.iceberg.DeleteFile; +import org.apache.iceberg.FileScanTask; +import org.apache.iceberg.MockFileScanTask; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +public class TestTableScanUtil { + + private List<FileScanTask> tasksWithDataAndDeleteSizes(List<Pair<Long, Long[]>> sizePairs) { + return sizePairs.stream().map(sizePair -> { + DataFile dataFile = dataFileWithSize(sizePair.first()); + DeleteFile[] deleteFiles = deleteFilesWithSizes( + Arrays.stream(sizePair.second()).mapToLong(Long::longValue).toArray()); + return new MockFileScanTask(dataFile, deleteFiles); + }).collect(Collectors.toList()); + } + + private DataFile dataFileWithSize(long size) { + DataFile mockFile = Mockito.mock(DataFile.class); + Mockito.when(mockFile.fileSizeInBytes()).thenReturn(size); + return mockFile; + } + + private DeleteFile[] deleteFilesWithSizes(long... sizes) { + return Arrays.stream(sizes).mapToObj(size -> { + DeleteFile mockDeleteFile = Mockito.mock(DeleteFile.class); + Mockito.when(mockDeleteFile.fileSizeInBytes()).thenReturn(size); + return mockDeleteFile; + }).toArray(DeleteFile[]::new); + } + + @Test + public void testPlanTaskWithDeleteFiles() { + List<FileScanTask> testFiles = tasksWithDataAndDeleteSizes( + Arrays.asList( + Pair.of(100L, new Long[] {20L, 20L}), + Pair.of(250L, new Long[0]), + Pair.of(100L, new Long[] {40L, 40L, 40L}), Review comment: I think you want at least one file scan task that weighs over 512 with delete files alone. One with 250 data and 3 delete files of 100 each would do it. Then that shouldn't get combined with anything if weighed properly. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
