oc_ocdm.counter_handler.in_memory_counter_handler module

class oc_ocdm.counter_handler.in_memory_counter_handler.InMemoryCounterHandler[source]

Bases: oc_ocdm.counter_handler.counter_handler.CounterHandler

A concrete implementation of the CounterHandler interface that temporarily stores the counter values in the volatile system memory.

Constructor of the InMemoryCounterHandler class.

Return type

None

set_counter(new_value, entity_short_name, prov_short_name='', identifier=1)[source]

It allows to set the counter value of graph and provenance entities.

Parameters
  • new_value (int) – The new counter value to be set

  • entity_short_name (str) – The short name associated either to the type of the entity itself or, in case of a provenance entity, to the type of the relative graph entity.

  • prov_short_name (str) – In case of a provenance entity, the short name associated to the type of the entity itself. An empty string otherwise.

  • identifier (int) – In case of a provenance entity, the counter value that identifies the relative graph entity. The integer value ‘1’ otherwise.

Raises

ValueError – if new_value is a negative integer, identifier is less than or equal to zero, entity_short_name is not a known short name or prov_short_name is not a known provenance short name.

Returns

None

Return type

None

read_counter(entity_short_name, prov_short_name='', identifier=1)[source]

It allows to read the counter value of graph and provenance entities.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself or, in case of a provenance entity, to the type of the relative graph entity.

  • prov_short_name (str) – In case of a provenance entity, the short name associated to the type of the entity itself. An empty string otherwise.

  • identifier (int) – In case of a provenance entity, the counter value that identifies the relative graph entity. The integer value ‘1’ otherwise.

Raises

ValueError – if identifier is less than or equal to zero, entity_short_name is not a known short name or prov_short_name is not a known provenance short name.

Returns

The requested counter value.

Return type

int

increment_counter(entity_short_name, prov_short_name='', identifier=1)[source]

It allows to increment the counter value of graph and provenance entities by one unit.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself or, in case of a provenance entity, to the type of the relative graph entity.

  • prov_short_name (str) – In case of a provenance entity, the short name associated to the type of the entity itself. An empty string otherwise.

  • identifier (int) – In case of a provenance entity, the counter value that identifies the relative graph entity. The integer value ‘1’ otherwise.

Raises

ValueError – if identifier is less than or equal to zero, entity_short_name is not a known short name or prov_short_name is not a known provenance short name.

Returns

The newly-updated (already incremented) counter value.

Return type

int

set_metadata_counter(new_value, entity_short_name, dataset_name)[source]

It allows to set the counter value of metadata entities.

Parameters
  • new_value (int) – The new counter value to be set

  • entity_short_name (str) – The short name associated either to the type of the entity itself.

  • dataset_name (str) – In case of a Dataset, its name. Otherwise, the name of the relative dataset.

Raises

ValueError – if new_value is a negative integer, dataset_name is None or entity_short_name is not a known metadata short name.

Returns

None

Return type

None

read_metadata_counter(entity_short_name, dataset_name)[source]

It allows to read the counter value of metadata entities.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself.

  • dataset_name (str) – In case of a Dataset, its name. Otherwise, the name of the relative dataset.

Raises

ValueError – if dataset_name is None or entity_short_name is not a known metadata short name.

Returns

The requested counter value.

Return type

int

increment_metadata_counter(entity_short_name, dataset_name)[source]

It allows to increment the counter value of metadata entities by one unit.

Parameters
  • entity_short_name (str) – The short name associated either to the type of the entity itself.

  • dataset_name (str) – In case of a Dataset, its name. Otherwise, the name of the relative dataset.

Raises

ValueError – if dataset_name is None or entity_short_name is not a known metadata short name.

Returns

The newly-updated (already incremented) counter value.

Return type

int