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,

source

pub fn new(disk_based: bool) -> Result<Graph<CT>, GraphAnnisCoreError>

Create a new and empty instance without any location on the disk.

source

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.

source

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 disk
  • preload - If true, all components are loaded from disk into main memory.
source

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.

source

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.

source

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.

source

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.

source

pub fn calculate_all_statistics(&mut self) -> Result<(), GraphAnnisCoreError>

(Re-) calculate the internal statistics needed for estimating graph components and annotations.

source

pub fn calculate_component_statistics( &mut self, c: &Component<CT> ) -> Result<(), GraphAnnisCoreError>

Makes sure the statistics for the given component are up-to-date.

source

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.

source

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.

source

pub fn ensure_loaded_all(&mut self) -> Result<(), GraphAnnisCoreError>

Ensure that the graph storages for all component are loaded and ready to use.

source

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.

source

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.

source

pub fn optimize_impl( &mut self, disk_based: bool ) -> Result<(), GraphAnnisCoreError>

source

pub fn optimize_gs_impl( &mut self, c: &Component<CT> ) -> Result<(), GraphAnnisCoreError>

source

pub fn get_graphstorage( &self, c: &Component<CT> ) -> Option<Arc<dyn GraphStorage>>

Get a read-only graph storage copy for the given component c.

source

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.

source

pub fn get_node_annos(&self) -> &dyn NodeAnnotationStorage

Get a read-only reference to the node annotations of this graph

source

pub fn get_node_annos_mut(&mut self) -> &mut dyn NodeAnnotationStorage

Get a mutable reference to the node annotations of this graph

source

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V