class TestObjBase: idx: int = doctable.IDCol() size: int = 10000000 def __post_init__(self): if self.data is None: self.data = [random.randrange(10**12)] * self.size
class MyClass: name: str = doctable.Col(unique=True) # builtin column types idx: int = doctable.IDCol() updated: datetime.datetime = doctable.UpdatedCol() added: datetime.datetime = doctable.AddedCol() # custom column types lon: float = doctable.Col() lat: float = doctable.Col() # use Col to use factory to construct emtpy list # will be stored as binary/pickle type, since no other available elements: Sequence = doctable.Col(list) # indices and constraints _indices_ = { doctable.Index('lonlat_index', 'lon', 'lat', unique=True), #'lonlat_index': ('lon', 'lat', {'unique':True}), #'name_index': ('name',), doctable.Index('name_index', 'name'), } _constraints_ = ( doctable.Constraint('check', 'lon > 0', name='check_lon'), doctable.Constraint('check', 'lat > 0'), #('foreignkey', ('a','b'), ('c','d')) )
class NoSlots: id: int = doctable.IDCol() a: int = doctable.Col() b: int = doctable.Col(5) c: int = doctable.Col(10) d: int = doctable.Col(10) e: int = doctable.Col(10) f: int = doctable.Col(10) g: int = doctable.Col(10) h: int = doctable.Col(10)
class WithSlots: __slots__ = [] id: int = doctable.IDCol() a: int = doctable.Col() b: int = doctable.Col(5) c: int = doctable.Col(10) d: int = doctable.Col(10) e: int = doctable.Col(10) f: int = doctable.Col(10) g: int = doctable.Col(10) h: int = doctable.Col(10)
class TestRow: __slots__ = [] id: int = doctable.IDCol() doc: doctable.ParseTreeDoc = doctable.Col(type_kwargs=dict( folder='tmp/parsed_trees'))
class Child: __slots__ = [] id: int = doctable.IDCol() name: str = doctable.Col() parent_name: str = doctable.Col()
class Parent: __slots__ = [] id: int = doctable.IDCol() name: str = doctable.Col()
class FileObj: id: int = doctable.IDCol() data: np.ndarray = doctable.Col(None, coltype='picklefile', type_args=dict(folder=folder))
class DataObj: __slots__ = [] id: int = doctable.IDCol() data: np.ndarray = doctable.Col(None)