private List getTokenRangesOfTable()

in flink-connector-cassandra/src/main/java/org/apache/flink/connector/cassandra/source/split/SplitsGenerator.java [154:182]


    private List<TokenRange> getTokenRangesOfTable() {
        ResultSet resultSet =
                session.execute(
                        "SELECT range_start, range_end, partitions_count, mean_partition_size FROM "
                                + "system.size_estimates WHERE keyspace_name = ? AND table_name = ?",
                        keyspace,
                        table);

        ArrayList<TokenRange> tokenRanges = new ArrayList<>();
        for (Row row : resultSet) {
            TokenRange tokenRange =
                    new TokenRange(
                            row.getLong("partitions_count"),
                            row.getLong("mean_partition_size"),
                            row.getString("range_start"),
                            row.getString("range_end"));
            tokenRanges.add(tokenRange);
        }
        // The table may not contain the estimates yet
        // or have partitions_count and mean_partition_size fields = 0
        // if the data was just inserted and the amount of data in the table was small.
        // This is very common situation during tests,
        // when we insert a few rows and immediately query them.
        // However, for tiny data sets the lack of size estimates is not a problem at all,
        // because we don't want to split tiny data anyways.
        // Therefore, we're not issuing a warning if the result set was empty
        // or mean_partition_size and partitions_count = 0.
        return tokenRanges;
    }