<commit_before>/*
 * Copyright (C) 2015 Cloudius Systems, Ltd.
 */

#include "query.hh"

namespace query {

template <typename T>
sstring join(const std::vector<T>& v, sstring sep) {
    std::ostringstream oss;
    size_t left = v.size();
    for (auto&& item : v) {
        oss << item;
        if (--left) {
            oss << ", ";
        }
    }
    return oss.str();
}

std::ostream& operator<<(std::ostream& out, const partition_slice& ps) {
    return out << "{"
        << "regular_cols=[" << join(ps.regular_columns, ", ") << "]"
        << ", static_cols=[" << join(ps.static_columns, ", ") << "]"
        << ", rows=[" << join(ps.row_ranges, ", ") << "]"
        << "}";
}

std::ostream& operator<<(std::ostream& out, const read_command& r) {
    return out << "read_command{"
        << "ks=" << r.keyspace
        << ", cf=" << r.column_family
        << ", pks=[" << join(r.partition_ranges, ", ") << "]"
        << ", slice=" << r.slice << ""
        << ", limit=" << r.row_limit << "}";
}

}
<commit_msg>Switch query.cc to use join() from to_string.hh<commit_after>/*
 * Copyright (C) 2015 Cloudius Systems, Ltd.
 */

#include "query.hh"
#include "to_string.hh"

namespace query {

std::ostream& operator<<(std::ostream& out, const partition_slice& ps) {
    return out << "{"
        << "regular_cols=[" << join(", ", ps.regular_columns) << "]"
        << ", static_cols=[" << join(", ", ps.static_columns) << "]"
        << ", rows=[" << join(", ", ps.row_ranges) << "]"
        << "}";
}

std::ostream& operator<<(std::ostream& out, const read_command& r) {
    return out << "read_command{"
        << "ks=" << r.keyspace
        << ", cf=" << r.column_family
        << ", pks=[" << join(", ", r.partition_ranges) << "]"
        << ", slice=" << r.slice << ""
        << ", limit=" << r.row_limit << "}";
}

}

{'fraction_non_alphanumeric': 0.2368995633187773, 'fraction_numerical': 0.004366812227074236, 'mean_word_length': 2.622529644268775, 'pattern_counts': {'":': 0, '<': 117, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5333633', 'n_tokens_mistral': 646, 'n_tokens_neox': 629, 'n_words': 125}