Process a batch of vectors and insert them into the database
(vectors, collection, batch_size)
| 527 | |
| 528 | |
| 529 | def process_vectors_batch(vectors, collection, batch_size): |
| 530 | """Process a batch of vectors and insert them into the database""" |
| 531 | try: |
| 532 | # Ensure all IDs are strings |
| 533 | for vector in vectors: |
| 534 | vector["id"] = str(vector["id"]) |
| 535 | txn_ = None |
| 536 | with collection.transaction() as txn: |
| 537 | txn.batch_upsert_vectors(vectors) |
| 538 | txn_ = txn |
| 539 | return txn_ |
| 540 | except Exception as e: |
| 541 | print(f"Error processing batch: {e}") |
| 542 | return None |
| 543 | |
| 544 | |
| 545 | def process_parquet_files( |
no outgoing calls
no test coverage detected