MCPcopy
hub / github.com/dgraph-io/dgraph / flushWriteBatch

Method flushWriteBatch

dgraph/cmd/bulk/vector_indexer.go:304–324  ·  view source on GitHub ↗

flushWriteBatch flushes any remaining entries in the write batch.

()

Source from the content-addressed store, hash-verified

302
303// flushWriteBatch flushes any remaining entries in the write batch.
304func (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.

Callers 2

waitMethod · 0.95
startWritingMethod · 0.80

Calls 4

FlushMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected