Pool

ABC Pool

source

Pool

 Pool (_cnt:int=0)

*The abstract storage for pooling the real-time data from the cloud.

Pool provides the following features:

- load(): initialize the pool interface
- close(): destructor
- store(): Store the data in the pool
- delete(id): remove the data with id in the pool
- find(id): Get the data from the pool
- sample(size, query: Optional[dict]=None): Sample a batch of data from the pool
- count(query: Optional[dict] = None): Count the number of data in the pool

Attributes: - _type_T: the type of the data stored in the pool - _cnt: the number of records in the pool*


source

Pool.load

 Pool.load ()

*Initialize the pool interface

This function should: - connect to db - init*


source

Pool.close

 Pool.close ()

close the pool, for destructor


source

Pool.store

 Pool.store (item:~ItemT)

Deposit an item (record) into the pool


source

Pool.delete

 Pool.delete (idx)

delete an itme by id or name.


source

Pool._count

 Pool._count (query:Optional[tspace.data.core.PoolQuery]=None)

*Count the number of records in the db.

query = { vehicle_id: str = “VB7”, driver_id: str = “longfei-zheng”, dt_start: datetime = None, dt_end: datetime = None, }*


source

Pool.find

 Pool.find (query:tspace.data.core.PoolQuery)

Find an item by id or name.


source

Pool.sample

 Pool.sample (size:int, query:Optional[tspace.data.core.PoolQuery]=None)

*Sample a size of records from the pool.

Args:

size: desired size of the samples
rule: an optional dictionary specifying a rule or a pipeline in mongodb
query: query to filter the records
vehicle_id: str = "VB7",
driver_id: str = "longfei-zheng",
dt_start: datetime = None,
dt_end: datetime = None,
}*
Type Default Details
size int number of required samples
query Optional[PoolQuery] None
Returns Optional[Union[pd.DataFrame, list[ItemT]]] query to filter the records

source

Pool.__iter__

 Pool.__iter__ ()

Iterate over the pool.


source

Pool.__getitem__

 Pool.__getitem__ (query:tspace.data.core.PoolQuery)

Get an item by id or name.


source

Pool.__len__

 Pool.__len__ ()

source

Pool.__repr__

 Pool.__repr__ ()

Return repr(self).