torch_geometric.data.RocksDatabase

class RocksDatabase(path: str, schema: ~typing.Union[~typing.Any, ~typing.Dict[str, ~typing.Any], ~typing.Tuple[~typing.Any], ~typing.List[~typing.Any]] = <class 'object'>)[source]

Bases: Database

一个基于RocksDB的索引键/值数据库。

注意

此数据库实现需要rocksdict包。

警告

RocksDatabase 目前没有 SQLiteDatabase 优化得好。

Parameters:
  • path (str) – The path to where the database should be saved.

  • schema (Any or Tuple[Any] or Dict[str, Any], optional) – The schema of the input data. Can take int, float, str, object, or a dictionary with dtype and size keys (for specifying tensor data) as input, and can be nested as a tuple or dictionary. Specifying the schema will improve efficiency, since by default the database will use python pickling for serializing and deserializing. (default: object)

connect() None[source]

连接到数据库。 数据库在实例化时会自动连接。

Return type:

None

close() None[source]

关闭与数据库的连接。

Return type:

None

insert(index: int, data: Any) None[source]

在指定索引处插入数据。

Parameters:
  • index (int) – The index at which to insert.

  • data (Any) – The object to insert.

Return type:

None

get(index: int) Any[source]

从指定的索引获取数据。

Parameters:

index (int) – The index to query.

Return type:

Any

multi_get(indices: Union[Sequence[int], Tensor, slice, range], batch_size: Optional[int] = None) List[Any]

从指定的索引获取一块数据。

Parameters:
  • indices (List[int] or torch.Tensor or range) – The indices to query.

  • batch_size (int, optional) – If specified, will request the data from the database in batches of size batch_size. (default: None)

Return type:

List[Any]

multi_insert(indices: Union[Sequence[int], Tensor, slice, range], data_list: Sequence[Any], batch_size: Optional[int] = None, log: bool = False) None

在指定的索引处插入一块数据。

Parameters:
  • indices (List[int] or torch.Tensor or range) – The indices at which to insert.

  • data_list (List[Any]) – The objects to insert.

  • batch_size (int, optional) – If specified, will insert the data to the database in batches of size batch_size. (default: None)

  • log (bool, optional) – If set to True, will log progress to the console. (default: False)

Return type:

None