跳到内容

库大小

ArcticDB 包含一些工具,用于分析您的库使用的存储量。

这些功能的 API 文档在此此处

我们按内部键类型对其进行细分,这些键类型记录在 arcticdb.KeyType 中。要获取库使用的总空间,只需将所有键类型的大小相加即可。

要使用这些工具,您可以运行如下代码:

from arcticdb import Arctic, KeyType
from arcticdb.version_store.admin_tools import sum_sizes

lib = Arctic("<your URI>").get_library("<your library>")
admin_tools = lib.admin_tools()

sizes = admin_tools.get_sizes()  # scan all the sizes in the library, can be slow
sum_sizes(sizes.values())  # total size of the library
sizes[KeyType.TABLE_DATA].bytes_compressed  # how much storage is consumed by data segments?
sizes[KeyType.TABLE_DATA].count  # how many data segments are in your library?

by_symbol = admin_tools.get_sizes_by_symbol()  # scan all the sizes in the library, grouped by symbol
size_for_sym = by_symbol["sym"]
sum_sizes(size_for_sym.values())  # total size of the symbol
size_for_sym[KeyType.TABLE_INDEX].bytes_compressed  # how much storage is consumed by index structures?
size_for_sym[KeyType.TABLE_INDEX].count  # how many indexes does this symbol have?

for_symbol = admin_tools.get_sizes_for_symbol("<your symbol>")  # scan sizes for one particular symbol, faster than the APIs above
sum_sizes(for_symbol.values())  # total size of the symbol
for_symbol[KeyType.VERSION].bytes_compressed  # how much storage is consumed by our versioning metadata layer?
for_symbol[KeyType.VERSION].count  # how many version keys are in the library?

库使用的大部分空间应在其 TABLE_DATA 键中,因为您的数据实际存储在此。其他键类型是 ArcticDB 跟踪的元数据,主要用于索引和版本化您的数据。有关我们的数据布局的更多信息,请访问此处