@@ -41,10 +41,12 @@ def load_rows(table: blosc2.CTable, nrows: int = 240) -> None:
4141packed = None
4242
4343try :
44+ print ("Creating a CTable with mixed dtypes..." )
4445 pt = blosc2 .CTable (Measurement , urlpath = str (table_path ), mode = "w" )
4546 load_rows (pt )
4647
4748 # Create a couple of indexes on columns with different dtypes.
49+ print ("\n Creating indexes..." )
4850 idx_sensor = pt .create_index ("sensor_id" , kind = blosc2 .IndexKind .FULL )
4951 idx_active = pt .create_index ("active" )
5052 print ("Indexes created:" , pt .indexes )
@@ -54,8 +56,8 @@ def load_rows(table: blosc2.CTable, nrows: int = 240) -> None:
5456 # Queries can combine indexed and non-indexed predicates.
5557 recent_active = pt .where ((pt ["sensor_id" ] >= 180 ) & pt ["active" ] & (pt ["region" ] == "north" ))
5658 print ("\n Live rows with sensor_id >= 180, active=True, region='north':" , len (recent_active ))
57- print ("sensor_ids:" , recent_active ["sensor_id" ]. to_numpy (). tolist () )
58- print ("statuses:" , recent_active ["status" ].to_numpy (). tolist () )
59+ print ("sensor_ids:" , recent_active ["sensor_id" ])
60+ print ("statuses:" , recent_active ["status" ].to_numpy ())
5961
6062 # Close the table, pack the TreeStore into a single .b2z file, and reopen it.
6163 del pt
@@ -79,8 +81,8 @@ def load_rows(table: blosc2.CTable, nrows: int = 240) -> None:
7981 # Query directly against the .b2z bundle; no unpack step is needed.
8082 warm_active = packed .where (packed ["active" ] & (packed ["status" ] == "warm" ) & (packed ["sensor_id" ] > 100 ))
8183 print ("\n Rows from .b2z with active=True, status='warm', sensor_id > 100:" , len (warm_active ))
82- print ("sensor_ids:" , warm_active ["sensor_id" ]. to_numpy (). tolist () )
83- print ("regions:" , warm_active ["region" ].to_numpy (). tolist () )
84+ print ("sensor_ids:" , warm_active ["sensor_id" ])
85+ print ("regions:" , warm_active ["region" ].to_numpy ())
8486
8587 print ("\n The packed file is kept on disk." )
8688 print (f"Inspect it later with: f = blosc2.open({ bundle_path .name !r} , mode='r')" )
0 commit comments