mirror of https://github.com/ceph/go-ceph
rados: use rados_write_op_omap_rm_keys2()
WriteOp.RmOmapKeys now uses rados_write_op_omap_rm_keys2().
The entirety of removeOmapKeysStep struct was removed as it's not necessary for
it to own the various C-allocated values passed to
rados_write_op_omap_rm_keys2() as arguments. rados_write_op_omap_rm_keys2()
makes copies of all the string-based args [1], so it's sufficient for them to
be short lived.
[1] 2bd3dd512a/src/librados/librados_c.cc (L3888-L3902)
This commit is contained in:
parent
044c3733e9
commit
3eba56ce60
|
@ -97,40 +97,6 @@ func (gos *GetOmapStep) More() bool {
|
|||
return *gos.more != 0
|
||||
}
|
||||
|
||||
// removeOmapKeysStep is a write operation step used to track state, especially
|
||||
// C memory, across the setup and use of a WriteOp.
|
||||
type removeOmapKeysStep struct {
|
||||
withRefs
|
||||
withoutUpdate
|
||||
|
||||
// arguments:
|
||||
cKeys cutil.CPtrCSlice
|
||||
cNum C.size_t
|
||||
}
|
||||
|
||||
func newRemoveOmapKeysStep(keys []string) *removeOmapKeysStep {
|
||||
cKeys := cutil.NewCPtrCSlice(len(keys))
|
||||
roks := &removeOmapKeysStep{
|
||||
cKeys: cKeys,
|
||||
cNum: C.size_t(len(keys)),
|
||||
}
|
||||
|
||||
i := 0
|
||||
for _, key := range keys {
|
||||
cKeys[i] = cutil.CPtr(C.CString(key))
|
||||
roks.add(unsafe.Pointer(cKeys[i]))
|
||||
i++
|
||||
}
|
||||
|
||||
runtime.SetFinalizer(roks, opStepFinalizer)
|
||||
return roks
|
||||
}
|
||||
|
||||
func (roks *removeOmapKeysStep) free() {
|
||||
roks.cKeys.Free()
|
||||
roks.withRefs.free()
|
||||
}
|
||||
|
||||
// SetOmap appends the map `pairs` to the omap `oid`
|
||||
func (ioctx *IOContext) SetOmap(oid string, pairs map[string][]byte) error {
|
||||
op := CreateWriteOp()
|
||||
|
|
|
@ -118,12 +118,14 @@ func (w *WriteOp) SetOmap(pairs map[string][]byte) {
|
|||
|
||||
// RmOmapKeys removes the specified `keys` from the omap `oid`.
|
||||
func (w *WriteOp) RmOmapKeys(keys []string) {
|
||||
roks := newRemoveOmapKeysStep(keys)
|
||||
w.steps = append(w.steps, roks)
|
||||
C.rados_write_op_omap_rm_keys(
|
||||
cKeys := cutil.NewBufferGroupStrings(keys)
|
||||
defer cKeys.Free()
|
||||
|
||||
C.rados_write_op_omap_rm_keys2(
|
||||
w.op,
|
||||
(**C.char)(roks.cKeys.Ptr()),
|
||||
roks.cNum)
|
||||
(**C.char)(cKeys.BuffersPtr()),
|
||||
(*C.size_t)(cKeys.LengthsPtr()),
|
||||
(C.size_t)(len(keys)))
|
||||
}
|
||||
|
||||
// CleanOmap clears the omap `oid`.
|
||||
|
|
Loading…
Reference in New Issue