summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp13
-rw-r--r--src/mongo/db/catalog/index_catalog.h4
-rw-r--r--src/mongo/db/dbcommands.cpp2
-rw-r--r--src/mongo/db/instance.cpp17
-rw-r--r--src/mongo/db/jsobjmanipulator.h82
-rw-r--r--src/mongo/db/mongod.vcxproj1
-rw-r--r--src/mongo/db/mongod.vcxproj.filters3
-rw-r--r--src/mongo/dbtests/test.vcxproj1
-rwxr-xr-xsrc/mongo/dbtests/test.vcxproj.filters6
-rwxr-xr-xsrc/mongo/shell/mongo.vcxproj3
-rw-r--r--src/mongo/shell/mongo.vcxproj.filters5
-rw-r--r--src/mongo/tools/stat.cpp8
12 files changed, 18 insertions, 127 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 5fd15c916b7..1b671b7dfa1 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -53,7 +53,6 @@
#include "mongo/db/index_legacy.h"
#include "mongo/db/index_names.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/jsobjmanipulator.h"
#include "mongo/db/keypattern.h"
#include "mongo/db/kill_current_op.h"
#include "mongo/db/ops/delete.h"
@@ -962,7 +961,9 @@ namespace mongo {
return toReturn;
}
- void IndexCatalog::updateTTLSetting( const IndexDescriptor* idx, long long newExpireSeconds ) {
+ void IndexCatalog::updateTTLSetting( TransactionExperiment* txn,
+ const IndexDescriptor* idx,
+ long long newExpireSeconds ) {
IndexDetails* indexDetails = _getIndexDetails( idx );
const BSONElement oldExpireSecs =
@@ -971,19 +972,19 @@ namespace mongo {
// Important that we set the new value in-place. We are writing directly to the
// object here so must be careful not to overwrite with a longer numeric type.
- BSONElementManipulator manip( oldExpireSecs );
+ char* nonConstPtr = const_cast<char*>(oldExpireSecs.value());
switch( oldExpireSecs.type() ) {
case EOO:
massert( 16631, "index does not have an 'expireAfterSeconds' field", false );
break;
case NumberInt:
- manip.SetInt( static_cast<int>( newExpireSeconds ) );
+ *txn->writing(reinterpret_cast<int*>(nonConstPtr)) = newExpireSeconds;
break;
case NumberDouble:
- manip.SetNumber( static_cast<double>( newExpireSeconds ) );
+ *txn->writing(reinterpret_cast<double*>(nonConstPtr)) = newExpireSeconds;
break;
case NumberLong:
- manip.SetLong( newExpireSeconds );
+ *txn->writing(reinterpret_cast<long long*>(nonConstPtr)) = newExpireSeconds;
break;
default:
massert( 16632, "current 'expireAfterSeconds' is not a number", false );
diff --git a/src/mongo/db/catalog/index_catalog.h b/src/mongo/db/catalog/index_catalog.h
index 7646cbd53f1..249f922efd9 100644
--- a/src/mongo/db/catalog/index_catalog.h
+++ b/src/mongo/db/catalog/index_catalog.h
@@ -185,7 +185,9 @@ namespace mongo {
* The specified index must already contain an expireAfterSeconds field, and the value in
* that field and newExpireSecs must both be numeric.
*/
- void updateTTLSetting( const IndexDescriptor* idx, long long newExpireSeconds );
+ void updateTTLSetting( TransactionExperiment* txn,
+ const IndexDescriptor* idx,
+ long long newExpireSeconds );
bool isMultikey( const IndexDescriptor* idex );
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index c41fd2b65a5..c639b770d79 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -1279,7 +1279,7 @@ namespace mongo {
if ( oldExpireSecs != newExpireSecs ) {
// change expireAfterSeconds
result.appendAs( oldExpireSecs, "expireAfterSeconds_old" );
- coll->getIndexCatalog()->updateTTLSetting( idx, newExpireSecs.numberLong() );
+ coll->getIndexCatalog()->updateTTLSetting( &txn, idx, newExpireSecs.numberLong() );
result.appendAs( newExpireSecs , "expireAfterSeconds_new" );
}
}
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 2efe48f1160..69d834cf332 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -58,7 +58,6 @@
#include "mongo/db/storage/mmap_v1/dur_transaction.h"
#include "mongo/db/instance.h"
#include "mongo/db/introspect.h"
-#include "mongo/db/jsobjmanipulator.h"
#include "mongo/db/json.h"
#include "mongo/db/kill_current_op.h"
#include "mongo/db/lasterror.h"
@@ -115,22 +114,6 @@ namespace mongo {
MONGO_FP_DECLARE(rsStopGetMore);
- void BSONElementManipulator::SetNumber(double d) {
- if ( _element.type() == NumberDouble )
- *getDur().writing( reinterpret_cast< double * >( value() ) ) = d;
- else if ( _element.type() == NumberInt )
- *getDur().writing( reinterpret_cast< int * >( value() ) ) = (int) d;
- else verify(0);
- }
- void BSONElementManipulator::SetLong(long long n) {
- verify( _element.type() == NumberLong );
- *getDur().writing( reinterpret_cast< long long * >(value()) ) = n;
- }
- void BSONElementManipulator::SetInt(int n) {
- verify( _element.type() == NumberInt );
- getDur().writingInt( *reinterpret_cast< int * >( value() ) ) = n;
- }
-
void inProgCmd( Message &m, DbResponse &dbresponse ) {
DbMessage d(m);
QueryMessage q(d);
diff --git a/src/mongo/db/jsobjmanipulator.h b/src/mongo/db/jsobjmanipulator.h
deleted file mode 100644
index 85f2b5cc65a..00000000000
--- a/src/mongo/db/jsobjmanipulator.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/** jsobjManipulator.h */
-
-/**
- * Copyright (C) 2009 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#pragma once
-
-#include "mongo/db/jsobj.h"
-
-namespace mongo {
-
- /** Manipulate the binary representation of a BSONElement in-place.
- Careful, this casts away const.
- */
- class BSONElementManipulator {
- public:
- BSONElementManipulator( const BSONElement &element ) :
- _element( element ) {
- verify( !_element.eoo() );
- }
-
- // Note the ones with a capital letter call getDur().writing and journal
-
- /** Change the value, in place, of the number. */
- void setNumber(double d) {
- if ( _element.type() == NumberDouble ) *reinterpret_cast< double * >( value() ) = d;
- else if ( _element.type() == NumberInt ) *reinterpret_cast< int * >( value() ) = (int) d;
- else verify(0);
- }
- void SetNumber(double d);
- void setLong(long long n) {
- verify( _element.type() == NumberLong );
- *reinterpret_cast< long long * >( value() ) = n;
- }
- void SetLong(long long n);
- void setInt(int n) {
- verify( _element.type() == NumberInt );
- *reinterpret_cast< int * >( value() ) = n;
- }
- void SetInt(int n);
-
- /** Replace the type and value of the element with the type and value of e,
- preserving the original fieldName */
- void replaceTypeAndValue( const BSONElement &e ) {
- *data() = e.type();
- memcpy( value(), e.value(), e.valuesize() );
- }
-
- private:
- char *data() { return nonConst( _element.rawdata() ); }
- char *value() { return nonConst( _element.value() ); }
- static char *nonConst( const char *s ) { return const_cast< char * >( s ); }
-
- const BSONElement _element;
- };
-
-} // namespace mongo
diff --git a/src/mongo/db/mongod.vcxproj b/src/mongo/db/mongod.vcxproj
index 516ea3485f3..ccc3e6fa3f0 100644
--- a/src/mongo/db/mongod.vcxproj
+++ b/src/mongo/db/mongod.vcxproj
@@ -4474,7 +4474,6 @@ cscript //Nologo "$(ProjectDir)..\shell\createCPPfromJavaScriptFiles.js" "$(Proj
<ClInclude Include="index_update.h" />
<ClInclude Include="initialize_server_global_state.h" />
<ClInclude Include="intervalbtreecursor.h" />
- <ClInclude Include="jsobjmanipulator.h" />
<ClInclude Include="key.h" />
<ClInclude Include="keypattern.h" />
<ClInclude Include="kill_current_op.h" />
diff --git a/src/mongo/db/mongod.vcxproj.filters b/src/mongo/db/mongod.vcxproj.filters
index c1445e3635e..c1696cd9c6f 100644
--- a/src/mongo/db/mongod.vcxproj.filters
+++ b/src/mongo/db/mongod.vcxproj.filters
@@ -3896,9 +3896,6 @@
<ClInclude Include="filever.h">
<Filter>db\Header Files\e to n</Filter>
</ClInclude>
- <ClInclude Include="jsobjmanipulator.h">
- <Filter>db\Header Files\e to n</Filter>
- </ClInclude>
<ClInclude Include="key.h">
<Filter>db\Header Files\e to n</Filter>
</ClInclude>
diff --git a/src/mongo/dbtests/test.vcxproj b/src/mongo/dbtests/test.vcxproj
index 4ae594420e2..547bf5e07c9 100644
--- a/src/mongo/dbtests/test.vcxproj
+++ b/src/mongo/dbtests/test.vcxproj
@@ -739,7 +739,6 @@ cscript //Nologo "$(ProjectDir)..\shell\createCPPfromJavaScriptFiles.js" "$(Proj
<ClInclude Include="..\db\interrupt_status.h" />
<ClInclude Include="..\db\interrupt_status_mongod.h" />
<ClInclude Include="..\db\intervalbtreecursor.h" />
- <ClInclude Include="..\db\jsobjmanipulator.h" />
<ClInclude Include="..\db\key.h" />
<ClInclude Include="..\db\keypattern.h" />
<ClInclude Include="..\db\kill_current_op.h" />
diff --git a/src/mongo/dbtests/test.vcxproj.filters b/src/mongo/dbtests/test.vcxproj.filters
index 30e8d34eb63..b8411f8557c 100755
--- a/src/mongo/dbtests/test.vcxproj.filters
+++ b/src/mongo/dbtests/test.vcxproj.filters
@@ -478,9 +478,6 @@
<ClInclude Include="..\db\jsobj.h">
<Filter>db\Header Files\e to n</Filter>
</ClInclude>
- <ClInclude Include="..\db\jsobjmanipulator.h">
- <Filter>db\Header Files\e to n</Filter>
- </ClInclude>
<ClInclude Include="..\db\json.h">
<Filter>db\Header Files\e to n</Filter>
</ClInclude>
@@ -520,9 +517,6 @@
<ClInclude Include="..\db\ops\update.h">
<Filter>db\ops</Filter>
</ClInclude>
- <ClInclude Include="..\db\jsobjmanipulator.h">
- <Filter>db\Header Files\e to n</Filter>
- </ClInclude>
<ClInclude Include="..\db\mongomutex.h">
<Filter>db\Header Files\e to n</Filter>
</ClInclude>
diff --git a/src/mongo/shell/mongo.vcxproj b/src/mongo/shell/mongo.vcxproj
index 220e84e6419..66a70967918 100755
--- a/src/mongo/shell/mongo.vcxproj
+++ b/src/mongo/shell/mongo.vcxproj
@@ -2025,7 +2025,6 @@ cscript //Nologo "$(ProjectDir)..\shell\createCPPfromJavaScriptFiles.js" "$(Proj
<ClInclude Include="..\db\index.h" />
<ClInclude Include="..\db\instance.h" />
<ClInclude Include="..\db\jsobj.h" />
- <ClInclude Include="..\db\jsobjmanipulator.h" />
<ClInclude Include="..\db\json.h" />
<ClInclude Include="..\db\key.h" />
<ClInclude Include="..\db\lasterror.h" />
@@ -2108,4 +2107,4 @@ cscript //Nologo "$(ProjectDir)..\shell\createCPPfromJavaScriptFiles.js" "$(Proj
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/mongo/shell/mongo.vcxproj.filters b/src/mongo/shell/mongo.vcxproj.filters
index f50d05d0b29..de520405e75 100644
--- a/src/mongo/shell/mongo.vcxproj.filters
+++ b/src/mongo/shell/mongo.vcxproj.filters
@@ -1468,9 +1468,6 @@
<ClInclude Include="..\db\jsobj.h">
<Filter>db\Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\db\jsobjmanipulator.h">
- <Filter>db\Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\db\json.h">
<Filter>db\Header Files</Filter>
</ClInclude>
@@ -2620,4 +2617,4 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/mongo/tools/stat.cpp b/src/mongo/tools/stat.cpp
index 30bb78252e1..499866fa331 100644
--- a/src/mongo/tools/stat.cpp
+++ b/src/mongo/tools/stat.cpp
@@ -35,7 +35,6 @@
#include "mongo/base/init.h"
#include "mongo/client/dbclientcursor.h"
#include "mongo/client/sasl_client_authenticate.h"
-#include "mongo/db/jsobjmanipulator.h"
#include "mongo/db/json.h"
#include "mongo/s/type_shard.h"
#include "mongo/tools/stat_util.h"
@@ -201,8 +200,11 @@ namespace mongo {
if ( e.isABSONObj() ) {
BSONObj x = e.Obj();
if ( x["width"].numberInt() < *maxWidth ) {
- BSONElementManipulator manip( x["width"] );
- manip.setNumber( *maxWidth );
+ // TODO somthing less horrible.
+ BSONElement width = x["width"];
+ invariant(width.type() == NumberInt);
+ char* nonConstPtr = const_cast<char*>(width.value());
+ *reinterpret_cast<int*>(nonConstPtr) = *maxWidth;
}
else {
*maxWidth = x["width"].numberInt();