diff options
Diffstat (limited to 'src/mongo/db/storage/biggie/biggie_sorted_impl.cpp')
-rw-r--r-- | src/mongo/db/storage/biggie/biggie_sorted_impl.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp b/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp index 6dc78eb4e06..e7ce7750c79 100644 --- a/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp +++ b/src/mongo/db/storage/biggie/biggie_sorted_impl.cpp @@ -83,13 +83,6 @@ BSONObj stripFieldNames(const BSONObj& obj) { return bob.obj(); } -Status dupKeyError(const BSONObj& key) { - StringBuilder sb; - sb << "E11000 duplicate key error "; - sb << "dup key: " << key; - return Status(ErrorCodes::DuplicateKey, sb.str()); -} - // This function converts a key and an ordering to a KeyString. std::unique_ptr<KeyString> keyToKeyString(const BSONObj& key, Ordering order) { KeyString::Version version = KeyString::Version::V1; @@ -220,13 +213,17 @@ int compareTwoKeys( SortedDataBuilderInterface::SortedDataBuilderInterface(OperationContext* opCtx, bool dupsAllowed, Ordering order, - std::string prefix, - std::string identEnd) + const std::string& prefix, + const std::string& identEnd, + const std::string& collectionNamespace, + const std::string& indexName) : _opCtx(opCtx), _dupsAllowed(dupsAllowed), _order(order), _prefix(prefix), _identEnd(identEnd), + _collectionNamespace(collectionNamespace), + _indexName(indexName), _hasLast(false), _lastKeyToString(""), _lastRID(-1) {} @@ -261,7 +258,7 @@ StatusWith<SpecialFormatInserted> SortedDataBuilderInterface::addKey(const BSONO "expected ascending (key, RecordId) order in bulk builder"); } if (!_dupsAllowed && twoKeyCmp == 0 && twoRIDCmp != 0) { - return dupKeyError(key); + return dupKeyError(key, _collectionNamespace, _indexName); } std::string workingCopyInsertKey = combineKeyAndRID(key, loc, _prefix, _order); @@ -283,18 +280,25 @@ StatusWith<SpecialFormatInserted> SortedDataBuilderInterface::addKey(const BSONO SortedDataBuilderInterface* SortedDataInterface::getBulkBuilder(OperationContext* opCtx, bool dupsAllowed) { - return new SortedDataBuilderInterface(opCtx, dupsAllowed, _order, _prefix, _identEnd); + return new SortedDataBuilderInterface( + opCtx, dupsAllowed, _order, _prefix, _identEnd, _collectionNamespace, _indexName); } // We append \1 to all idents we get, and therefore the KeyString with ident + \0 will only be // before elements in this ident, and the KeyString with ident + \2 will only be after elements in // this ident. -SortedDataInterface::SortedDataInterface(const Ordering& ordering, bool isUnique, StringData ident) +SortedDataInterface::SortedDataInterface(const Ordering& ordering, + bool isUnique, + StringData ident, + const std::string& collectionNamespace, + const std::string& indexName) : _order(ordering), // All entries in this ident will have a prefix of ident + \1. _prefix(ident.toString().append(1, '\1')), // Therefore, the string ident + \2 will be greater than all elements in this ident. _identEnd(ident.toString().append(1, '\2')), + _collectionNamespace(collectionNamespace), + _indexName(indexName), _isUnique(isUnique) { // This is the string representation of the KeyString before elements in this ident, which is // ident + \0. This is before all elements in this ident. @@ -340,7 +344,7 @@ StatusWith<SpecialFormatInserted> SortedDataInterface::insert(OperationContext* auto ks1 = keyToKeyString(ike.key, _order); auto ks2 = keyToKeyString(key, _order); if (ks1->compare(*ks2) == 0 && ike.loc.repr() != loc.repr()) { - return dupKeyError(key); + return dupKeyError(key, _collectionNamespace, _indexName); } } } @@ -398,7 +402,7 @@ Status SortedDataInterface::dupKeyCheck(OperationContext* opCtx, lowerBoundIterator->first.compare(_KSForIdentEnd) < 0 && lowerBoundIterator->first.compare( combineKeyAndRID(key, RecordId::max(), _prefix, _order)) <= 0) { - return dupKeyError(key); + return dupKeyError(key, _collectionNamespace, _indexName); } return Status::OK(); } |