Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/in_memory.py
Show All 32 Lines | |||||
from .interface import PagedResult, Sha1 | from .interface import PagedResult, Sha1 | ||||
from .model import ( | from .model import ( | ||||
BaseRow, | BaseRow, | ||||
ContentCtagsRow, | ContentCtagsRow, | ||||
ContentLanguageRow, | ContentLanguageRow, | ||||
ContentLicenseRow, | ContentLicenseRow, | ||||
ContentMetadataRow, | ContentMetadataRow, | ||||
ContentMimetypeRow, | ContentMimetypeRow, | ||||
DirectoryIntrinsicMetadataRow, | |||||
OriginIntrinsicMetadataRow, | OriginIntrinsicMetadataRow, | ||||
RevisionIntrinsicMetadataRow, | |||||
) | ) | ||||
from .writer import JournalWriter | from .writer import JournalWriter | ||||
SHA1_DIGEST_SIZE = 160 | SHA1_DIGEST_SIZE = 160 | ||||
ToolId = int | ToolId = int | ||||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | def __init__(self, journal_writer=None): | ||||
self.journal_writer = JournalWriter(tool_getter, journal_writer) | self.journal_writer = JournalWriter(tool_getter, journal_writer) | ||||
args = (self._tools, self.journal_writer) | args = (self._tools, self.journal_writer) | ||||
self._mimetypes = SubStorage(ContentMimetypeRow, *args) | self._mimetypes = SubStorage(ContentMimetypeRow, *args) | ||||
self._languages = SubStorage(ContentLanguageRow, *args) | self._languages = SubStorage(ContentLanguageRow, *args) | ||||
self._content_ctags = SubStorage(ContentCtagsRow, *args) | self._content_ctags = SubStorage(ContentCtagsRow, *args) | ||||
self._licenses = SubStorage(ContentLicenseRow, *args) | self._licenses = SubStorage(ContentLicenseRow, *args) | ||||
self._content_metadata = SubStorage(ContentMetadataRow, *args) | self._content_metadata = SubStorage(ContentMetadataRow, *args) | ||||
self._revision_intrinsic_metadata = SubStorage( | self._directory_intrinsic_metadata = SubStorage( | ||||
RevisionIntrinsicMetadataRow, *args | DirectoryIntrinsicMetadataRow, *args | ||||
) | ) | ||||
self._origin_intrinsic_metadata = SubStorage(OriginIntrinsicMetadataRow, *args) | self._origin_intrinsic_metadata = SubStorage(OriginIntrinsicMetadataRow, *args) | ||||
def check_config(self, *, check_write): | def check_config(self, *, check_write): | ||||
return True | return True | ||||
def content_mimetype_missing( | def content_mimetype_missing( | ||||
self, mimetypes: Iterable[Dict] | self, mimetypes: Iterable[Dict] | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | def content_metadata_get(self, ids: Iterable[Sha1]) -> List[ContentMetadataRow]: | ||||
return self._content_metadata.get(ids) | return self._content_metadata.get(ids) | ||||
def content_metadata_add( | def content_metadata_add( | ||||
self, metadata: List[ContentMetadataRow] | self, metadata: List[ContentMetadataRow] | ||||
) -> Dict[str, int]: | ) -> Dict[str, int]: | ||||
added = self._content_metadata.add(metadata) | added = self._content_metadata.add(metadata) | ||||
return {"content_metadata:add": added} | return {"content_metadata:add": added} | ||||
def revision_intrinsic_metadata_missing( | def directory_intrinsic_metadata_missing( | ||||
self, metadata: Iterable[Dict] | self, metadata: Iterable[Dict] | ||||
) -> List[Tuple[Sha1, int]]: | ) -> List[Tuple[Sha1, int]]: | ||||
return self._revision_intrinsic_metadata.missing(metadata) | return self._directory_intrinsic_metadata.missing(metadata) | ||||
def revision_intrinsic_metadata_get( | def directory_intrinsic_metadata_get( | ||||
self, ids: Iterable[Sha1] | self, ids: Iterable[Sha1] | ||||
) -> List[RevisionIntrinsicMetadataRow]: | ) -> List[DirectoryIntrinsicMetadataRow]: | ||||
return self._revision_intrinsic_metadata.get(ids) | return self._directory_intrinsic_metadata.get(ids) | ||||
def revision_intrinsic_metadata_add( | def directory_intrinsic_metadata_add( | ||||
self, metadata: List[RevisionIntrinsicMetadataRow] | self, metadata: List[DirectoryIntrinsicMetadataRow] | ||||
) -> Dict[str, int]: | ) -> Dict[str, int]: | ||||
added = self._revision_intrinsic_metadata.add(metadata) | added = self._directory_intrinsic_metadata.add(metadata) | ||||
return {"revision_intrinsic_metadata:add": added} | return {"directory_intrinsic_metadata:add": added} | ||||
def origin_intrinsic_metadata_get( | def origin_intrinsic_metadata_get( | ||||
self, urls: Iterable[str] | self, urls: Iterable[str] | ||||
) -> List[OriginIntrinsicMetadataRow]: | ) -> List[OriginIntrinsicMetadataRow]: | ||||
return self._origin_intrinsic_metadata.get(urls) | return self._origin_intrinsic_metadata.get(urls) | ||||
def origin_intrinsic_metadata_add( | def origin_intrinsic_metadata_add( | ||||
self, metadata: List[OriginIntrinsicMetadataRow] | self, metadata: List[OriginIntrinsicMetadataRow] | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |