(
req_ct, base_idx, vector_db_name, transaction_id, dimensions, perturbation_degree
)
| 248 | |
| 249 | |
| 250 | def process_base_vector_batch( |
| 251 | req_ct, base_idx, vector_db_name, transaction_id, dimensions, perturbation_degree |
| 252 | ): |
| 253 | try: |
| 254 | # Generate one base vector |
| 255 | base_vector = generate_random_vector_with_id( |
| 256 | req_ct * 10000 + base_idx * 100, dimensions |
| 257 | ) |
| 258 | |
| 259 | # Create batch containing base vector and its perturbations |
| 260 | batch_vectors = [base_vector] # Start with base vector |
| 261 | |
| 262 | # Generate 99 perturbations for this base vector |
| 263 | for i in range(99): |
| 264 | perturbed_vector = generate_perturbation( |
| 265 | base_vector, |
| 266 | req_ct * 10000 |
| 267 | + base_idx * 100 |
| 268 | + i |
| 269 | + 1, # Unique ID for each perturbation |
| 270 | perturbation_degree, |
| 271 | dimensions, |
| 272 | ) |
| 273 | batch_vectors.append(perturbed_vector) |
| 274 | |
| 275 | # Submit this base vector and its perturbations as one batch |
| 276 | upsert_in_transaction(vector_db_name, transaction_id, batch_vectors) |
| 277 | print( |
| 278 | f"Upsert complete for base vector {base_idx} and its {len(batch_vectors) - 1} perturbations" |
| 279 | ) |
| 280 | |
| 281 | return ( |
| 282 | base_idx, |
| 283 | generate_perturbation( |
| 284 | base_vector, |
| 285 | req_ct * 10000 |
| 286 | + base_idx * 100 |
| 287 | + i |
| 288 | + 1, # Unique ID for each perturbation |
| 289 | perturbation_degree, |
| 290 | dimensions, |
| 291 | ), |
| 292 | batch_vectors, |
| 293 | ) |
| 294 | except Exception as e: |
| 295 | print(f"Error processing base vector {base_idx}: {e}") |
| 296 | raise |
| 297 | |
| 298 | |
| 299 | def bruteforce_search(vectors, query, k=5): |
nothing calls this directly
no test coverage detected