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) {
60 data =
new char[block_size + 8];
65 return reinterpret_cast<uint8_t*
>(
data + 8);
74 return reinterpret_cast<uint8_t*
>(
data + 8);
94 return *alignment_cast<uint4*>(
data);
103 return *alignment_cast<uint4*>(
data + 4);
109 *alignment_cast<uint4*>(
data + 4) = n;
118 return reinterpret_cast<uint8_t*
>(
data + 8);
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);
Cast a pointer we know is suitably aligned.
A cursor pointing to a position in a Btree table, for reading several entries in order,...
const GlassTable * get_table() const
Return a pointer to the GlassTable we're a cursor for.
GlassCursor & operator=(const GlassCursor &)
Assignment not allowed.
const GlassTable * B
The Btree table.
void get_key(string *key) const
Get the key.
GlassCursor * clone() const
Clone a cursor.
bool find_entry_ge(const string &key)
Position the cursor on the lowest entry with key >= key.
string current_key
Current key pointed to by cursor.
bool find_exact(const string &key)
Position the cursor exactly on a key.
bool after_end() const
Determine whether cursor is off the end of table.
bool find_entry(const string &key)
Position the cursor on the highest entry with key <= key.
void to_end()
Set the cursor to be off the end of the table.
bool read_tag(bool keep_compressed=false)
Read the tag from the table and store it in current_tag.
int level
The value of level in the Btree structure.
enum GlassCursor::@4 tag_status
Status of the current_tag member.
void rebuild()
Rebuild the cursor.
bool next()
Advance to the next key.
string current_tag
Current tag pointed to by cursor.
~GlassCursor()
Destroy the GlassCursor.
void find_entry_lt(const string &key)
Position the cursor on the highest entry with key < key.
bool is_after_end
Whether the cursor is off the end of the table.
bool is_positioned
Whether the cursor is positioned at a valid entry.
Glass::Cursor * C
Pointer to an array of Cursors.
GlassCursor(const GlassCursor &)
Copying not allowed.
Class managing a Btree table in a Glass database.
Cursor & operator=(const Cursor &)
uint8_t * init(unsigned block_size)
uint8_t * get_modifiable_p(unsigned block_size)
bool rewrite
true if the block is not the same as on disk, and so needs rewriting
int c
offset in the block's directory
uint4 get_n() const
Get the block number.
char * data
Pointer to reference counted data.
const uint8_t * clone(const Cursor &o)
const uint8_t * get_p() const
Get pointer to block.
MutableGlassCursor(GlassTable *B_)
Create a mutable cursor attached to a Btree.
bool del()
Delete the current key/tag pair, leaving the cursor on the next entry.
Definitions, types, etc for use inside glass.
Various assertion macros.