Batch version of the mutate method. Note that the response entries ordering is undefined (i.e., may not match the input ordering) When DataVersionId is 0, zeroVersionIdCode is used instead of code.
( code opCode, zeroVersionIdCode opCode, items []*Item)
| 459 | // ordering is undefined (i.e., may not match the input ordering) |
| 460 | // When DataVersionId is 0, zeroVersionIdCode is used instead of code. |
| 461 | func (c *RawBinaryClient) mutateMulti( |
| 462 | code opCode, zeroVersionIdCode opCode, |
| 463 | items []*Item) []MutateResponse { |
| 464 | |
| 465 | if items == nil { |
| 466 | return nil |
| 467 | } |
| 468 | |
| 469 | responses := make([]MutateResponse, len(items), len(items)) |
| 470 | |
| 471 | // Short-circuit function to avoid locking. |
| 472 | if len(items) == 0 { |
| 473 | return responses |
| 474 | } |
| 475 | |
| 476 | c.mutex.Lock() |
| 477 | defer c.mutex.Unlock() |
| 478 | |
| 479 | var itemCode opCode |
| 480 | for i, item := range items { |
| 481 | itemCode = code |
| 482 | if item.DataVersionId == 0 { |
| 483 | itemCode = zeroVersionIdCode |
| 484 | } |
| 485 | responses[i] = c.sendMutateRequest(itemCode, item, true) |
| 486 | } |
| 487 | |
| 488 | for i, item := range items { |
| 489 | if responses[i] != nil { // error occurred while sending |
| 490 | continue |
| 491 | } |
| 492 | itemCode = code |
| 493 | if item.DataVersionId == 0 { |
| 494 | itemCode = zeroVersionIdCode |
| 495 | } |
| 496 | responses[i] = c.receiveMutateResponse(itemCode, item.Key) |
| 497 | } |
| 498 | |
| 499 | return responses |
| 500 | } |
| 501 | |
| 502 | // See Client interface for documentation. |
| 503 | func (c *RawBinaryClient) Set(item *Item) MutateResponse { |
no test coverage detected