base_non_rdf_layout.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import logging
  2. from abc import ABCMeta, abstractmethod
  3. logger = logging.getLogger(__name__)
  4. class BaseNonRdfLayout(metaclass=ABCMeta):
  5. '''
  6. Abstract class for setting the non-RDF (bitstream) store layout.
  7. Differerent layouts can be created by implementing all the abstract methods
  8. of this class. A non-RDF layout is not necessarily restricted to a
  9. traditional filesystem—e.g. a layout persisting to HDFS can be written too.
  10. '''
  11. def __init__(self, config):
  12. '''
  13. Initialize the base non-RDF store layout.
  14. '''
  15. self.config = config
  16. self.root = config['path']
  17. ## INTERFACE METHODS ##
  18. @abstractmethod
  19. def persist(self, stream):
  20. '''
  21. Store the stream in the designated persistence layer for this layout.
  22. '''
  23. pass
  24. @abstractmethod
  25. def delete(self, id):
  26. '''
  27. Delete a stream by its identifier (i.e. checksum).
  28. '''
  29. pass
  30. @abstractmethod
  31. def local_path(self, uuid):
  32. '''
  33. Return the local path of a file.
  34. '''
  35. pass