@Override
    public void collectSizeStats(StateObjectSizeStatsCollector collector) {
        metaStateHandle.collectSizeStats(collector);
        directoryStateHandle.collectSizeStats(collector);
    }
@Test
    public void testDirectorySize(@TempDir Path directory) throws IOException {
        final int metaDataBytes = 42;
        ByteStreamStateHandle metaDataStateHandle =
                new ByteStreamStateHandle("MetaDataTest", new byte[metaDataBytes]);

        final int fileOneBytes = 1024;
        File outputFile = new File(directory.toFile(), "out.001");
        try (FileOutputStream outputStream = new FileOutputStream(outputFile)) {
            outputStream.write(new byte[fileOneBytes]);
        }

        File subPath = new File(directory.toFile(), "subdir");
        Preconditions.checkState(subPath.mkdirs());
        final int fileTwoBytes = 128;
        outputFile = new File(subPath, "out.002");
        try (FileOutputStream outputStream = new FileOutputStream(outputFile)) {
            outputStream.write(new byte[fileTwoBytes]);
        }

        DirectoryStateHandle directoryStateHandle = DirectoryStateHandle.forPathWithSize(directory);
        IncrementalLocalKeyedStateHandle handle =
                new IncrementalLocalKeyedStateHandle(
                        UUID.randomUUID(),
                        0,
                        directoryStateHandle,
                        new KeyGroupRange(0, 1),
                        metaDataStateHandle,
                        Collections.emptyList());

        StateObject.StateObjectSizeStatsCollector stats =
                StateObject.StateObjectSizeStatsCollector.create();
        handle.collectSizeStats(stats);
        Assertions.assertEquals(
                metaDataBytes + fileOneBytes + fileTwoBytes, extractLocalStateSizes(stats));
    }