Add seeking to the first page
parent
0cf4623c7a
commit
6e6c7df9a3
|
@ -122,11 +122,16 @@ YDB_TablePage* ydb_get_current_page(YDB_Engine* instance);
|
||||||
YDB_Error ydb_delete_current_page(YDB_Engine* instance);
|
YDB_Error ydb_delete_current_page(YDB_Engine* instance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Seek to the last page.
|
* @brief Seek to the first page.
|
||||||
* @param instance A YeltsinDB instance
|
* @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.
|
* @return Operation status.
|
||||||
*
|
|
||||||
* @warning Could break an instance if ydb_
|
|
||||||
*/
|
*/
|
||||||
YDB_Error ydb_seek_to_end(YDB_Engine* instance);
|
YDB_Error ydb_seek_to_end(YDB_Engine* instance);
|
||||||
|
|
||||||
|
|
11
src/ydb.c
11
src/ydb.c
|
@ -409,6 +409,17 @@ YDB_Error ydb_delete_current_page(YDB_Engine *instance) {
|
||||||
return __ydb_read_page(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) {
|
YDB_Error ydb_seek_to_end(YDB_Engine *instance) {
|
||||||
THROW_IF_NULL(instance, YDB_ERR_INSTANCE_NOT_INITIALIZED);
|
THROW_IF_NULL(instance, YDB_ERR_INSTANCE_NOT_INITIALIZED);
|
||||||
THROW_IF_NULL(instance->in_use, YDB_ERR_INSTANCE_NOT_IN_USE);
|
THROW_IF_NULL(instance->in_use, YDB_ERR_INSTANCE_NOT_IN_USE);
|
||||||
|
|
Loading…
Reference in New Issue