presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/PrestoThriftPageResult.java/PrestoThriftPageResult/totalRecords
class PrestoThriftPageResult:    private static int totalRecords(RecordSet recordSet)
    {
        RecordCursor cursor = recordSet.cursor();
        int result = 0;
        while (cursor.advanceNextPosition()) {
            result++;
        }
        return result;
    }