mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 10:30:38 +00:00
Profiling alternator implied that JSON parsing takes up a fair amount of CPU, and as such should be optimized. libjsoncpp is a standard library for handling JSON objects, but it also proves slower than rapidjson, which is hereby used instead. The results indicated that libjsoncpp used roughly 30% of CPU for a single-shard alternator instance under stress, while rapidjson dropped that usage to 18% without optimizations. Future optimizations should include eliding object copying, string copying and perhaps experimenting with different JSON allocators.
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
/*
|
|
* Copyright 2019 ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* This file is part of Scylla.
|
|
*
|
|
* See the LICENSE.PROPRIETARY file in the top-level directory for licensing information.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include "types.hh"
|
|
#include "schema.hh"
|
|
#include "keys.hh"
|
|
#include "rjson.hh"
|
|
|
|
namespace alternator {
|
|
|
|
enum class alternator_type : int8_t {
|
|
S, B, BOOL, N, NOT_SUPPORTED_YET
|
|
};
|
|
|
|
struct type_info {
|
|
alternator_type atype;
|
|
data_type dtype;
|
|
};
|
|
|
|
struct type_representation {
|
|
std::string ident;
|
|
data_type dtype;
|
|
};
|
|
|
|
type_info type_info_from_string(std::string type);
|
|
type_representation represent_type(alternator_type atype);
|
|
|
|
bytes serialize_item(const rjson::value& item);
|
|
rjson::value deserialize_item(bytes_view bv);
|
|
|
|
std::string type_to_string(data_type type);
|
|
|
|
bytes get_key_column_value(const rjson::value& item, const column_definition& column);
|
|
rjson::value json_key_column_value(bytes_view cell, const column_definition& column);
|
|
|
|
partition_key pk_from_json(const rjson::value& item, schema_ptr schema);
|
|
clustering_key ck_from_json(const rjson::value& item, schema_ptr schema);
|
|
|
|
}
|