Search in sources :

Example 1 with IndexRange

use of com.pingcap.tikv.predicates.IndexRange in project tispark by pingcap.

the class IndexStatistics method getRowCount.

public double getRowCount(List<IndexRange> indexRanges) {
    double rowCount = 0.0;
    for (IndexRange ir : indexRanges) {
        StatisticsKeyRangeBuilder builder = new StatisticsKeyRangeBuilder(ir);
        Pair<Key, Key> range = builder.compute();
        // TODO: Implement CMSketch point query
        // if (cmSketch != null) {
        // rowCount += cmSketch.queryBytes(convertedKey.getBytes());
        // } else {
        // rowCount += histogram.betweenRowCount(convertedKey, convertedNext);
        // }
        rowCount += histogram.betweenRowCount(range.first, range.second);
    }
    if (rowCount > histogram.totalRowCount()) {
        rowCount = histogram.totalRowCount();
    } else if (rowCount < 0) {
        rowCount = 0;
    }
    return rowCount;
}
Also used : IndexRange(com.pingcap.tikv.predicates.IndexRange) StatisticsKeyRangeBuilder(com.pingcap.tikv.key.StatisticsKeyRangeBuilder) Key(com.pingcap.tikv.key.Key)

Aggregations

Key (com.pingcap.tikv.key.Key)1 StatisticsKeyRangeBuilder (com.pingcap.tikv.key.StatisticsKeyRangeBuilder)1 IndexRange (com.pingcap.tikv.predicates.IndexRange)1