github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/batcheval/cmd_merge.go (about) 1 // Copyright 2014 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package batcheval 12 13 import ( 14 "context" 15 16 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval/result" 17 "github.com/cockroachdb/cockroach/pkg/roachpb" 18 "github.com/cockroachdb/cockroach/pkg/storage" 19 ) 20 21 func init() { 22 RegisterReadWriteCommand(roachpb.Merge, DefaultDeclareKeys, Merge) 23 } 24 25 // Merge is used to merge a value into an existing key. Merge is an 26 // efficient accumulation operation which is exposed by RocksDB, used 27 // by CockroachDB for the efficient accumulation of certain 28 // values. Due to the difficulty of making these operations 29 // transactional, merges are not currently exposed directly to 30 // clients. Merged values are explicitly not MVCC data. 31 func Merge( 32 ctx context.Context, readWriter storage.ReadWriter, cArgs CommandArgs, resp roachpb.Response, 33 ) (result.Result, error) { 34 args := cArgs.Args.(*roachpb.MergeRequest) 35 h := cArgs.Header 36 37 return result.Result{}, storage.MVCCMerge(ctx, readWriter, cArgs.Stats, args.Key, h.Timestamp, args.Value) 38 }