mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 09:30:45 +00:00
db: store keys and values as serialized bytes, not boost::any
While less efficient, it's similar to what origin does, so will be easier to follow.
This commit is contained in:
11
database.cc
11
database.cc
@@ -90,3 +90,14 @@ data_type ascii_type(new string_type_impl("ascii"));
|
||||
data_type blob_type(new blob_type_impl);
|
||||
data_type varchar_type(new string_type_impl("varchar"));
|
||||
data_type text_type(new string_type_impl("text"));
|
||||
|
||||
partition::partition(column_family& cf)
|
||||
: rows(key_compare(cf.clustering_key_type)) {
|
||||
}
|
||||
|
||||
column_family::column_family(data_type partition_key_type,
|
||||
data_type clustering_key_type)
|
||||
: partition_key_type(std::move(partition_key_type))
|
||||
, clustering_key_type(std::move(clustering_key_type))
|
||||
, partitions(key_compare(partition_key_type)) {
|
||||
}
|
||||
|
||||
25
database.hh
25
database.hh
@@ -67,16 +67,28 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct row {
|
||||
std::vector<boost::any> cells;
|
||||
class key_compare {
|
||||
data_type _type;
|
||||
public:
|
||||
key_compare(data_type type) : _type(type) {}
|
||||
bool operator()(const bytes& v1, const bytes& v2) const {
|
||||
return _type.less(v1, v2);
|
||||
}
|
||||
};
|
||||
|
||||
using key_compare = std::function<bool (const boost::any&, const boost::any&)>;
|
||||
struct row;
|
||||
struct paritition;
|
||||
struct column_family;
|
||||
|
||||
struct row {
|
||||
std::vector<bytes> cells;
|
||||
};
|
||||
|
||||
struct partition {
|
||||
explicit partition(column_family& cf);
|
||||
row static_columns;
|
||||
// row key within partition -> row
|
||||
std::map<boost::any, row, key_compare> rows;
|
||||
std::map<bytes, row, key_compare> rows;
|
||||
};
|
||||
|
||||
// FIXME: add missing types
|
||||
@@ -93,13 +105,16 @@ struct column_definition {
|
||||
};
|
||||
|
||||
struct column_family {
|
||||
column_family(data_type partition_key_type, data_type clustering_key_type);
|
||||
// primary key = paritition key + clustering_key
|
||||
data_type partition_key_type;
|
||||
data_type clustering_key_type;
|
||||
std::vector<column_definition> partition_key;
|
||||
std::vector<column_definition> clustering_key;
|
||||
std::vector<column_definition> column_defs;
|
||||
std::unordered_map<sstring, unsigned> column_names;
|
||||
// partition key -> partition
|
||||
std::map<boost::any, partition, key_compare> partitions;
|
||||
std::map<bytes, partition, key_compare> partitions;
|
||||
};
|
||||
|
||||
struct keyspace {
|
||||
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
}
|
||||
keyspace& ks = _db.keyspaces[ks_def.name];
|
||||
for (const CfDef& cf_def : ks_def.cf_defs) {
|
||||
column_family& cf = ks.column_families[cf_def.name];
|
||||
column_family cf(blob_type, blob_type);
|
||||
// FIXME: look at key_alias and key_validator first
|
||||
cf.partition_key.push_back(column_definition{"key", blob_type});
|
||||
// FIXME: guess clustering keys
|
||||
@@ -252,6 +252,7 @@ public:
|
||||
blob_type,
|
||||
});
|
||||
}
|
||||
ks.column_families.emplace(cf_def.name, std::move(cf));
|
||||
}
|
||||
cob(schema_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user