flushWriteBatch flushes any remaining entries in the write batch.
()
| 302 | |
| 303 | // flushWriteBatch flushes any remaining entries in the write batch. |
| 304 | func (vi *vectorIndexer) flushWriteBatch() error { |
| 305 | vi.mu.Lock() |
| 306 | defer vi.mu.Unlock() |
| 307 | |
| 308 | if vi.writeBatch != nil { |
| 309 | if vi.writeCount > 0 { |
| 310 | if err := vi.writeBatch.Flush(); err != nil { |
| 311 | vi.writeBatch.Cancel() |
| 312 | vi.writeBatch = nil |
| 313 | vi.writeCount = 0 |
| 314 | return fmt.Errorf("error flushing final vector write batch: %w", err) |
| 315 | } |
| 316 | } else { |
| 317 | // No entries to flush, just cancel |
| 318 | vi.writeBatch.Cancel() |
| 319 | } |
| 320 | vi.writeBatch = nil |
| 321 | vi.writeCount = 0 |
| 322 | } |
| 323 | return nil |
| 324 | } |
| 325 | |
| 326 | // validateVectorDimension checks that the vector has the expected dimension for the predicate. |
| 327 | // If this is the first vector for the predicate, it sets the expected dimension. |