(self)
| 266 | return deleted_count |
| 267 | |
| 268 | def clear_empty_collections(self) -> int: |
| 269 | inspector = inspect(self.engine) |
| 270 | table_names = inspector.get_table_names() |
| 271 | |
| 272 | with self.SessionLocal() as session: |
| 273 | deleted_count = 0 |
| 274 | for table_name in table_names: |
| 275 | table = Table(table_name, self.metadata, autoload_with=self.engine) |
| 276 | |
| 277 | # Efficiently check for emptiness without fetching all rows |
| 278 | if session.query(table.select().limit(1).exists()).scalar(): |
| 279 | continue |
| 280 | |
| 281 | # Use delete_collection to handle index and table deletion |
| 282 | self.delete_collection(table_name) |
| 283 | deleted_count += 1 |
| 284 | |
| 285 | session.commit() # Commit is likely not needed here |
| 286 | logger.warning(f"Deleted {deleted_count} empty tables.") |
| 287 | return deleted_count |
| 288 | |
| 289 | def _parse_embedding_store_record(self, res: Any) -> Dict[str, Any]: |
| 290 | metadata = res.cmetadata or {} |
nothing calls this directly
no test coverage detected