Add seeking to the first page

master
Yury Kurlykov 2019-12-05 00:19:49 +10:00
parent 0cf4623c7a
commit 6e6c7df9a3
Signed by: t1meshift
GPG Key ID: B133F3167ABF94D8
2 changed files with 20 additions and 4 deletions

View File

@ -122,11 +122,16 @@ YDB_TablePage* ydb_get_current_page(YDB_Engine* instance);
YDB_Error ydb_delete_current_page(YDB_Engine* instance);
/**
* @brief Seek to the last page.
* @param instance A YeltsinDB instance
* @brief Seek to the first page.
* @param instance A YeltsinDB instance.
* @return Operation status.
*/
YDB_Error ydb_seek_to_begin(YDB_Engine* instance);
/**
* @brief Seek to the last page.
* @param instance A YeltsinDB instance.
* @return Operation status.
*
* @warning Could break an instance if ydb_
*/
YDB_Error ydb_seek_to_end(YDB_Engine* instance);

View File

@ -409,6 +409,17 @@ YDB_Error ydb_delete_current_page(YDB_Engine *instance) {
return __ydb_read_page(instance);
}
YDB_Error ydb_seek_to_begin(YDB_Engine *instance) {
THROW_IF_NULL(instance, YDB_ERR_INSTANCE_NOT_INITIALIZED);
THROW_IF_NULL(instance->in_use, YDB_ERR_INSTANCE_NOT_IN_USE);
if (instance->prev_page_offset == 0)
return YDB_ERR_SUCCESS;
instance->curr_page_offset = instance->prev_page_offset;
return __ydb_read_page(instance);
}
YDB_Error ydb_seek_to_end(YDB_Engine *instance) {
THROW_IF_NULL(instance, YDB_ERR_INSTANCE_NOT_INITIALIZED);
THROW_IF_NULL(instance->in_use, YDB_ERR_INSTANCE_NOT_IN_USE);