server_storage core topic OKM object key/col/value mapping

pull/19/head
Niko PLP 7 months ago
parent 5b9c1d67fd
commit 4ba34c7300
  1. 4
      ng-broker/src/server_broker.rs
  2. 31
      ng-broker/src/server_storage/core/topic.rs
  3. 2
      ng-net/src/actors/client/pin_repo.rs
  4. 14
      ng-repo/src/kcv_storage.rs

@ -21,14 +21,14 @@ use ng_repo::{
use crate::rocksdb_server_storage::RocksDbServerStorage; use crate::rocksdb_server_storage::RocksDbServerStorage;
struct TopicInfo { pub struct TopicInfo {
repo: RepoHash, repo: RepoHash,
publisher_advert: Option<PublisherAdvert>, publisher_advert: Option<PublisherAdvert>,
current_heads: HashSet<ObjectId>, current_heads: HashSet<ObjectId>,
expose_outer: bool, root_commit: Option<ObjectId>,
/// indicates which users have opened the topic (boolean says if as publisher or not) /// indicates which users have opened the topic (boolean says if as publisher or not)
users: HashMap<UserId, bool>, users: HashMap<UserId, bool>,

@ -19,6 +19,8 @@ use ng_repo::types::*;
use serde_bare::to_vec; use serde_bare::to_vec;
use crate::server_broker::TopicInfo;
pub struct Topic<'a> { pub struct Topic<'a> {
key: Vec<u8>, key: Vec<u8>,
repo: ExistentialValue<RepoHash>, repo: ExistentialValue<RepoHash>,
@ -60,18 +62,23 @@ impl<'a> Topic<'a> {
vec![&Self::USERS, &Self::HEADS], vec![&Self::USERS, &Self::HEADS],
); );
pub fn load(&self) -> Result<(), StorageError> { pub fn load(
let props = self.load_props()?; id: &TopicId,
// let bs = BranchInfo { overlay: &OverlayId,
// id: id.clone(), storage: &'a dyn KCVStorage,
// branch_type: prop(Self::TYPE, &props)?, ) -> Result<TopicInfo, StorageError> {
// read_cap: prop(Self::READ_CAP, &props)?, let mut opening = Topic::new(id, overlay, storage);
// topic: prop(Self::TOPIC, &props)?, let props = opening.load_props()?;
// topic_priv_key: prop(Self::PUBLISHER, &props).ok(), let existential = col(&Self::REPO, &props)?;
// current_heads: Self::get_all_heads(id, storage)?, opening.repo.set(&existential, &opening)?;
// }; let ti = TopicInfo {
// Ok(bs) repo: existential,
Ok(()) publisher_advert: col(&Self::ADVERT, &props).ok(),
root_commit: col(&Self::ROOT_COMMIT, &props).ok(),
users: Self::USERS.get_all(&mut opening)?,
current_heads: Self::HEADS.get_all(&mut opening)?,
};
Ok(ti)
} }
pub fn new(id: &TopicId, overlay: &OverlayId, storage: &'a dyn KCVStorage) -> Self { pub fn new(id: &TopicId, overlay: &OverlayId, storage: &'a dyn KCVStorage) -> Self {

@ -48,7 +48,7 @@ impl PinRepo {
expose_outer: false, expose_outer: false,
peers: vec![], peers: vec![],
max_peer_count: 0, max_peer_count: 0,
allowed_peers: vec![], //allowed_peers: vec![],
ro_topics, ro_topics,
rw_topics, rw_topics,
}) })

@ -24,6 +24,20 @@ where
)?) )?)
} }
pub fn col<A>(
column: &dyn ISingleValueColumn,
props: &HashMap<u8, Vec<u8>>,
) -> Result<A, StorageError>
where
A: for<'a> Deserialize<'a>,
{
Ok(from_slice(
&props
.get(&column.suffix())
.ok_or(StorageError::PropertyNotFound)?,
)?)
}
pub struct Class<'a> { pub struct Class<'a> {
columns: Vec<&'a dyn ISingleValueColumn>, columns: Vec<&'a dyn ISingleValueColumn>,
multi_value_columns: Vec<&'a dyn IMultiValueColumn>, multi_value_columns: Vec<&'a dyn IMultiValueColumn>,

Loading…
Cancel
Save