store.py 899 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. r"""标准仓读写接口(**组件接入点:TiDB community**)。
  3. 现在:仓库是本地 parquet 目录(`outputs/<场>/windscada/*.parquet`)。
  4. 目标:同一接口下新增 TiDB 实现(表 ↔ 仓映射、事务边界在这一层),算法层不受影响。
  5. P0 只立契约,**没有任何实现**(默认走现有本地实现,故零行为变化)。
  6. """
  7. from __future__ import annotations
  8. from abc import ABC, abstractmethod
  9. class Warehouse(ABC):
  10. """标准仓:按"表名"读写产物(与存储介质无关)。"""
  11. @abstractmethod
  12. def list_tables(self) -> list[str]: ...
  13. @abstractmethod
  14. def read_table(self, name: str): ...
  15. @abstractmethod
  16. def write_table(self, name: str, data, *, overwrite: bool = True) -> None: ...
  17. @abstractmethod
  18. def exists(self, name: str) -> bool: ...