_session.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. from fate_arch.common.address import LinkisHiveAddress
  17. from fate_arch.storage import StorageSessionBase, StorageEngine, LinkisHiveStoreType
  18. from fate_arch.abc import AddressABC
  19. class StorageSession(StorageSessionBase):
  20. def __init__(self, session_id, options=None):
  21. super(StorageSession, self).__init__(session_id=session_id, engine=StorageEngine.LINKIS_HIVE)
  22. self.con = None
  23. self.cur = None
  24. self.address = None
  25. def table(self, name, namespace, address: AddressABC, partitions,
  26. storage_type: LinkisHiveStoreType = LinkisHiveStoreType.DEFAULT, options=None, **kwargs):
  27. self.address = address
  28. if isinstance(address, LinkisHiveAddress):
  29. from fate_arch.storage.linkis_hive._table import StorageTable
  30. return StorageTable(
  31. address=address,
  32. name=name,
  33. namespace=namespace,
  34. storage_type=storage_type,
  35. partitions=partitions,
  36. options=options)
  37. raise NotImplementedError(f"address type {type(address)} not supported with eggroll storage")
  38. def cleanup(self, name, namespace):
  39. pass
  40. def stop(self):
  41. pass
  42. def kill(self):
  43. pass