Trait graphannis::graph::AnnotationStorage

source ·
pub trait AnnotationStorage<T>: Send + Sync
where T: Send + Sync,
{
Show 23 methods // Required methods fn insert( &mut self, item: T, anno: Annotation ) -> Result<(), GraphAnnisCoreError>; fn get_all_keys_for_item( &self, item: &T, ns: Option<&str>, name: Option<&str> ) -> Result<Vec<Arc<AnnoKey>>, GraphAnnisCoreError>; fn remove_annotation_for_item( &mut self, item: &T, key: &AnnoKey ) -> Result<Option<Cow<'_, str>>, GraphAnnisCoreError>; fn clear(&mut self) -> Result<(), GraphAnnisCoreError>; fn get_qnames( &self, name: &str ) -> Result<Vec<AnnoKey>, GraphAnnisCoreError>; fn get_annotations_for_item( &self, item: &T ) -> Result<Vec<Annotation>, GraphAnnisCoreError>; fn get_value_for_item( &self, item: &T, key: &AnnoKey ) -> Result<Option<Cow<'_, str>>, GraphAnnisCoreError>; fn has_value_for_item( &self, item: &T, key: &AnnoKey ) -> Result<bool, GraphAnnisCoreError>; fn get_keys_for_iterator<'a>( &'a self, ns: Option<&str>, name: Option<&str>, it: Box<dyn Iterator<Item = Result<T, Box<dyn Error + Send + Sync>>> + 'a> ) -> Result<Vec<Match>, GraphAnnisCoreError>; fn number_of_annotations(&self) -> Result<usize, GraphAnnisCoreError>; fn is_empty(&self) -> Result<bool, GraphAnnisCoreError>; fn number_of_annotations_by_name( &self, ns: Option<&str>, name: &str ) -> Result<usize, GraphAnnisCoreError>; fn exact_anno_search<'a>( &'a self, namespace: Option<&str>, name: &str, value: ValueSearch<&str> ) -> Box<dyn Iterator<Item = Result<Match, GraphAnnisCoreError>> + 'a>; fn regex_anno_search<'a>( &'a self, namespace: Option<&str>, name: &str, pattern: &str, negated: bool ) -> Box<dyn Iterator<Item = Result<Match, GraphAnnisCoreError>> + 'a>; fn guess_max_count( &self, ns: Option<&str>, name: &str, lower_val: &str, upper_val: &str ) -> Result<usize, GraphAnnisCoreError>; fn guess_max_count_regex( &self, ns: Option<&str>, name: &str, pattern: &str ) -> Result<usize, GraphAnnisCoreError>; fn guess_most_frequent_value( &self, ns: Option<&str>, name: &str ) -> Result<Option<Cow<'_, str>>, GraphAnnisCoreError>; fn get_all_values( &self, key: &AnnoKey, most_frequent_first: bool ) -> Result<Vec<Cow<'_, str>>, GraphAnnisCoreError>; fn annotation_keys(&self) -> Result<Vec<AnnoKey>, GraphAnnisCoreError>; fn get_largest_item(&self) -> Result<Option<T>, GraphAnnisCoreError>; fn calculate_statistics(&mut self) -> Result<(), GraphAnnisCoreError>; fn load_annotations_from( &mut self, location: &Path ) -> Result<(), GraphAnnisCoreError>; fn save_annotations_to( &self, location: &Path ) -> Result<(), GraphAnnisCoreError>;
}
Expand description

Access annotations for nodes or edges.

Required Methods§

source

fn insert( &mut self, item: T, anno: Annotation ) -> Result<(), GraphAnnisCoreError>

Insert an annotation anno (with annotation key and value) for an item item.

source

fn get_all_keys_for_item( &self, item: &T, ns: Option<&str>, name: Option<&str> ) -> Result<Vec<Arc<AnnoKey>>, GraphAnnisCoreError>

Get all the annotation keys of a node, filtered by the optional namespace (ns) and name.

source

fn remove_annotation_for_item( &mut self, item: &T, key: &AnnoKey ) -> Result<Option<Cow<'_, str>>, GraphAnnisCoreError>

Remove the annotation given by its key for a specific item Returns the value for that annotation, if it existed.

source

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

Remove all annotations.

source

fn get_qnames(&self, name: &str) -> Result<Vec<AnnoKey>, GraphAnnisCoreError>

Get all qualified annotation names (including namespace) for a given annotation name

source

fn get_annotations_for_item( &self, item: &T ) -> Result<Vec<Annotation>, GraphAnnisCoreError>

Get all annotations for an item (node or edge).

source

fn get_value_for_item( &self, item: &T, key: &AnnoKey ) -> Result<Option<Cow<'_, str>>, GraphAnnisCoreError>

Get the annotation for a given item and the annotation key.

source

fn has_value_for_item( &self, item: &T, key: &AnnoKey ) -> Result<bool, GraphAnnisCoreError>

Returns true if the given item has an annotation for the given key.

source

fn get_keys_for_iterator<'a>( &'a self, ns: Option<&str>, name: Option<&str>, it: Box<dyn Iterator<Item = Result<T, Box<dyn Error + Send + Sync>>> + 'a> ) -> Result<Vec<Match>, GraphAnnisCoreError>

Get the matching annotation keys for each item in the iterator.

This function allows to filter the received annotation keys by specifying the namespace and name.

source

fn number_of_annotations(&self) -> Result<usize, GraphAnnisCoreError>

Return the total number of annotations contained in this AnnotationStorage.

source

fn is_empty(&self) -> Result<bool, GraphAnnisCoreError>

Return true if there are no annotations in this AnnotationStorage.

source

fn number_of_annotations_by_name( &self, ns: Option<&str>, name: &str ) -> Result<usize, GraphAnnisCoreError>

Return the number of annotations contained in this AnnotationStorage filtered by name and optional namespace (ns).

Returns an iterator for all items that exactly match the given annotation constraints. The annotation name must be given as argument, the other arguments are optional.

  • namespace- If given, only annotations having this namespace are returned.
  • name - Only annotations with this name are returned.
  • value - Constrain the value of the annotation.

The result is an iterator over matches. A match contains the node ID and the qualifed name of the matched annotation (e.g. there can be multiple annotations with the same name if the namespace is different).

Returns an iterator for all items where the value matches the regular expression. The annotation name and the pattern for the value must be given as argument, the
namespace argument is optional and can be used as additional constraint.

  • namespace- If given, only annotations having this namespace are returned.
  • name - Only annotations with this name are returned.
  • pattern - If given, only annotation having a value that mattches this pattern are returned.
  • negated - If true, find all annotations that do not match the value

The result is an iterator over matches. A match contains the node ID and the qualifed name of the matched annotation (e.g. there can be multiple annotations with the same name if the namespace is different).

source

fn guess_max_count( &self, ns: Option<&str>, name: &str, lower_val: &str, upper_val: &str ) -> Result<usize, GraphAnnisCoreError>

Estimate the number of results for an annotation exact search for a given an inclusive value range.

  • ns - If given, only annotations having this namespace are considered.
  • name - Only annotations with this name are considered.
  • lower_val- Inclusive lower bound for the annotation value.
  • upper_val- Inclusive upper bound for the annotation value.
source

fn guess_max_count_regex( &self, ns: Option<&str>, name: &str, pattern: &str ) -> Result<usize, GraphAnnisCoreError>

Estimate the number of results for an annotation regular expression search for a given pattern.

  • ns - If given, only annotations having this namespace are considered.
  • name - Only annotations with this name are considered.
  • pattern- The regular expression pattern.
source

fn guess_most_frequent_value( &self, ns: Option<&str>, name: &str ) -> Result<Option<Cow<'_, str>>, GraphAnnisCoreError>

Estimate the most frequent value for a given annotation name with an optional namespace (ns).

If more than one qualified annotation name matches the defnition, the more frequent value is used.

source

fn get_all_values( &self, key: &AnnoKey, most_frequent_first: bool ) -> Result<Vec<Cow<'_, str>>, GraphAnnisCoreError>

Return a list of all existing values for a given annotation key. If the most_frequent_first parameter is true, the results are sorted by their frequency.

source

fn annotation_keys(&self) -> Result<Vec<AnnoKey>, GraphAnnisCoreError>

Get all the annotation keys which are part of this annotation storage

source

fn get_largest_item(&self) -> Result<Option<T>, GraphAnnisCoreError>

Return the item with the largest item which has an annotation value in this annotation storage.

This can be used to calculate new IDs for new items.

source

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

(Re-) calculate the internal statistics needed for estimating annotation values.

An annotation storage can invalid statistics, in which case the estimation function will not return valid results.

source

fn load_annotations_from( &mut self, location: &Path ) -> Result<(), GraphAnnisCoreError>

Load the annotation from an external location.

source

fn save_annotations_to( &self, location: &Path ) -> Result<(), GraphAnnisCoreError>

Save the current annotation to a location on the disk, but do not remember this location.

Implementors§

source§

impl<T> AnnotationStorage<T> for graphannis_core::annostorage::inmemory::AnnoStorageImpl<T>

source§

impl<T> AnnotationStorage<T> for graphannis_core::annostorage::ondisk::AnnoStorageImpl<T>