Skip to content

Commit

Permalink
Move PaginatedResponse from lib to cache
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen-stig committed Jun 4, 2024
1 parent f0e4498 commit 8d55b3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/cache/cache_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ use std::sync::Mutex;

use crate::cache::cache_container::CacheContainer;
use crate::cache::change_set::ChangeSet;
use crate::cache::SnapshotId;
use crate::cache::{PaginatedResponse, SnapshotId};
use crate::iterator::ScanDirection;
use crate::schema::KeyDecoder;
use crate::PaginatedResponse;
use crate::{
KeyCodec, Operation, ReadOnlyLock, Schema, SchemaBatch, SchemaKey, SchemaValue, SeekKeyEncoder,
ValueCodec,
Expand Down
5 changes: 2 additions & 3 deletions src/cache/delta_reader.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Module with `DeltaReader`, a handler of `DB` and uncommited snapshots.
use crate::cache::PaginatedResponse;
use crate::iterator::{RawDbIter, ScanDirection};
use crate::schema::{KeyCodec, KeyDecoder, ValueCodec};
use crate::{
Operation, PaginatedResponse, Schema, SchemaBatch, SchemaKey, SchemaValue, SeekKeyEncoder, DB,
};
use crate::{Operation, Schema, SchemaBatch, SchemaKey, SchemaValue, SeekKeyEncoder, DB};
use std::cmp::Ordering;
use std::collections::btree_map;
use std::iter::{Peekable, Rev};
Expand Down
12 changes: 12 additions & 0 deletions src/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
//! All structs related to caching layer of Rockbound.

use crate::Schema;

pub mod cache_container;
pub mod cache_db;
pub mod change_set;
pub mod delta_reader;

/// Id of ChangeSet/snapshot/cache layer
pub type SnapshotId = u64;

/// Response for a paginated query which also includes the "next" key to pass.
#[derive(Debug)]
pub struct PaginatedResponse<S: Schema> {
/// A vector of storage keys and their values
pub key_value: Vec<(S::Key, S::Value)>,
/// Key indicating the first key after the final pair from key_value.
/// Meant to be passed in subsequent queries
pub next: Option<S::Key>,
}
10 changes: 0 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,6 @@ impl<T> From<Arc<RwLock<T>>> for ReadOnlyLock<T> {
}
}

/// Response for a paginated query which also includes the "next" key to pass.
#[derive(Debug)]
pub struct PaginatedResponse<S: Schema> {
/// A vector of storage keys and their values
pub key_value: Vec<(S::Key, S::Value)>,
/// Key indicating the first key after the final pair from key_value.
/// Meant to be passed in subsequent queries
pub next: Option<S::Key>,
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 8d55b3a

Please sign in to comment.