|
|
@ -76,56 +76,67 @@ impl Storage { |
|
|
|
name: ID2STR_CF, |
|
|
|
name: ID2STR_CF, |
|
|
|
use_iter: false, |
|
|
|
use_iter: false, |
|
|
|
min_prefix_size: 0, |
|
|
|
min_prefix_size: 0, |
|
|
|
|
|
|
|
unordered_writes: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: SPOG_CF, |
|
|
|
name: SPOG_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: POSG_CF, |
|
|
|
name: POSG_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named node start
|
|
|
|
min_prefix_size: 17, // named node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: OSPG_CF, |
|
|
|
name: OSPG_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 0, // There are small literals...
|
|
|
|
min_prefix_size: 0, // There are small literals...
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: GSPO_CF, |
|
|
|
name: GSPO_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: GPOS_CF, |
|
|
|
name: GPOS_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: GOSP_CF, |
|
|
|
name: GOSP_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: DSPO_CF, |
|
|
|
name: DSPO_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: DPOS_CF, |
|
|
|
name: DPOS_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: DOSP_CF, |
|
|
|
name: DOSP_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 0, // There are small literals...
|
|
|
|
min_prefix_size: 0, // There are small literals...
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ColumnFamilyDefinition { |
|
|
|
ColumnFamilyDefinition { |
|
|
|
name: GRAPHS_CF, |
|
|
|
name: GRAPHS_CF, |
|
|
|
use_iter: true, |
|
|
|
use_iter: true, |
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
min_prefix_size: 17, // named or blank node start
|
|
|
|
|
|
|
|
unordered_writes: false, |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
@ -194,7 +205,7 @@ impl Storage { |
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
fn ensure_version(&self) -> Result<u64, StorageError> { |
|
|
|
fn ensure_version(&self) -> Result<u64, StorageError> { |
|
|
|
Ok( |
|
|
|
Ok( |
|
|
|
if let Some(version) = self.db.snapshot().get(&self.default_cf, b"oxversion")? { |
|
|
|
if let Some(version) = self.db.get(&self.default_cf, b"oxversion")? { |
|
|
|
let mut buffer = [0; 8]; |
|
|
|
let mut buffer = [0; 8]; |
|
|
|
buffer.copy_from_slice(&version); |
|
|
|
buffer.copy_from_slice(&version); |
|
|
|
u64::from_be_bytes(buffer) |
|
|
|
u64::from_be_bytes(buffer) |
|
|
@ -207,9 +218,8 @@ impl Storage { |
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
fn update_version(&self, version: u64) -> Result<(), StorageError> { |
|
|
|
fn update_version(&self, version: u64) -> Result<(), StorageError> { |
|
|
|
self.db.transaction(|mut t| { |
|
|
|
self.db |
|
|
|
t.insert(&self.default_cf, b"oxversion", &version.to_be_bytes()) |
|
|
|
.insert(&self.default_cf, b"oxversion", &version.to_be_bytes())?; |
|
|
|
})?; |
|
|
|
|
|
|
|
self.db.flush(&self.default_cf) |
|
|
|
self.db.flush(&self.default_cf) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -583,6 +593,18 @@ impl StorageReader { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
|
|
|
|
pub fn get_str(&self, key: &StrHash) -> Result<Option<String>, StorageError> { |
|
|
|
|
|
|
|
Ok(self |
|
|
|
|
|
|
|
.storage |
|
|
|
|
|
|
|
.db |
|
|
|
|
|
|
|
.get(&self.storage.id2str_cf, &key.to_be_bytes())? |
|
|
|
|
|
|
|
.map(|v| String::from_utf8(v.into())) |
|
|
|
|
|
|
|
.transpose() |
|
|
|
|
|
|
|
.map_err(CorruptionError::new)?) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")] |
|
|
|
pub fn get_str(&self, key: &StrHash) -> Result<Option<String>, StorageError> { |
|
|
|
pub fn get_str(&self, key: &StrHash) -> Result<Option<String>, StorageError> { |
|
|
|
Ok(self |
|
|
|
Ok(self |
|
|
|
.reader |
|
|
|
.reader |
|
|
@ -592,6 +614,14 @@ impl StorageReader { |
|
|
|
.map_err(CorruptionError::new)?) |
|
|
|
.map_err(CorruptionError::new)?) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
|
|
|
|
pub fn contains_str(&self, key: &StrHash) -> Result<bool, StorageError> { |
|
|
|
|
|
|
|
self.storage |
|
|
|
|
|
|
|
.db |
|
|
|
|
|
|
|
.contains_key(&self.storage.id2str_cf, &key.to_be_bytes()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")] |
|
|
|
pub fn contains_str(&self, key: &StrHash) -> Result<bool, StorageError> { |
|
|
|
pub fn contains_str(&self, key: &StrHash) -> Result<bool, StorageError> { |
|
|
|
self.reader |
|
|
|
self.reader |
|
|
|
.contains_key(&self.storage.id2str_cf, &key.to_be_bytes()) |
|
|
|
.contains_key(&self.storage.id2str_cf, &key.to_be_bytes()) |
|
|
@ -819,6 +849,23 @@ impl<'a> StorageWriter<'a> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))] |
|
|
|
|
|
|
|
fn insert_str(&mut self, key: &StrHash, value: &str) -> Result<(), StorageError> { |
|
|
|
|
|
|
|
if self |
|
|
|
|
|
|
|
.storage |
|
|
|
|
|
|
|
.db |
|
|
|
|
|
|
|
.contains_key(&self.storage.id2str_cf, &key.to_be_bytes())? |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Ok(()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.storage.db.insert( |
|
|
|
|
|
|
|
&self.storage.id2str_cf, |
|
|
|
|
|
|
|
&key.to_be_bytes(), |
|
|
|
|
|
|
|
value.as_bytes(), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")] |
|
|
|
fn insert_str(&mut self, key: &StrHash, value: &str) -> Result<(), StorageError> { |
|
|
|
fn insert_str(&mut self, key: &StrHash, value: &str) -> Result<(), StorageError> { |
|
|
|
self.transaction.insert( |
|
|
|
self.transaction.insert( |
|
|
|
&self.storage.id2str_cf, |
|
|
|
&self.storage.id2str_cf, |
|
|
|