Struct graphannis::Graph
source · [−]pub struct Graph<CT> where
CT: ComponentType, { /* private fields */ }
Expand description
A representation of a graph including node annotations and edges. Edges are partioned into components and each component is implemented by specialized graph storage implementation.
Graphs can have an optional location on the disk. In this case, changes to the graph via the apply_update(…) function are automatically persisted to this location.
Implementations
sourceimpl<CT> Graph<CT> where
CT: ComponentType,
impl<CT> Graph<CT> where
CT: ComponentType,
sourcepub fn new(disk_based: bool) -> Result<Graph<CT>, GraphAnnisCoreError>
pub fn new(disk_based: bool) -> Result<Graph<CT>, GraphAnnisCoreError>
Create a new and empty instance without any location on the disk.
sourcepub fn with_default_graphstorages(
disk_based: bool
) -> Result<Graph<CT>, GraphAnnisCoreError>
pub fn with_default_graphstorages(
disk_based: bool
) -> Result<Graph<CT>, GraphAnnisCoreError>
Create a new instance without any location on the disk but with the default graph storage components.
sourcepub fn load_from(
&mut self,
location: &Path,
preload: bool
) -> Result<(), GraphAnnisCoreError>
pub fn load_from(
&mut self,
location: &Path,
preload: bool
) -> Result<(), GraphAnnisCoreError>
Load the graph from an external location. This sets the location of this instance to the given location.
location
- The path on the diskpreload
- Iftrue
, all components are loaded from disk into main memory.
sourcepub fn save_to(&mut self, location: &Path) -> Result<(), GraphAnnisCoreError>
pub fn save_to(&mut self, location: &Path) -> Result<(), GraphAnnisCoreError>
Save the current database to a location
on the disk, but do not remember this location.
sourcepub fn persist_to(&mut self, location: &Path) -> Result<(), GraphAnnisCoreError>
pub fn persist_to(&mut self, location: &Path) -> Result<(), GraphAnnisCoreError>
Save the current database at a new location
and remember it as new internal location.
sourcepub fn apply_update<F>(
&mut self,
u: &mut GraphUpdate,
progress_callback: F
) -> Result<(), GraphAnnisCoreError> where
F: Fn(&str),
pub fn apply_update<F>(
&mut self,
u: &mut GraphUpdate,
progress_callback: F
) -> Result<(), GraphAnnisCoreError> where
F: Fn(&str),
Apply a sequence of updates (u
parameter) to this graph.
If the graph has a location on the disk, the changes are persisted.
sourcepub fn background_sync_wal_updates(&self) -> Result<(), GraphAnnisCoreError>
pub fn background_sync_wal_updates(&self) -> Result<(), GraphAnnisCoreError>
A function to persist the changes of a write-ahead-log update on the disk. Should be run in a background thread.
sourcepub fn calculate_component_statistics(
&mut self,
c: &Component<CT>
) -> Result<(), GraphAnnisCoreError>
pub fn calculate_component_statistics(
&mut self,
c: &Component<CT>
) -> Result<(), GraphAnnisCoreError>
Makes sure the statistics for the given component are up-to-date.
sourcepub fn get_or_create_writable(
&mut self,
c: &Component<CT>
) -> Result<&mut dyn WriteableGraphStorage, GraphAnnisCoreError>
pub fn get_or_create_writable(
&mut self,
c: &Component<CT>
) -> Result<&mut dyn WriteableGraphStorage, GraphAnnisCoreError>
Gets the the given component. If the component does not exist yet, it creates a new empty one. If the existing component is non-writable, a writable copy of it is created and returned.
sourcepub fn is_loaded(&self, c: &Component<CT>) -> bool
pub fn is_loaded(&self, c: &Component<CT>) -> bool
Returns true
if the graph storage for this specific component is loaded and ready to use.
sourcepub fn ensure_loaded_all(&mut self) -> Result<(), GraphAnnisCoreError>
pub fn ensure_loaded_all(&mut self) -> Result<(), GraphAnnisCoreError>
Ensure that the graph storages for all component are loaded and ready to use.
sourcepub fn ensure_loaded(
&mut self,
c: &Component<CT>
) -> Result<(), GraphAnnisCoreError>
pub fn ensure_loaded(
&mut self,
c: &Component<CT>
) -> Result<(), GraphAnnisCoreError>
Ensure that the graph storage for a specific component is loaded and ready to use.
pub fn optimize_impl(
&mut self,
disk_based: bool
) -> Result<(), GraphAnnisCoreError>
pub fn optimize_gs_impl(
&mut self,
c: &Component<CT>
) -> Result<(), GraphAnnisCoreError>
pub fn get_node_id_from_name(
&self,
node_name: &str
) -> Result<Option<u64>, GraphAnnisCoreError>
sourcepub fn get_graphstorage(
&self,
c: &Component<CT>
) -> Option<Arc<dyn GraphStorage + 'static>>
pub fn get_graphstorage(
&self,
c: &Component<CT>
) -> Option<Arc<dyn GraphStorage + 'static>>
Get a read-only graph storage copy for the given component c
.
sourcepub fn get_graphstorage_as_ref(
&'a self,
c: &Component<CT>
) -> Option<&'a (dyn GraphStorage + 'a)>
pub fn get_graphstorage_as_ref(
&'a self,
c: &Component<CT>
) -> Option<&'a (dyn GraphStorage + 'a)>
Get a read-only graph storage reference for the given component c
.
sourcepub fn get_node_annos(&self) -> &dyn AnnotationStorage<u64>
pub fn get_node_annos(&self) -> &dyn AnnotationStorage<u64>
Get a read-only reference to the node annotations of this graph
sourcepub fn get_node_annos_mut(&mut self) -> &mut dyn AnnotationStorage<u64>
pub fn get_node_annos_mut(&mut self) -> &mut dyn AnnotationStorage<u64>
Get a mutable reference to the node annotations of this graph
sourcepub fn get_all_components(
&self,
ctype: Option<CT>,
name: Option<&str>
) -> Vec<Component<CT>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_all_components(
&self,
ctype: Option<CT>,
name: Option<&str>
) -> Vec<Component<CT>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns all components of the graph given an optional type (ctype
) and name
.
This allows to filter which components to receive.
If you want to retrieve all components, use None
as value for both arguments.
pub fn size_of_cached(
&self,
ops: &mut MallocSizeOfOps
) -> Result<usize, GraphAnnisCoreError>
Trait Implementations
sourceimpl<CT> MallocSizeOf for Graph<CT> where
CT: ComponentType,
impl<CT> MallocSizeOf for Graph<CT> where
CT: ComponentType,
sourcefn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself. Read more
Auto Trait Implementations
impl<CT> !RefUnwindSafe for Graph<CT>
impl<CT> Send for Graph<CT>
impl<CT> Sync for Graph<CT>
impl<CT> Unpin for Graph<CT>
impl<CT> !UnwindSafe for Graph<CT>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more