Struct graphannis::Graph
source · pub struct Graph<CT>where
CT: ComponentType,{
pub global_statistics: Option<<CT as ComponentType>::GlobalStatistics>,
/* 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.
Fields§
§global_statistics: Option<<CT as ComponentType>::GlobalStatistics>
Implementations§
source§impl<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>
pub fn apply_update<F>( &mut self, u: &mut GraphUpdate, progress_callback: F ) -> Result<(), GraphAnnisCoreError>
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_all_statistics(&mut self) -> Result<(), GraphAnnisCoreError>
pub fn calculate_all_statistics(&mut self) -> Result<(), GraphAnnisCoreError>
(Re-) calculate the internal statistics needed for estimating graph components and annotations.
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.
sourcepub fn ensure_loaded_parallel(
&mut self,
components_to_load: &[Component<CT>]
) -> Result<(), GraphAnnisCoreError>
pub fn ensure_loaded_parallel( &mut self, components_to_load: &[Component<CT>] ) -> Result<(), GraphAnnisCoreError>
Ensure that the graph storage for a the given component is loaded and ready to use. Loading is done in paralell.
pub fn optimize_impl( &mut self, disk_based: bool ) -> Result<(), GraphAnnisCoreError>
pub fn optimize_gs_impl( &mut self, c: &Component<CT> ) -> Result<(), GraphAnnisCoreError>
sourcepub fn get_graphstorage(
&self,
c: &Component<CT>
) -> Option<Arc<dyn GraphStorage>>
pub fn get_graphstorage( &self, c: &Component<CT> ) -> Option<Arc<dyn GraphStorage>>
Get a read-only graph storage copy for the given component c
.
sourcepub fn get_graphstorage_as_ref<'a>(
&'a self,
c: &Component<CT>
) -> Option<&'a dyn GraphStorage>
pub fn get_graphstorage_as_ref<'a>( &'a self, c: &Component<CT> ) -> Option<&'a dyn GraphStorage>
Get a read-only graph storage reference for the given component c
.
sourcepub fn get_node_annos(&self) -> &dyn NodeAnnotationStorage
pub fn get_node_annos(&self) -> &dyn NodeAnnotationStorage
Get a read-only reference to the node annotations of this graph
sourcepub fn get_node_annos_mut(&mut self) -> &mut dyn NodeAnnotationStorage
pub fn get_node_annos_mut(&mut self) -> &mut dyn NodeAnnotationStorage
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>>
pub fn get_all_components( &self, ctype: Option<CT>, name: Option<&str> ) -> Vec<Component<CT>>
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.
Auto Trait Implementations§
impl<CT> Freeze for Graph<CT>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more