| 254 | } |
| 255 | |
| 256 | func (a *segment) mutateEx(operation uint64, |
| 257 | keyStart, keyLength, valLength int) error { |
| 258 | if keyLength > maxKeyLength { |
| 259 | return ErrKeyTooLarge |
| 260 | } |
| 261 | if valLength > maxValLength { |
| 262 | return ErrValueTooLarge |
| 263 | } |
| 264 | |
| 265 | if keyLength <= 0 && valLength <= 0 { |
| 266 | keyStart = 0 |
| 267 | } |
| 268 | |
| 269 | opKlVl := encodeOpKeyLenValLen(operation, keyLength, valLength) |
| 270 | |
| 271 | a.kvs = append(a.kvs, opKlVl, uint64(keyStart)) |
| 272 | |
| 273 | switch operation { |
| 274 | case OperationSet: |
| 275 | a.totOperationSet++ |
| 276 | case OperationDel: |
| 277 | a.totOperationDel++ |
| 278 | case OperationMerge: |
| 279 | a.totOperationMerge++ |
| 280 | default: |
| 281 | } |
| 282 | |
| 283 | a.totKeyByte += uint64(keyLength) |
| 284 | a.totValByte += uint64(valLength) |
| 285 | |
| 286 | return nil |
| 287 | } |
| 288 | |
| 289 | // ------------------------------------------------------ |
| 290 | |