add utf8:validate to operator<< partition_key with_schema.
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
#include "readers/filtering.hh"
|
||||
#include "readers/compacting.hh"
|
||||
#include "tombstone_gc.hh"
|
||||
#include "keys.hh"
|
||||
|
||||
namespace sstables {
|
||||
|
||||
@@ -1283,9 +1284,9 @@ public:
|
||||
type,
|
||||
schema.ks_name(),
|
||||
schema.cf_name(),
|
||||
partition_key_to_string(new_key.key(), schema),
|
||||
new_key.key().with_schema(schema),
|
||||
new_key,
|
||||
partition_key_to_string(current_key.key(), schema),
|
||||
current_key.key().with_schema(schema),
|
||||
current_key,
|
||||
action.empty() ? "" : "; ",
|
||||
action);
|
||||
@@ -1298,9 +1299,9 @@ public:
|
||||
type,
|
||||
schema.ks_name(),
|
||||
schema.cf_name(),
|
||||
partition_key_to_string(new_key.key(), schema),
|
||||
new_key.key().with_schema(schema),
|
||||
new_key,
|
||||
partition_key_to_string(current_key.key(), schema),
|
||||
current_key.key().with_schema(schema),
|
||||
current_key,
|
||||
action.empty() ? "" : "; ",
|
||||
action);
|
||||
@@ -1318,7 +1319,7 @@ public:
|
||||
mf.mutation_fragment_kind(),
|
||||
mf.has_key() ? format(" with key {}", mf.key().with_schema(schema)) : "",
|
||||
mf.position(),
|
||||
partition_key_to_string(key.key(), schema),
|
||||
key.key().with_schema(schema),
|
||||
key,
|
||||
prev_pos.region(),
|
||||
prev_pos.has_key() ? format(" with key {}", prev_pos.key().with_schema(schema)) : "",
|
||||
@@ -1330,14 +1331,10 @@ public:
|
||||
const auto& schema = validator.schema();
|
||||
const auto& key = validator.previous_partition_key();
|
||||
clogger.error("[{} compaction {}.{}] Invalid end-of-stream, last partition {} ({}) didn't end with a partition-end fragment{}{}",
|
||||
type, schema.ks_name(), schema.cf_name(), partition_key_to_string(key.key(), schema), key, action.empty() ? "" : "; ", action);
|
||||
type, schema.ks_name(), schema.cf_name(), key.key().with_schema(schema), key, action.empty() ? "" : "; ", action);
|
||||
}
|
||||
|
||||
private:
|
||||
static sstring partition_key_to_string(const partition_key& key, const ::schema& s) {
|
||||
sstring ret = format("{}", key.with_schema(s));
|
||||
return utils::utf8::validate((const uint8_t*)ret.data(), ret.size()) ? ret : "<non-utf8-key>";
|
||||
}
|
||||
|
||||
class reader : public flat_mutation_reader_v2::impl {
|
||||
using skip = bool_class<class skip_tag>;
|
||||
|
||||
15
keys.cc
15
keys.cc
@@ -12,6 +12,7 @@
|
||||
#include "dht/i_partitioner.hh"
|
||||
#include "clustering_bounds_comparator.hh"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "utils/utf8.hh"
|
||||
|
||||
logging::logger klog("keys");
|
||||
|
||||
@@ -36,7 +37,19 @@ static std::ostream& print_key(std::ostream& out, const T& key_with_schema) {
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const partition_key::with_schema_wrapper& pk) {
|
||||
return print_key(out, pk);
|
||||
const auto& [schema, key] = pk;
|
||||
auto type_iterator = key.get_compound_type(schema)->types().begin();
|
||||
bool first = true;
|
||||
for (auto&& e : key.components(schema)) {
|
||||
if (!first) {
|
||||
out << ":";
|
||||
}
|
||||
first = false;
|
||||
auto keystr = (*type_iterator)->to_string(to_bytes(e));
|
||||
out << (utils::utf8::validate((const uint8_t *) keystr.data(), keystr.size()) ? keystr : "<non-utf8-key>");
|
||||
++type_iterator;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const clustering_key_prefix::with_schema_wrapper& ck) {
|
||||
|
||||
Reference in New Issue
Block a user