@@ -416,42 +416,44 @@ item_info Item::toItemInfo(uint64_t vb_uuid, int64_t hlcEpoch) const {
416416 return info;
417417}
418418
419- void Item::removeBody () {
419+ Item::WasValueInflated Item::removeBody () {
420420 if (!value) {
421421 // No value, nothing to do
422- return ;
422+ return WasValueInflated::No ;
423423 }
424424
425425 if (!mcbp::datatype::is_xattr (getDataType ())) {
426426 // We don't want the body and there are no xattrs, just set empty value
427427 setData (nullptr , 0 );
428428 setDataType (PROTOCOL_BINARY_RAW_BYTES);
429- return ;
429+ return WasValueInflated::No ;
430430 }
431431
432432 // No-op if already uncompressed
433- decompressValue ();
433+ const auto wasInflated = decompressValue ();
434434
435435 // We want only xattrs.
436436 // Note: The following is no-op if no Body present.
437437 std::string_view valBuffer{value->getData (), value->valueSize ()};
438438 setData (valBuffer.data (), cb::xattr::get_body_offset (valBuffer));
439439 setDataType (PROTOCOL_BINARY_DATATYPE_XATTR);
440+
441+ return wasInflated ? WasValueInflated::Yes : WasValueInflated::No;
440442}
441443
442- void Item::removeXattrs () {
444+ Item::WasValueInflated Item::removeXattrs () {
443445 if (!value) {
444446 // No value, nothing to do
445- return ;
447+ return WasValueInflated::No ;
446448 }
447449
448450 if (!mcbp::datatype::is_xattr (getDataType ())) {
449451 // No Xattrs, nothing to do
450- return ;
452+ return WasValueInflated::No ;
451453 }
452454
453455 // No-op if already uncompressed
454- decompressValue ();
456+ const auto wasInflated = decompressValue ();
455457
456458 // We want only the body
457459 std::string_view valBuffer{value->getData (), value->valueSize ()};
@@ -466,21 +468,23 @@ void Item::removeXattrs() {
466468 // Subdoc logic for details. Here we have to rectify.
467469 setDataType (getDataType () & ~PROTOCOL_BINARY_DATATYPE_JSON);
468470 }
471+
472+ return wasInflated ? WasValueInflated::Yes : WasValueInflated::No;
469473}
470474
471- void Item::removeUserXattrs () {
475+ Item::WasValueInflated Item::removeUserXattrs () {
472476 if (!value) {
473477 // No value, nothing to do
474- return ;
478+ return WasValueInflated::No ;
475479 }
476480
477481 if (!mcbp::datatype::is_xattr (getDataType ())) {
478482 // No Xattrs, nothing to do
479- return ;
483+ return WasValueInflated::No ;
480484 }
481485
482486 // No-op if already uncompressed
483- decompressValue ();
487+ const auto wasInflated = decompressValue ();
484488
485489 // The function currently does not support value with body.
486490 // That is fine for now as this is introduced for MB-37374, thus is supposed
@@ -507,33 +511,37 @@ void Item::removeUserXattrs() {
507511 // Note: Doing this unconditionally as we reach this line iff there is no
508512 // body. We would need to do this conditionally otherwise.
509513 setDataType (getDataType () & ~PROTOCOL_BINARY_DATATYPE_JSON);
514+
515+ return wasInflated ? WasValueInflated::Yes : WasValueInflated::No;
510516}
511517
512- void Item::removeBodyAndOrXattrs (
518+ Item::WasValueInflated Item::removeBodyAndOrXattrs (
513519 IncludeValue includeVal,
514520 IncludeXattrs includeXattrs,
515521 IncludeDeletedUserXattrs includeDeletedUserXattrs) {
516522 if (!value) {
517523 // If no value (ie, no body and/or xattrs) then nothing to do
518- return ;
524+ return WasValueInflated::No ;
519525 }
520526
521527 // Take a copy of the original datatype before proceeding, any modification
522528 // to the value may change the datatype.
523529 const auto originalDatatype = getDataType ();
524530
531+ auto wasInflated = WasValueInflated::No;
532+
525533 // Note: IncludeValue acts like "include body"
526534 if (includeVal != IncludeValue::Yes) {
527- removeBody ();
535+ wasInflated = removeBody ();
528536 }
529537
530538 if (includeXattrs == IncludeXattrs::No) {
531- removeXattrs ();
539+ wasInflated = removeXattrs ();
532540 }
533541
534542 if (isDeleted () &&
535543 includeDeletedUserXattrs == IncludeDeletedUserXattrs::No) {
536- removeUserXattrs ();
544+ wasInflated = removeUserXattrs ();
537545 }
538546
539547 // Datatype for no-value must be RAW
@@ -545,6 +553,8 @@ void Item::removeBodyAndOrXattrs(
545553 if (includeVal == IncludeValue::NoWithUnderlyingDatatype) {
546554 setDataType (originalDatatype);
547555 }
556+
557+ return wasInflated;
548558}
549559
550560item_info to_item_info (const ItemMetaData& itemMeta,
0 commit comments