[caching] hint support

This commit is contained in:
Joe Thornber
2013-09-24 12:00:09 +01:00
parent 2e58332e49
commit 17f7c982f2
6 changed files with 192 additions and 6 deletions

View File

@ -13,22 +13,44 @@ namespace caching {
struct hint_traits {
typedef unsigned char byte;
typedef byte disk_type[WIDTH];
typedef byte value_type[WIDTH];
typedef vector<byte> value_type;
typedef no_op_ref_counter<value_type> ref_counter;
// FIXME: slow copying for now
static void unpack(disk_type const &disk, value_type &value) {
::memcpy(value, disk, sizeof(value));
for (unsigned byte = 0; byte < WIDTH; byte++)
value[byte] = disk[byte];
}
static void pack(value_type const &value, disk_type &disk) {
::memcpy(disk, value, sizeof(disk));
for (unsigned byte = 0; byte < WIDTH; byte++)
disk[byte] = value[byte];
}
};
// FIXME: data visitor stuff
}
// typedef persistent_data::array<mapping_array_detail::hint_traits> hint_array;
class hint_array {
public:
typedef boost::shared_ptr<hint_array> ptr;
typedef typename persistent_data::transaction_manager::ptr tm_ptr;
hint_array(tm_ptr tm, unsigned width);
hint_array(tm_ptr tm, unsigned width, block_address root, unsigned nr_entries);
unsigned get_nr_entries() const;
void grow(unsigned new_nr_entries, void const *v);
block_address get_root() const;
void get_hint(unsigned index, vector<unsigned char> &data) const;
void set_hint(unsigned index, vector<unsigned char> const &data);
private:
unsigned width_;
boost::shared_ptr<persistent_data::array_base> impl_;
};
}
//----------------------------------------------------------------