23 #ifndef OM_HGUARD_GLASS_CURSOR_H 24 #define OM_HGUARD_GLASS_CURSOR_H 36 #define BLK_UNUSED uint4(-1) 54 uint8_t *
init(
unsigned block_size) {
55 if (data &&
refs() > 1) {
60 data =
new char[block_size + 8];
65 return reinterpret_cast<uint8_t*
>(data + 8);
74 return reinterpret_cast<uint8_t*
>(data + 8);
78 std::swap(data, o.
data);
117 if (
rare(!data))
return NULL;
118 return reinterpret_cast<uint8_t*
>(data + 8);
122 if (
rare(!data))
return NULL;
124 char * new_data =
new char[block_size + 8];
125 std::memcpy(new_data, data, block_size + 8);
130 return reinterpret_cast<uint8_t*
>(data + 8);
208 void get_key(
string * key)
const;
258 bool read_tag(
bool keep_compressed =
false);
298 bool find_entry(
const string &key);
308 bool find_exact(
const string &key);
311 void find_entry_lt(
const string &key);
318 bool find_entry_ge(
const string &key);
bool is_after_end
Whether the cursor is off the end of the table.
Class managing a Btree table in a Glass database.
const GlassTable * B
The Btree table.
Cast a pointer we know is suitably aligned.
Definitions, types, etc for use inside glass.
bool after_end() const
Determine whether cursor is off the end of table.
int level
The value of level in the Btree structure.
std::enable_if< std::is_const< typename std::remove_pointer< U >::type >::value, T >::type alignment_cast(U ptr)
Cast a pointer we know is suitably aligned.
string current_key
Current key pointed to by cursor.
string current_tag
Current tag pointed to by cursor.
const uint8_t * clone(const Cursor &o)
uint8_t * get_modifiable_p(unsigned block_size)
A cursor pointing to a position in a Btree table, for reading several entries in order, or finding approximate matches.
GlassCursor * clone() const
Clone a cursor.
const GlassTable * get_table() const
Return a pointer to the GlassTable we're a cursor for.
int c
offset in the block's directory
char * data
Pointer to reference counted data.
MutableGlassCursor(GlassTable *B_)
Create a mutable cursor attached to a Btree.
bool is_positioned
Whether the cursor is positioned at a valid entry.
const uint8_t * get_p() const
Get pointer to block.
Various assertion macros.
Glass::Cursor * C
Pointer to an array of Cursors.
uint4 get_n() const
Get the block number.
Cursor & operator=(const Cursor &)
uint8_t * init(unsigned block_size)
bool rewrite
true if the block is not the same as on disk, and so needs rewriting
void to_end()
Set the cursor to be off the end of the table.