airbyte.results
1# Copyright (c) 2023 Airbyte, Inc., all rights reserved. 2from __future__ import annotations 3 4from collections.abc import Mapping 5from typing import TYPE_CHECKING 6 7from airbyte.datasets import CachedDataset 8 9 10if TYPE_CHECKING: 11 from collections.abc import Iterator 12 13 from sqlalchemy.engine import Engine 14 15 from airbyte.caches import CacheBase 16 17 18class ReadResult(Mapping[str, CachedDataset]): 19 def __init__( 20 self, 21 processed_records: int, 22 cache: CacheBase, 23 processed_streams: list[str], 24 ) -> None: 25 self.processed_records = processed_records 26 self._cache = cache 27 self._processed_streams = processed_streams 28 29 def __getitem__(self, stream: str) -> CachedDataset: 30 if stream not in self._processed_streams: 31 raise KeyError(stream) 32 33 return CachedDataset(self._cache, stream) 34 35 def __contains__(self, stream: object) -> bool: 36 if not isinstance(stream, str): 37 return False 38 39 return stream in self._processed_streams 40 41 def __iter__(self) -> Iterator[str]: 42 return self._processed_streams.__iter__() 43 44 def __len__(self) -> int: 45 return len(self._processed_streams) 46 47 def get_sql_engine(self) -> Engine: 48 return self._cache.get_sql_engine() 49 50 @property 51 def streams(self) -> Mapping[str, CachedDataset]: 52 return { 53 stream_name: CachedDataset(self._cache, stream_name) 54 for stream_name in self._processed_streams 55 } 56 57 @property 58 def cache(self) -> CacheBase: 59 return self._cache
class
ReadResult(collections.abc.Mapping[str, airbyte.datasets._sql.CachedDataset]):
19class ReadResult(Mapping[str, CachedDataset]): 20 def __init__( 21 self, 22 processed_records: int, 23 cache: CacheBase, 24 processed_streams: list[str], 25 ) -> None: 26 self.processed_records = processed_records 27 self._cache = cache 28 self._processed_streams = processed_streams 29 30 def __getitem__(self, stream: str) -> CachedDataset: 31 if stream not in self._processed_streams: 32 raise KeyError(stream) 33 34 return CachedDataset(self._cache, stream) 35 36 def __contains__(self, stream: object) -> bool: 37 if not isinstance(stream, str): 38 return False 39 40 return stream in self._processed_streams 41 42 def __iter__(self) -> Iterator[str]: 43 return self._processed_streams.__iter__() 44 45 def __len__(self) -> int: 46 return len(self._processed_streams) 47 48 def get_sql_engine(self) -> Engine: 49 return self._cache.get_sql_engine() 50 51 @property 52 def streams(self) -> Mapping[str, CachedDataset]: 53 return { 54 stream_name: CachedDataset(self._cache, stream_name) 55 for stream_name in self._processed_streams 56 } 57 58 @property 59 def cache(self) -> CacheBase: 60 return self._cache
A Mapping is a generic container for associating key/value pairs.
This class provides concrete generic implementations of all methods except for __getitem__, __iter__, and __len__.
ReadResult( processed_records: int, cache: airbyte.caches.base.CacheBase, processed_streams: list[str])
Inherited Members
- collections.abc.Mapping
- get
- keys
- items
- values