diff options
author | Geert Bosch <geert@mongodb.com> | 2017-03-02 14:07:32 -0500 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2017-03-08 10:07:17 -0500 |
commit | 78052771af75f9c6fdff10796c82a38167274a6f (patch) | |
tree | 7fcfa87c45775dc86c86898501b2e06541ecd21b /src/mongo/bson/bsonelement.h | |
parent | 54f3fff857ac66be0cdca5a4ddce9f87a0d80e6a (diff) | |
download | mongo-78052771af75f9c6fdff10796c82a38167274a6f.tar.gz |
SERVER-27987 Create and persist UUIDs for newly created collections
Diffstat (limited to 'src/mongo/bson/bsonelement.h')
-rw-r--r-- | src/mongo/bson/bsonelement.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 111cbad442f..3120907b589 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -579,6 +579,17 @@ public: return Timestamp(); } + const std::array<unsigned char, 16> uuid() const { + int len = 0; + const char* data = nullptr; + if (type() == BinData && binDataType() == BinDataType::newUUID) + data = binData(len); + uassert(00000, "uuid must be a 16-byte binary field with UUID (4) subtype", len == 16); + std::array<unsigned char, 16> result; + memcpy(&result, data, len); + return result; + } + Date_t timestampTime() const { unsigned long long t = ConstDataView(value() + 4).read<LittleEndian<unsigned int>>(); return Date_t::fromMillisSinceEpoch(t * 1000); |