mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
cursor: add is_empty
This commit is contained in:
@@ -156,6 +156,12 @@ pub unsafe extern "C" fn MVCCScanCursorOpen(db: MVCCDatabaseRef) -> MVCCScanCurs
|
||||
let (database, runtime) = (&database.db, &database.runtime);
|
||||
match runtime.block_on(async move { mvcc_rs::cursor::ScanCursor::new(database).await }) {
|
||||
Ok(cursor) => {
|
||||
if cursor.is_empty() {
|
||||
tracing::debug!("Cursor is empty");
|
||||
return MVCCScanCursorRef {
|
||||
ptr: std::ptr::null_mut(),
|
||||
};
|
||||
}
|
||||
tracing::debug!("Cursor open: {cursor:?}");
|
||||
MVCCScanCursorRef {
|
||||
ptr: Box::into_raw(Box::new(ScanCursorContext { cursor, db })),
|
||||
@@ -249,4 +255,4 @@ pub unsafe extern "C" fn MVCCScanCursorPosition(cursor: MVCCScanCursorRef) -> u6
|
||||
let cursor_ctx = unsafe { &mut *cursor.ptr };
|
||||
let cursor = &mut cursor_ctx.cursor;
|
||||
cursor.current_row_id().unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,8 @@ impl<
|
||||
self.index += 1;
|
||||
self.index < self.row_ids.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.index >= self.row_ids.len()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user