MCPcopy
hub / github.com/weaviate/weaviate / PutObjects

Method PutObjects

usecases/replica/replicator.go:202–237  ·  view source on GitHub ↗
(ctx context.Context,
	shard string,
	objs []*storobj.Object,
	l types.ConsistencyLevel,
	schemaVersion uint64,
)

Source from the content-addressed store, hash-verified

200}
201
202func (r *Replicator) PutObjects(ctx context.Context,
203 shard string,
204 objs []*storobj.Object,
205 l types.ConsistencyLevel,
206 schemaVersion uint64,
207) []error {
208 coord := NewWriteCoordinator[SimpleResponse, error](r.client, r.router, r.metrics, r.class, shard, r.requestID(opPutObjects), r.log)
209 release := r.inflight.register(shard)
210 defer release()
211 op := func(ctx context.Context, host, requestID string) error {
212 resp, err := r.client.PutObjects(ctx, host, r.class, shard, requestID, objs, schemaVersion)
213 if err == nil {
214 err = resp.FirstError()
215 }
216 if err != nil {
217 return fmt.Errorf("%q: %w", host, err)
218 }
219 return nil
220 }
221 rs, err := coord.Push(ctx, l, op, r.simpleCommit(shard), r.readSimpleResponse, r.flattenErrors, len(objs))
222 if err != nil {
223 r.log.WithField("op", "push.many").WithField("class", r.class).
224 WithField("shard", shard).Error(err)
225 err = fmt.Errorf("%s %q: %w", replicaerrors.MsgCLevel, l, replicaerrors.NewNotEnoughReplicasError(err))
226 errs := make([]error, len(objs))
227 for i := 0; i < len(objs); i++ {
228 errs[i] = err
229 }
230 return errs
231 }
232 if err := firstError(rs); err != nil {
233 r.log.WithField("op", "put.many").WithField("class", r.class).
234 WithField("shard", shard).Error(rs)
235 }
236 return rs
237}
238
239func (r *Replicator) DeleteObjects(ctx context.Context,
240 shard string,

Callers

nothing calls this directly

Calls 10

requestIDMethod · 0.95
simpleCommitMethod · 0.95
NewWriteCoordinatorFunction · 0.85
firstErrorFunction · 0.85
registerMethod · 0.80
ErrorfMethod · 0.80
PutObjectsMethod · 0.65
FirstErrorMethod · 0.45
PushMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected