public CompactionTask.TaskResult getResult() {
        int allSuccess = 0;
        int partialSuccess = 0;
        int noneSuccess = 0;
        for (CompactionTask task : tasks) {
            CompactionTask.TaskResult subTaskResult = task.getResult();
            switch (subTaskResult) {
                case NOT_FINISHED:
                    return subTaskResult; // early return
                case PARTIAL_SUCCESS:
                    partialSuccess++;
                    break;
                case NONE_SUCCESS:
                    noneSuccess++;
                    break;
                case ALL_SUCCESS:
                    allSuccess++;
                    break;
                default:
                    Preconditions.checkArgument(false, "unhandled compaction task result: %s", subTaskResult.name());
                    break;
            }
        }
        if (allSuccess == tasks.size()) {
            return CompactionTask.TaskResult.ALL_SUCCESS;
        } else if (noneSuccess == tasks.size()) {
            return CompactionTask.TaskResult.NONE_SUCCESS;
        } else {
            return CompactionTask.TaskResult.PARTIAL_SUCCESS;
        }
    }
@Test
    public void testGetResult() {
        Database db = new Database();
        Table table = new Table(Table.TableType.CLOUD_NATIVE);
        PhysicalPartition partition = new PhysicalPartitionImpl(0, "", 1, 2, null);
        CompactionJob job = new CompactionJob(db, table, partition, 10010, true);

        Assert.assertTrue(job.getAllowPartialSuccess());
        List<CompactionTask> list = new ArrayList<>();
        list.add(new CompactionTask(100));
        list.add(new CompactionTask(101));
        job.setTasks(list);
        new MockUp<CompactionTask>() {
            @Mock
            public CompactionTask.TaskResult getResult() {
                return CompactionTask.TaskResult.NOT_FINISHED;
            }
        };
        Assert.assertEquals(CompactionTask.TaskResult.NOT_FINISHED, job.getResult());

        new MockUp<CompactionTask>() {
            @Mock
            public CompactionTask.TaskResult getResult() {
                return CompactionTask.TaskResult.NONE_SUCCESS;
            }
        };
        Assert.assertEquals(CompactionTask.TaskResult.NONE_SUCCESS, job.getResult());

        new MockUp<CompactionTask>() {
            @Mock
            public CompactionTask.TaskResult getResult() {
                return CompactionTask.TaskResult.ALL_SUCCESS;
            }
        };
        Assert.assertEquals(CompactionTask.TaskResult.ALL_SUCCESS, job.getResult());

        new MockUp<CompactionTask>() {
            @Mock
            public CompactionTask.TaskResult getResult() {
                return CompactionTask.TaskResult.PARTIAL_SUCCESS;
            }
        };
        Assert.assertEquals(CompactionTask.TaskResult.PARTIAL_SUCCESS, job.getResult());
    }