@@ -405,42 +405,44 @@ item_info Item::toItemInfo(uint64_t vb_uuid, int64_t hlcEpoch) const {
405405 return info;
406406}
407407
408- void Item::removeBody () {
408+ Item::WasValueInflated Item::removeBody () {
409409 if (!value) {
410410 // No value, nothing to do
411- return ;
411+ return WasValueInflated::No ;
412412 }
413413
414414 if (!mcbp::datatype::is_xattr (getDataType ())) {
415415 // We don't want the body and there are no xattrs, just set empty value
416416 setData (nullptr , 0 );
417417 setDataType (PROTOCOL_BINARY_RAW_BYTES);
418- return ;
418+ return WasValueInflated::No ;
419419 }
420420
421421 // No-op if already uncompressed
422- decompressValue ();
422+ const auto wasInflated = decompressValue ();
423423
424424 // We want only xattrs.
425425 // Note: The following is no-op if no Body present.
426426 const cb::const_char_buffer valBuffer{value->getData (), value->valueSize ()};
427427 setData (valBuffer.data (), cb::xattr::get_body_offset (valBuffer));
428428 setDataType (PROTOCOL_BINARY_DATATYPE_XATTR);
429+
430+ return wasInflated ? WasValueInflated::Yes : WasValueInflated::No;
429431}
430432
431- void Item::removeXattrs () {
433+ Item::WasValueInflated Item::removeXattrs () {
432434 if (!value) {
433435 // No value, nothing to do
434- return ;
436+ return WasValueInflated::No ;
435437 }
436438
437439 if (!mcbp::datatype::is_xattr (getDataType ())) {
438440 // No Xattrs, nothing to do
439- return ;
441+ return WasValueInflated::No ;
440442 }
441443
442444 // No-op if already uncompressed
443- decompressValue ();
445+ const auto wasInflated = decompressValue ();
444446
445447 // We want only the body
446448 const cb::const_char_buffer valBuffer{value->getData (), value->valueSize ()};
@@ -454,21 +456,23 @@ void Item::removeXattrs() {
454456 // Subdoc logic for details. Here we have to rectify.
455457 setDataType (getDataType () & ~PROTOCOL_BINARY_DATATYPE_JSON);
456458 }
459+
460+ return wasInflated ? WasValueInflated::Yes : WasValueInflated::No;
457461}
458462
459- void Item::removeUserXattrs () {
463+ Item::WasValueInflated Item::removeUserXattrs () {
460464 if (!value) {
461465 // No value, nothing to do
462- return ;
466+ return WasValueInflated::No ;
463467 }
464468
465469 if (!mcbp::datatype::is_xattr (getDataType ())) {
466470 // No Xattrs, nothing to do
467- return ;
471+ return WasValueInflated::No ;
468472 }
469473
470474 // No-op if already uncompressed
471- decompressValue ();
475+ const auto wasInflated = decompressValue ();
472476
473477 // The function currently does not support value with body.
474478 // That is fine for now as this is introduced for MB-37374, thus is supposed
@@ -494,33 +498,37 @@ void Item::removeUserXattrs() {
494498 // Note: Doing this unconditionally as we reach this line iff there is no
495499 // body. We would need to do this conditionally otherwise.
496500 setDataType (getDataType () & ~PROTOCOL_BINARY_DATATYPE_JSON);
501+
502+ return wasInflated ? WasValueInflated::Yes : WasValueInflated::No;
497503}
498504
499- void Item::removeBodyAndOrXattrs (
505+ Item::WasValueInflated Item::removeBodyAndOrXattrs (
500506 IncludeValue includeVal,
501507 IncludeXattrs includeXattrs,
502508 IncludeDeletedUserXattrs includeDeletedUserXattrs) {
503509 if (!value) {
504510 // If no value (ie, no body and/or xattrs) then nothing to do
505- return ;
511+ return WasValueInflated::No ;
506512 }
507513
508514 // Take a copy of the original datatype before proceeding, any modification
509515 // to the value may change the datatype.
510516 const auto originalDatatype = getDataType ();
511517
518+ auto wasInflated = WasValueInflated::No;
519+
512520 // Note: IncludeValue acts like "include body"
513521 if (includeVal != IncludeValue::Yes) {
514- removeBody ();
522+ wasInflated = removeBody ();
515523 }
516524
517525 if (includeXattrs == IncludeXattrs::No) {
518- removeXattrs ();
526+ wasInflated = removeXattrs ();
519527 }
520528
521529 if (isDeleted () &&
522530 includeDeletedUserXattrs == IncludeDeletedUserXattrs::No) {
523- removeUserXattrs ();
531+ wasInflated = removeUserXattrs ();
524532 }
525533
526534 // Datatype for no-value must be RAW
@@ -532,6 +540,8 @@ void Item::removeBodyAndOrXattrs(
532540 if (includeVal == IncludeValue::NoWithUnderlyingDatatype) {
533541 setDataType (originalDatatype);
534542 }
543+
544+ return wasInflated;
535545}
536546
537547item_info to_item_info (const ItemMetaData& itemMeta,
0 commit comments