(ctx context.Context, ids []ksuid.KSUID, author, message string)
| 430 | } |
| 431 | |
| 432 | func (b *Branch) AddVectors(ctx context.Context, ids []ksuid.KSUID, author, message string) (ksuid.KSUID, error) { |
| 433 | if message == "" { |
| 434 | message = vectorMessage("add", ids) |
| 435 | } |
| 436 | // XXX We should add some parallelism here to stream the next file while |
| 437 | // the CPU is chugging away on the current file. See issue #4015. |
| 438 | for _, id := range ids { |
| 439 | if err := data.CreateVector(ctx, b.pool.engine, b.pool.DataPath, id); err != nil { |
| 440 | return ksuid.Nil, err |
| 441 | } |
| 442 | } |
| 443 | return b.commit(ctx, func(parent *branches.Config, retries int) (*commits.Object, error) { |
| 444 | snap, err := b.pool.commits.Snapshot(ctx, parent.Commit) |
| 445 | if err != nil { |
| 446 | return nil, err |
| 447 | } |
| 448 | for _, id := range ids { |
| 449 | if !snap.Exists(id) { |
| 450 | return nil, fmt.Errorf("non-existent object %s: vector add operation aborted", id) |
| 451 | } |
| 452 | if snap.HasVector(id) { |
| 453 | return nil, fmt.Errorf("vector exists for %s: vector add operation aborted", id) |
| 454 | } |
| 455 | } |
| 456 | return commits.NewAddVectorsObject(parent.Commit, author, message, ids, retries), nil |
| 457 | }) |
| 458 | } |
| 459 | |
| 460 | func (b *Branch) DeleteVectors(ctx context.Context, ids []ksuid.KSUID, author, message string) (ksuid.KSUID, error) { |
| 461 | if message == "" { |
nothing calls this directly
no test coverage detected