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§

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_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 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_node_id_from_name( &self, node_name: &str ) -> Result<Option<u64>, GraphAnnisCoreError>

source

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

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 AnnotationStorage<u64>

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

source

pub fn get_node_annos_mut(&mut self) -> &mut dyn AnnotationStorage<u64>

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>, Global>

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.

source

pub fn size_of_cached( &self, ops: &mut MallocSizeOfOps ) -> Result<usize, GraphAnnisCoreError>

Trait Implementations§

source§

impl<CT> MallocSizeOf for Graph<CT>where CT: ComponentType,

source§

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.

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V