summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/ce/value_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/ce/value_utils.cpp')
-rw-r--r--src/mongo/db/query/ce/value_utils.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/query/ce/value_utils.cpp b/src/mongo/db/query/ce/value_utils.cpp
index 9838f91a285..f4bfd0e8b53 100644
--- a/src/mongo/db/query/ce/value_utils.cpp
+++ b/src/mongo/db/query/ce/value_utils.cpp
@@ -156,6 +156,18 @@ double valueToDouble(value::TypeTags tag, value::Value val) {
const double charToDbl = ch / std::pow(2, i * 8);
result += charToDbl;
}
+ } else if (tag == value::TypeTags::Date || tag == value::TypeTags::Timestamp) {
+ int64_t v = value::bitcastTo<int64_t>(val);
+ result = value::numericCast<double>(value::TypeTags::NumberInt64, v);
+
+ } else if (tag == value::TypeTags::ObjectId) {
+ auto objView =
+ ConstDataView(reinterpret_cast<const char*>(sbe::value::getObjectIdView(val)->data()));
+ // Take the first 8 bytes of the ObjectId.
+ // ToDo: consider using the entire ObjectId or other parts of it
+ // auto v = objView.read<LittleEndian<uint64_t>>(sizeof(uint32_t));
+ auto v = objView.read<LittleEndian<uint64_t>>();
+ result = value::numericCast<double>(value::TypeTags::NumberInt64, v);
} else {
uassert(6844500, "Unexpected value type", false);
}