diff options
Diffstat (limited to 'src/mongo/db/exec/document_value/document_metadata_fields.cpp')
| -rw-r--r-- | src/mongo/db/exec/document_value/document_metadata_fields.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/mongo/db/exec/document_value/document_metadata_fields.cpp b/src/mongo/db/exec/document_value/document_metadata_fields.cpp index 90e15ef5c2a..0532ed2e8cb 100644 --- a/src/mongo/db/exec/document_value/document_metadata_fields.cpp +++ b/src/mongo/db/exec/document_value/document_metadata_fields.cpp @@ -46,6 +46,7 @@ DocumentMetadataFields::DocumentMetadataFields(const DocumentMetadataFields& oth DocumentMetadataFields& DocumentMetadataFields::operator=(const DocumentMetadataFields& other) { _holder = other._holder ? std::make_unique<MetadataHolder>(*other._holder) : nullptr; + _modified = true; return *this; } @@ -54,6 +55,7 @@ DocumentMetadataFields::DocumentMetadataFields(DocumentMetadataFields&& other) DocumentMetadataFields& DocumentMetadataFields::operator=(DocumentMetadataFields&& other) { _holder = std::move(other._holder); + _modified = true; return *this; } @@ -91,6 +93,12 @@ void DocumentMetadataFields::mergeWith(const DocumentMetadataFields& other) { if (!hasTimeseriesBucketMaxTime() && other.hasTimeseriesBucketMaxTime()) { setTimeseriesBucketMaxTime(other.getTimeseriesBucketMaxTime()); } + if (!hasSearchSortValues() && other.hasSearchSortValues()) { + setSearchSortValues(other.getSearchSortValues()); + } + if (!hasVectorSearchScore() && other.hasVectorSearchScore()) { + setVectorSearchScore(other.getVectorSearchScore()); + } } void DocumentMetadataFields::copyFrom(const DocumentMetadataFields& other) { @@ -127,6 +135,12 @@ void DocumentMetadataFields::copyFrom(const DocumentMetadataFields& other) { if (other.hasTimeseriesBucketMaxTime()) { setTimeseriesBucketMaxTime(other.getTimeseriesBucketMaxTime()); } + if (other.hasSearchSortValues()) { + setSearchSortValues(other.getSearchSortValues()); + } + if (other.hasVectorSearchScore()) { + setVectorSearchScore(other.getVectorSearchScore()); + } } size_t DocumentMetadataFields::getApproximateSize() const { @@ -148,7 +162,7 @@ size_t DocumentMetadataFields::getApproximateSize() const { size -= sizeof(_holder->searchHighlights); size += _holder->indexKey.objsize(); size += _holder->searchScoreDetails.objsize(); - + size += _holder->searchSortValues.objsize(); return size; } @@ -204,6 +218,14 @@ void DocumentMetadataFields::serializeForSorter(BufBuilder& buf) const { buf.appendNum(static_cast<char>(MetaType::kTimeseriesBucketMaxTime + 1)); buf.appendNum(getTimeseriesBucketMaxTime().toMillisSinceEpoch()); } + if (hasSearchSortValues()) { + buf.appendNum(static_cast<char>(MetaType::kSearchSortValues + 1)); + getSearchSortValues().appendSelfToBufBuilder(buf); + } + if (hasVectorSearchScore()) { + buf.appendNum(static_cast<char>(MetaType::kVectorSearchScore + 1)); + buf.appendNum(getVectorSearchScore()); + } buf.appendNum(static_cast<char>(0)); } @@ -236,9 +258,16 @@ void DocumentMetadataFields::deserializeForSorter(BufReader& buf, DocumentMetada out->setSearchScoreDetails( BSONObj::deserializeForSorter(buf, BSONObj::SorterDeserializeSettings())); } else if (marker == static_cast<char>(MetaType::kTimeseriesBucketMinTime) + 1) { - out->setTimeseriesBucketMinTime(Date_t::fromMillisSinceEpoch(buf.read<long long>())); + out->setTimeseriesBucketMinTime( + Date_t::fromMillisSinceEpoch(buf.read<LittleEndian<long long>>())); } else if (marker == static_cast<char>(MetaType::kTimeseriesBucketMaxTime) + 1) { - out->setTimeseriesBucketMaxTime(Date_t::fromMillisSinceEpoch(buf.read<long long>())); + out->setTimeseriesBucketMaxTime( + Date_t::fromMillisSinceEpoch(buf.read<LittleEndian<long long>>())); + } else if (marker == static_cast<char>(MetaType::kSearchSortValues) + 1) { + out->setSearchSortValues( + BSONObj::deserializeForSorter(buf, BSONObj::SorterDeserializeSettings())); + } else if (marker == static_cast<char>(MetaType::kVectorSearchScore) + 1) { + out->setVectorSearchScore(buf.read<LittleEndian<double>>()); } else { uasserted(28744, "Unrecognized marker, unable to deserialize buffer"); } @@ -298,6 +327,10 @@ const char* DocumentMetadataFields::typeNameToDebugString(DocumentMetadataFields return "timeseries bucket min time"; case DocumentMetadataFields::kTimeseriesBucketMaxTime: return "timeseries bucket max time"; + case DocumentMetadataFields::kSearchSortValues: + return "$search sort values"; + case DocumentMetadataFields::kVectorSearchScore: + return "$vectorSearch distance"; default: MONGO_UNREACHABLE; } |
