_storage.py 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. import abc
  17. from typing import Iterable
  18. from fate_arch.common.log import getLogger
  19. LOGGER = getLogger()
  20. class StorageTableMetaABC(metaclass=abc.ABCMeta):
  21. @abc.abstractmethod
  22. def create(self):
  23. ...
  24. @abc.abstractmethod
  25. def set_metas(self, **kwargs):
  26. ...
  27. @abc.abstractmethod
  28. def query_table_meta(self, filter_fields, query_fields=None):
  29. ...
  30. @abc.abstractmethod
  31. def update_metas(self, schema=None, count=None, part_of_data=None, description=None, partitions=None, **kwargs):
  32. ...
  33. @abc.abstractmethod
  34. def destroy_metas(self):
  35. ...
  36. @abc.abstractmethod
  37. def get_name(self):
  38. ...
  39. ...
  40. @abc.abstractmethod
  41. def get_namespace(self):
  42. ...
  43. @abc.abstractmethod
  44. def get_address(self):
  45. ...
  46. @abc.abstractmethod
  47. def get_engine(self):
  48. ...
  49. @abc.abstractmethod
  50. def get_store_type(self):
  51. ...
  52. @abc.abstractmethod
  53. def get_options(self):
  54. ...
  55. @abc.abstractmethod
  56. def get_partitions(self):
  57. ...
  58. @abc.abstractmethod
  59. def get_in_serialized(self):
  60. ...
  61. @abc.abstractmethod
  62. def get_id_delimiter(self):
  63. ...
  64. @abc.abstractmethod
  65. def get_extend_sid(self):
  66. ...
  67. @abc.abstractmethod
  68. def get_auto_increasing_sid(self):
  69. ...
  70. @abc.abstractmethod
  71. def get_have_head(self):
  72. ...
  73. @abc.abstractmethod
  74. def get_schema(self):
  75. ...
  76. @abc.abstractmethod
  77. def get_count(self):
  78. ...
  79. @abc.abstractmethod
  80. def get_part_of_data(self):
  81. ...
  82. @abc.abstractmethod
  83. def get_description(self):
  84. ...
  85. @abc.abstractmethod
  86. def get_origin(self):
  87. ...
  88. @abc.abstractmethod
  89. def get_disable(self):
  90. ...
  91. @abc.abstractmethod
  92. def to_dict(self) -> dict:
  93. ...
  94. class StorageTableABC(metaclass=abc.ABCMeta):
  95. @property
  96. @abc.abstractmethod
  97. def name(self):
  98. ...
  99. @property
  100. @abc.abstractmethod
  101. def namespace(self):
  102. ...
  103. @property
  104. @abc.abstractmethod
  105. def address(self):
  106. ...
  107. @property
  108. @abc.abstractmethod
  109. def engine(self):
  110. ...
  111. @property
  112. @abc.abstractmethod
  113. def store_type(self):
  114. ...
  115. @property
  116. @abc.abstractmethod
  117. def options(self):
  118. ...
  119. @property
  120. @abc.abstractmethod
  121. def partitions(self):
  122. ...
  123. @property
  124. @abc.abstractmethod
  125. def meta(self) -> StorageTableMetaABC:
  126. ...
  127. @meta.setter
  128. @abc.abstractmethod
  129. def meta(self, meta: StorageTableMetaABC):
  130. ...
  131. @abc.abstractmethod
  132. def update_meta(self,
  133. schema=None,
  134. count=None,
  135. part_of_data=None,
  136. description=None,
  137. partitions=None,
  138. **kwargs) -> StorageTableMetaABC:
  139. ...
  140. @abc.abstractmethod
  141. def create_meta(self, **kwargs) -> StorageTableMetaABC:
  142. ...
  143. @abc.abstractmethod
  144. def put_all(self, kv_list: Iterable, **kwargs):
  145. ...
  146. @abc.abstractmethod
  147. def collect(self, **kwargs) -> list:
  148. ...
  149. @abc.abstractmethod
  150. def read(self) -> list:
  151. ...
  152. @abc.abstractmethod
  153. def count(self):
  154. ...
  155. @abc.abstractmethod
  156. def destroy(self):
  157. ...
  158. @abc.abstractmethod
  159. def check_address(self):
  160. ...
  161. class StorageSessionABC(metaclass=abc.ABCMeta):
  162. @abc.abstractmethod
  163. def create_table(self, address, name, namespace, partitions, storage_type=None, options=None,
  164. **kwargs) -> StorageTableABC:
  165. ...
  166. @abc.abstractmethod
  167. def get_table(self, name, namespace) -> StorageTableABC:
  168. ...
  169. @abc.abstractmethod
  170. def get_table_meta(self, name, namespace) -> StorageTableMetaABC:
  171. ...
  172. # @abc.abstractmethod
  173. # def table(self, name, namespace, address, partitions, store_type=None, options=None, **kwargs) -> StorageTableABC:
  174. # ...
  175. # @abc.abstractmethod
  176. # def get_storage_info(self, name, namespace):
  177. # ...
  178. @abc.abstractmethod
  179. def destroy(self):
  180. ...
  181. @abc.abstractmethod
  182. def stop(self):
  183. ...
  184. @abc.abstractmethod
  185. def kill(self):
  186. ...
  187. @abc.abstractmethod
  188. def cleanup(self, name, namespace):
  189. ...
  190. @property
  191. @abc.abstractmethod
  192. def session_id(self) -> str:
  193. ...
  194. @property
  195. @abc.abstractmethod
  196. def engine(self) -> str:
  197. ...