public static Optional<int[]> smallestKey(@Nullable Set<ImmutableBitSet> upsertKeys) {
        if (null == upsertKeys || upsertKeys.isEmpty()) {
            return Optional.empty();
        }
        return upsertKeys.stream()
                .map(ImmutableBitSet::toArray)
                .reduce(
                        (k1, k2) -> {
                            if (k1.length < k2.length) {
                                return k1;
                            }
                            if (k1.length == k2.length) {
                                for (int index = 0; index < k1.length; index++) {
                                    if (k1[index] < k2[index]) {
                                        return k1;
                                    }
                                }
                            }
                            return k2;
                        });
    }
@Test
    void testSmallestKey() {
        assertThat(UpsertKeyUtil.getSmallestKey(null)).isEqualTo(emptyKey);
        assertThat(UpsertKeyUtil.getSmallestKey(new HashSet<>())).isEqualTo(emptyKey);

        ImmutableBitSet smallestKey = ImmutableBitSet.of(0, 1);
        ImmutableBitSet middleKey = ImmutableBitSet.of(0, 2);
        ImmutableBitSet longKey = ImmutableBitSet.of(0, 1, 2);

        Set<ImmutableBitSet> upsertKeys = new HashSet<>();
        upsertKeys.add(smallestKey);
        upsertKeys.add(middleKey);
        assertThat(UpsertKeyUtil.getSmallestKey(upsertKeys)).isEqualTo(smallestKey.toArray());

        upsertKeys.clear();
        upsertKeys.add(smallestKey);
        upsertKeys.add(longKey);
        assertThat(UpsertKeyUtil.getSmallestKey(upsertKeys)).isEqualTo(smallestKey.toArray());
    }