balancer_policy.h   balancer_policy.h 
skipping to change at line 34 skipping to change at line 34
* file(s) with this exception, you may extend this exception to your * 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 * 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 y ou * wish to do so, delete this exception statement from your version. If y ou
* delete this exception statement from all source files in the program, * delete this exception statement from all source files in the program,
* then also delete it in the license file. * then also delete it in the license file.
*/ */
#ifndef S_BALANCER_POLICY_HEADER #ifndef S_BALANCER_POLICY_HEADER
#define S_BALANCER_POLICY_HEADER #define S_BALANCER_POLICY_HEADER
#include "mongo/base/status_with.h"
#include "mongo/base/owned_pointer_vector.h"
#include "mongo/db/jsobj.h" #include "mongo/db/jsobj.h"
#include "mongo/s/shard.h"
#include "mongo/s/type_chunk.h" #include "mongo/s/type_chunk.h"
namespace mongo { namespace mongo {
class ChunkManager;
struct ChunkInfo { struct ChunkInfo {
const BSONObj min; const BSONObj min;
const BSONObj max; const BSONObj max;
ChunkInfo( const BSONObj& a_min, const BSONObj& a_max ) ChunkInfo( const BSONObj& a_min, const BSONObj& a_max )
: min( a_min.getOwned() ), max( a_max.getOwned() ){} : min( a_min.getOwned() ), max( a_max.getOwned() ){}
ChunkInfo( const BSONObj& chunk ) ChunkInfo( const BSONObj& chunk )
: min(chunk[ChunkType::min()].Obj().getOwned()), : min(chunk[ChunkType::min()].Obj().getOwned()),
max(chunk[ChunkType::max()].Obj().getOwned()) { max(chunk[ChunkType::max()].Obj().getOwned()) {
skipping to change at line 125 skipping to change at line 130
const string ns; const string ns;
const string to; const string to;
const string from; const string from;
const ChunkInfo chunk; const ChunkInfo chunk;
MigrateInfo( const string& a_ns , const string& a_to , const string & a_from , const BSONObj& a_chunk ) MigrateInfo( const string& a_ns , const string& a_to , const string & a_from , const BSONObj& a_chunk )
: ns( a_ns ) , to( a_to ) , from( a_from ), chunk( a_chunk ) {} : ns( a_ns ) , to( a_to ) , from( a_from ), chunk( a_chunk ) {}
}; };
typedef map< string,ShardInfo > ShardInfoMap; typedef std::map< std::string,ShardInfo > ShardInfoMap;
typedef map< string,vector<BSONObj> > ShardToChunksMap; typedef std::map<std::string, OwnedPointerVector<ChunkType>* > ShardToC
hunksMap;
class DistributionStatus : boost::noncopyable { class DistributionStatus : boost::noncopyable {
public: public:
DistributionStatus( const ShardInfoMap& shardInfo, DistributionStatus( const ShardInfoMap& shardInfo,
const ShardToChunksMap& shardToChunksMap ); const ShardToChunksMap& shardToChunksMap );
// only used when building // only used when building
/** /**
* @return if range is valid * @return if range is valid
skipping to change at line 166 skipping to change at line 171
/** @return total number of chunks */ /** @return total number of chunks */
unsigned totalChunks() const; unsigned totalChunks() const;
/** @return number of chunks in this shard */ /** @return number of chunks in this shard */
unsigned numberOfChunksInShard( const string& shard ) const; unsigned numberOfChunksInShard( const string& shard ) const;
/** @return number of chunks in this shard with the given tag */ /** @return number of chunks in this shard with the given tag */
unsigned numberOfChunksInShardWithTag( const string& shard, const s tring& tag ) const; unsigned numberOfChunksInShardWithTag( const string& shard, const s tring& tag ) const;
/** @return chunks for the shard */ /** @return chunks for the shard */
const vector<BSONObj>& getChunks( const string& shard ) const; const std::vector<ChunkType*>& getChunks(const std::string& shard) const;
/** @return all tags we know about, not include "" */ /** @return all tags we know about, not include "" */
const set<string>& tags() const { return _allTags; } const set<string>& tags() const { return _allTags; }
/** @return the right tag for chunk, possibly "" */ /** @return the right tag for chunk, possibly "" */
string getTagForChunk( const BSONObj& chunk ) const; std::string getTagForChunk(const ChunkType& chunk) const;
/** @return all shards we know about */ /** @return all shards we know about */
const set<string>& shards() const { return _shards; } const set<string>& shards() const { return _shards; }
/** @return the ShardInfo for the shard */ /** @return the ShardInfo for the shard */
const ShardInfo& shardInfo( const string& shard ) const; const ShardInfo& shardInfo( const string& shard ) const;
/** writes all state to log() */ /** writes all state to log() */
void dump() const; void dump() const;
static void populateShardInfoMap(const std::vector<Shard> allShards
,
ShardInfoMap* shardInfo);
/**
* Note: jumbo and versions are not set.
*/
static void populateShardToChunksMap(const std::vector<Shard>& allS
hards,
const ChunkManager& chunkMgr,
ShardToChunksMap* shardToChunk
sMap);
/**
* Returns the tag of the given chunk by querying the config server
.
*
* TODO: add a way to incrementally update chunk tags metadata so t
his is not needed.
*/
static StatusWith<std::string> getTagForSingleChunk(const std::stri
ng& configServer,
const std::stri
ng& ns,
const ChunkType
& chunk);
private: private:
const ShardInfoMap& _shardInfo; const ShardInfoMap& _shardInfo;
const ShardToChunksMap& _shardChunks; const ShardToChunksMap& _shardChunks;
map<BSONObj,TagRange> _tagRanges; map<BSONObj,TagRange> _tagRanges;
set<string> _allTags; set<string> _allTags;
set<string> _shards; set<string> _shards;
}; };
class BalancerPolicy { class BalancerPolicy {
public: public:
skipping to change at line 208 skipping to change at line 232
* *
* @param ns is the collections namepace. * @param ns is the collections namepace.
* @param DistributionStatus holds all the info about the current s tate of the cluster/namespace * @param DistributionStatus holds all the info about the current s tate of the cluster/namespace
* @param balancedLastTime is the number of chunks effectively move d in the last round. * @param balancedLastTime is the number of chunks effectively move d in the last round.
* @returns NULL or MigrateInfo of the best move to make towards ba lacing the collection. * @returns NULL or MigrateInfo of the best move to make towards ba lacing the collection.
* caller owns the MigrateInfo instance * caller owns the MigrateInfo instance
*/ */
static MigrateInfo* balance( const string& ns, static MigrateInfo* balance( const string& ns,
const DistributionStatus& distribution , const DistributionStatus& distribution ,
int balancedLastTime ); int balancedLastTime );
private:
static bool _isJumbo( const BSONObj& chunk );
}; };
} // namespace mongo } // namespace mongo
#endif // S_BALANCER_POLICY_HEADER #endif // S_BALANCER_POLICY_HEADER
 End of changes. 8 change blocks. 
7 lines changed or deleted 37 lines changed or added


 chunk.h   chunk.h 
skipping to change at line 425 skipping to change at line 425
*/ */
ChunkPtr findIntersectingChunk( const BSONObj& point ) const; ChunkPtr findIntersectingChunk( const BSONObj& point ) const;
ChunkPtr findChunkOnServer( const Shard& shard ) const; ChunkPtr findChunkOnServer( const Shard& shard ) const;
void getShardsForQuery( set<Shard>& shards , const BSONObj& query ) const; void getShardsForQuery( set<Shard>& shards , const BSONObj& query ) const;
void getAllShards( set<Shard>& all ) const; void getAllShards( set<Shard>& all ) const;
/** @param shards set to the shards covered by the interval [min, m ax], see SERVER-4791 */ /** @param shards set to the shards covered by the interval [min, m ax], see SERVER-4791 */
void getShardsForRange( set<Shard>& shards, const BSONObj& min, con st BSONObj& max ) const; void getShardsForRange( set<Shard>& shards, const BSONObj& min, con st BSONObj& max ) const;
ChunkMap getChunkMap() const { return _chunkMap; } const ChunkMap& getChunkMap() const { return _chunkMap; }
/** /**
* Returns true if, for this shard, the chunks are identical in bot h chunk managers * Returns true if, for this shard, the chunks are identical in bot h chunk managers
*/ */
bool compatibleWith( const ChunkManager& other, const Shard& shard ) const; bool compatibleWith( const ChunkManager& other, const Shard& shard ) const;
bool compatibleWith( ChunkManagerPtr other, const Shard& shard ) co nst { if( ! other ) return false; return compatibleWith( *other, shard ); } bool compatibleWith( ChunkManagerPtr other, const Shard& shard ) co nst { if( ! other ) return false; return compatibleWith( *other, shard ); }
bool compatibleWith( const Chunk& other ) const; bool compatibleWith( const Chunk& other ) const;
bool compatibleWith( ChunkPtr other ) const { if( ! other ) return false; return compatibleWith( *other ); } bool compatibleWith( ChunkPtr other ) const { if( ! other ) return false; return compatibleWith( *other ); }
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 compiler.h   compiler.h 
/* // Copyright 2012 the V8 project authors. All rights reserved.
* Copyright 2012 10gen Inc. // Redistribution and use in source and binary forms, with or without
* // modification, are permitted provided that the following conditions are
* Licensed under the Apache License, Version 2.0 (the "License"); // met:
* you may not use this file except in compliance with the License. //
* You may obtain a copy of the License at // * Redistributions of source code must retain the above copyright
* // notice, this list of conditions and the following disclaimer.
* http://www.apache.org/licenses/LICENSE-2.0 // * Redistributions in binary form must reproduce the above
* // copyright notice, this list of conditions and the following
* Unless required by applicable law or agreed to in writing, software // disclaimer in the documentation and/or other materials provided
* distributed under the License is distributed on an "AS IS" BASIS, // with the distribution.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // * Neither the name of Google Inc. nor the names of its
* See the License for the specific language governing permissions and // contributors may be used to endorse or promote products derived
* limitations under the License. // from this software without specific prior written permission.
*/ //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#pragma once // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
/** // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* Include "mongo/platform/compiler.h" to get compiler-targeted macro defin // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
itions and utilities. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* The following macros are provided in all compiler environments: // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* MONGO_COMPILER_NORETURN // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Instructs the compiler that the decorated function will not return thr #ifndef V8_COMPILER_H_
ough the normal return #define V8_COMPILER_H_
* path.
* #include "allocation.h"
* Correct: MONGO_COMPILER_NORETURN void myAbortFunction(); #include "ast.h"
* #include "zone.h"
*
* MONGO_COMPILER_VARIABLE_UNUSED namespace v8 {
* namespace internal {
* Instructs the compiler not to warn if it detects no use of the decorat
ed variable. class ScriptDataImpl;
* Typically only useful for variables that are always declared but only
used in // CompilationInfo encapsulates some information known at compile time. It
* conditionally-compiled code. // is constructed based on the resources available at compile-time.
* class CompilationInfo {
* Correct: MONGO_COMPILER_VARIABLE_UNUSED int ignored; public:
* CompilationInfo(Handle<Script> script, Zone* zone);
* CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
* MONGO_COMPILER_ALIGN_TYPE(ALIGNMENT) CompilationInfo(Handle<JSFunction> closure, Zone* zone);
*
* Instructs the compiler to use the given minimum alignment for the deco virtual ~CompilationInfo();
rated type.
* Isolate* isolate() {
* Alignments should probably always be powers of two. Also, note that m ASSERT(Isolate::Current() == isolate_);
ost allocators will not return isolate_;
* be able to guarantee better than 16- or 32-byte alignment. }
* Zone* zone() {
* Correct: return zone_;
* class MONGO_COMPILER_ALIGN_TYPE(16) MyClass {...}; }
* bool is_lazy() const { return IsLazy::decode(flags_); }
* Incorrect: bool is_eval() const { return IsEval::decode(flags_); }
* MONGO_COMPILER_ALIGN_TYPE(16) class MyClass {...}; bool is_global() const { return IsGlobal::decode(flags_); }
* class MyClass{...} MONGO_COMPILER_ALIGN_TYPE(16); bool is_classic_mode() const { return language_mode() == CLASSIC_MODE; }
* bool is_extended_mode() const { return language_mode() == EXTENDED_MODE;
* }
* MONGO_COMPILER_ALIGN_VARIABLE(ALIGNMENT) LanguageMode language_mode() const {
* return LanguageModeField::decode(flags_);
* Instructs the compiler to use the given minimum alignment for the deco }
rated variable. bool is_in_loop() const { return IsInLoop::decode(flags_); }
* FunctionLiteral* function() const { return function_; }
* Note that most allocators will not allow heap allocated alignments tha Scope* scope() const { return scope_; }
t are better than 16- or Scope* global_scope() const { return global_scope_; }
* 32-byte aligned. Stack allocators may only guarantee up to the natura Handle<Code> code() const { return code_; }
l word length worth of Handle<JSFunction> closure() const { return closure_; }
* alignment. Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
* Handle<Script> script() const { return script_; }
* Correct: v8::Extension* extension() const { return extension_; }
* class MyClass { ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; }
* MONGO_COMPILER_ALIGN_VARIABLE(8) char a; Handle<Context> calling_context() const { return calling_context_; }
* }; int osr_ast_id() const { return osr_ast_id_; }
*
* MONGO_COMPILER_ALIGN_VARIABLE(8) class MyClass {...} singletonInstan void MarkAsEval() {
ce; ASSERT(!is_lazy());
* flags_ |= IsEval::encode(true);
* Incorrect: }
* int MONGO_COMPILER_ALIGN_VARIABLE(16) a, b; void MarkAsGlobal() {
* ASSERT(!is_lazy());
* flags_ |= IsGlobal::encode(true);
* MONGO_COMPILER_API_EXPORT }
* void SetLanguageMode(LanguageMode language_mode) {
* Instructs the compiler to label the given type, variable or function a ASSERT(this->language_mode() == CLASSIC_MODE ||
s part of the this->language_mode() == language_mode ||
* exported interface of the library object under construction. language_mode == EXTENDED_MODE);
* flags_ = LanguageModeField::update(flags_, language_mode);
* Correct: }
* MONGO_COMPILER_API_EXPORT int globalSwitch; void MarkAsInLoop() {
* class MONGO_COMPILER_API_EXPORT ExportedType { ... }; ASSERT(is_lazy());
* MONGO_COMPILER_API_EXPORT SomeType exportedFunction(...); flags_ |= IsInLoop::encode(true);
* }
* NOTE: Rather than using this macro directly, one typically declares an void MarkAsNative() {
other macro named for the flags_ |= IsNative::encode(true);
* library, which is conditionally defined to either MONGO_COMIPLER_API_E }
XPORT or bool is_native() const {
* MONGO_COMPILER_API_IMPORT based on whether the compiler is currently b return IsNative::decode(flags_);
uilding the library or }
* building an object that depends on the library, respectively. For exa void SetFunction(FunctionLiteral* literal) {
mple, MONGO_CLIENT_API ASSERT(function_ == NULL);
* might be defined to MONGO_COMPILER_API_EXPORT when building the MongoD function_ = literal;
B shared library, and to }
* MONGO_COMPILER_API_IMPORT when building an application that links agai void SetScope(Scope* scope) {
nst the shared library. ASSERT(scope_ == NULL);
* scope_ = scope;
* }
* MONGO_COMPILER_API_IMPORT void SetGlobalScope(Scope* global_scope) {
* ASSERT(global_scope_ == NULL);
* Instructs the compiler to label the given type, variable or function a global_scope_ = global_scope;
s imported }
* from another library, and not part of the library object under constru void SetCode(Handle<Code> code) { code_ = code; }
ction. void SetExtension(v8::Extension* extension) {
* ASSERT(!is_lazy());
* Same correct/incorrect usage as for MONGO_COMPILER_API_EXPORT. extension_ = extension;
* }
* void SetPreParseData(ScriptDataImpl* pre_parse_data) {
* MONGO_COMPILER_API_CALLING_CONVENTION ASSERT(!is_lazy());
* pre_parse_data_ = pre_parse_data;
* Explicitly decorates a function declaration the api calling conventio }
n used for void SetCallingContext(Handle<Context> context) {
* shared libraries. ASSERT(is_eval());
* calling_context_ = context;
* Same correct/incorrect usage as for MONGO_COMPILER_API_EXPORT. }
*/ void SetOsrAstId(int osr_ast_id) {
ASSERT(IsOptimizing());
#if defined(_MSC_VER) osr_ast_id_ = osr_ast_id;
#include "mongo/platform/compiler_msvc.h" }
#elif defined(__GNUC__) void MarkCompilingForDebugging(Handle<Code> current_code) {
#include "mongo/platform/compiler_gcc.h" ASSERT(mode_ != OPTIMIZE);
#else ASSERT(current_code->kind() == Code::FUNCTION);
#error "Unsupported compiler family" flags_ |= IsCompilingForDebugging::encode(true);
if (current_code->is_compiled_optimizable()) {
EnableDeoptimizationSupport();
} else {
mode_ = CompilationInfo::NONOPT;
}
}
bool IsCompilingForDebugging() {
return IsCompilingForDebugging::decode(flags_);
}
bool has_global_object() const {
return !closure().is_null() && (closure()->context()->global() != NULL)
;
}
GlobalObject* global_object() const {
return has_global_object() ? closure()->context()->global() : NULL;
}
// Accessors for the different compilation modes.
bool IsOptimizing() const { return mode_ == OPTIMIZE; }
bool IsOptimizable() const { return mode_ == BASE; }
void SetOptimizing(int osr_ast_id) {
SetMode(OPTIMIZE);
osr_ast_id_ = osr_ast_id;
}
void DisableOptimization();
// Deoptimization support.
bool HasDeoptimizationSupport() const {
return SupportsDeoptimization::decode(flags_);
}
void EnableDeoptimizationSupport() {
ASSERT(IsOptimizable());
flags_ |= SupportsDeoptimization::encode(true);
}
// Determines whether or not to insert a self-optimization header.
bool ShouldSelfOptimize();
// Disable all optimization attempts of this info for the rest of the
// current compilation pipeline.
void AbortOptimization();
void set_deferred_handles(DeferredHandles* deferred_handles) {
ASSERT(deferred_handles_ == NULL);
deferred_handles_ = deferred_handles;
}
void SaveHandles() {
SaveHandle(&closure_);
SaveHandle(&shared_info_);
SaveHandle(&calling_context_);
SaveHandle(&script_);
}
private:
Isolate* isolate_;
// Compilation mode.
// BASE is generated by the full codegen, optionally prepared for bailout
s.
// OPTIMIZE is optimized code generated by the Hydrogen-based backend.
// NONOPT is generated by the full codegen and is not prepared for
// recompilation/bailouts. These functions are never recompiled.
enum Mode {
BASE,
OPTIMIZE,
NONOPT
};
void Initialize(Mode mode) {
mode_ = V8::UseCrankshaft() ? mode : NONOPT;
ASSERT(!script_.is_null());
if (script_->type()->value() == Script::TYPE_NATIVE) {
MarkAsNative();
}
if (!shared_info_.is_null()) {
ASSERT(language_mode() == CLASSIC_MODE);
SetLanguageMode(shared_info_->language_mode());
}
}
void SetMode(Mode mode) {
ASSERT(V8::UseCrankshaft());
mode_ = mode;
}
// Flags using template class BitField<type, start, length>. All are
// false by default.
//
// Compilation is either eager or lazy.
class IsLazy: public BitField<bool, 0, 1> {};
// Flags that can be set for eager compilation.
class IsEval: public BitField<bool, 1, 1> {};
class IsGlobal: public BitField<bool, 2, 1> {};
// Flags that can be set for lazy compilation.
class IsInLoop: public BitField<bool, 3, 1> {};
// Strict mode - used in eager compilation.
class LanguageModeField: public BitField<LanguageMode, 4, 2> {};
// Is this a function from our natives.
class IsNative: public BitField<bool, 6, 1> {};
// Is this code being compiled with support for deoptimization..
class SupportsDeoptimization: public BitField<bool, 7, 1> {};
// If compiling for debugging produce just full code matching the
// initial mode setting.
class IsCompilingForDebugging: public BitField<bool, 8, 1> {};
unsigned flags_;
// Fields filled in by the compilation pipeline.
// AST filled in by the parser.
FunctionLiteral* function_;
// The scope of the function literal as a convenience. Set to indicate
// that scopes have been analyzed.
Scope* scope_;
// The global scope provided as a convenience.
Scope* global_scope_;
// The compiled code.
Handle<Code> code_;
// Possible initial inputs to the compilation process.
Handle<JSFunction> closure_;
Handle<SharedFunctionInfo> shared_info_;
Handle<Script> script_;
// Fields possibly needed for eager compilation, NULL by default.
v8::Extension* extension_;
ScriptDataImpl* pre_parse_data_;
// The context of the caller is needed for eval code, and will be a null
// handle otherwise.
Handle<Context> calling_context_;
// Compilation mode flag and whether deoptimization is allowed.
Mode mode_;
int osr_ast_id_;
// The zone from which the compilation pipeline working on this
// CompilationInfo allocates.
Zone* zone_;
DeferredHandles* deferred_handles_;
template<typename T>
void SaveHandle(Handle<T> *object) {
if (!object->is_null()) {
Handle<T> handle(*(*object));
*object = handle;
}
}
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
};
// Exactly like a CompilationInfo, except also creates and enters a
// Zone on construction and deallocates it on exit.
class CompilationInfoWithZone: public CompilationInfo {
public:
explicit CompilationInfoWithZone(Handle<Script> script)
: CompilationInfo(script, &zone_),
zone_(script->GetIsolate()),
zone_scope_(&zone_, DELETE_ON_EXIT) {}
explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
: CompilationInfo(shared_info, &zone_),
zone_(shared_info->GetIsolate()),
zone_scope_(&zone_, DELETE_ON_EXIT) {}
explicit CompilationInfoWithZone(Handle<JSFunction> closure)
: CompilationInfo(closure, &zone_),
zone_(closure->GetIsolate()),
zone_scope_(&zone_, DELETE_ON_EXIT) {}
private:
Zone zone_;
ZoneScope zone_scope_;
};
// A wrapper around a CompilationInfo that detaches the Handles from
// the underlying DeferredHandleScope and stores them in info_ on
// destruction.
class CompilationHandleScope BASE_EMBEDDED {
public:
explicit CompilationHandleScope(CompilationInfo* info)
: deferred_(info->isolate()), info_(info) {}
~CompilationHandleScope() {
info_->set_deferred_handles(deferred_.Detach());
}
private:
DeferredHandleScope deferred_;
CompilationInfo* info_;
};
class HGraph;
class HGraphBuilder;
class LChunk;
// A helper class that calls the three compilation phases in
// Crankshaft and keeps track of its state. The three phases
// CreateGraph, OptimizeGraph and GenerateAndInstallCode can either
// fail, bail-out to the full code generator or succeed. Apart from
// their return value, the status of the phase last run can be checked
// using last_status().
class OptimizingCompiler: public ZoneObject {
public:
explicit OptimizingCompiler(CompilationInfo* info)
: info_(info),
oracle_(NULL),
graph_builder_(NULL),
graph_(NULL),
chunk_(NULL),
time_taken_to_create_graph_(0),
time_taken_to_optimize_(0),
time_taken_to_codegen_(0),
last_status_(FAILED) { }
enum Status {
FAILED, BAILED_OUT, SUCCEEDED
};
MUST_USE_RESULT Status CreateGraph();
MUST_USE_RESULT Status OptimizeGraph();
MUST_USE_RESULT Status GenerateAndInstallCode();
Status last_status() const { return last_status_; }
CompilationInfo* info() const { return info_; }
MUST_USE_RESULT Status AbortOptimization() {
info_->AbortOptimization();
info_->shared_info()->DisableOptimization();
return SetLastStatus(BAILED_OUT);
}
private:
CompilationInfo* info_;
TypeFeedbackOracle* oracle_;
HGraphBuilder* graph_builder_;
HGraph* graph_;
LChunk* chunk_;
int64_t time_taken_to_create_graph_;
int64_t time_taken_to_optimize_;
int64_t time_taken_to_codegen_;
Status last_status_;
MUST_USE_RESULT Status SetLastStatus(Status status) {
last_status_ = status;
return last_status_;
}
void RecordOptimizationStats();
struct Timer {
Timer(OptimizingCompiler* compiler, int64_t* location)
: compiler_(compiler),
start_(OS::Ticks()),
location_(location) { }
~Timer() {
*location_ += (OS::Ticks() - start_);
}
OptimizingCompiler* compiler_;
int64_t start_;
int64_t* location_;
};
};
// The V8 compiler
//
// General strategy: Source code is translated into an anonymous function w
/o
// parameters which then can be executed. If the source code contains other
// functions, they will be compiled and allocated as part of the compilatio
n
// of the source code.
// Please note this interface returns shared function infos. This means yo
u
// need to call Factory::NewFunctionFromSharedFunctionInfo before you have
a
// real function with a context.
class Compiler : public AllStatic {
public:
// Default maximum number of function optimization attempts before we
// give up.
static const int kDefaultMaxOptCount = 10;
static const int kMaxInliningLevels = 3;
// Call count before primitive functions trigger their own optimization.
static const int kCallsUntilPrimitiveOpt = 200;
// All routines return a SharedFunctionInfo.
// If an error occurs an exception is raised and the return handle
// contains NULL.
// Compile a String source within a context.
static Handle<SharedFunctionInfo> Compile(Handle<String> source,
Handle<Object> script_name,
int line_offset,
int column_offset,
v8::Extension* extension,
ScriptDataImpl* pre_data,
Handle<Object> script_data,
NativesFlag is_natives_code);
// Compile a String source within a context for Eval.
static Handle<SharedFunctionInfo> CompileEval(Handle<String> source,
Handle<Context> context,
bool is_global,
LanguageMode language_mode,
int scope_position);
// Compile from function info (used for lazy compilation). Returns true o
n
// success and false if the compilation resulted in a stack overflow.
static bool CompileLazy(CompilationInfo* info);
static void RecompileParallel(Handle<JSFunction> function);
// Compile a shared function info object (the function is possibly lazily
// compiled).
static Handle<SharedFunctionInfo> BuildFunctionInfo(FunctionLiteral* node
,
Handle<Script> script
);
// Set the function info for a newly compiled function.
static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
FunctionLiteral* lit,
bool is_toplevel,
Handle<Script> script);
static void InstallOptimizedCode(OptimizingCompiler* info);
#ifdef ENABLE_DEBUGGER_SUPPORT
static bool MakeCodeForLiveEdit(CompilationInfo* info);
#endif #endif
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
CompilationInfo* info,
Handle<SharedFunctionInfo> shared);
};
} } // namespace v8::internal
#endif // V8_COMPILER_H_
 End of changes. 2 change blocks. 
135 lines changed or deleted 472 lines changed or added


 dbclientinterface.h   dbclientinterface.h 
skipping to change at line 88 skipping to change at line 88
method, and it will take care of all the details for you. method, and it will take care of all the details for you.
*/ */
QueryOption_Exhaust = 1 << 6, QueryOption_Exhaust = 1 << 6,
/** When sharded, this means its ok to return partial results /** When sharded, this means its ok to return partial results
Usually we will fail a query if all required shards aren't up Usually we will fail a query if all required shards aren't up
If this is set, it'll be a partial result set If this is set, it'll be a partial result set
*/ */
QueryOption_PartialResults = 1 << 7 , QueryOption_PartialResults = 1 << 7 ,
QueryOption_AllSupported = QueryOption_CursorTailable | QueryOption QueryOption_AllSupported = QueryOption_CursorTailable |
_SlaveOk | QueryOption_OplogReplay | QueryOption_NoCursorTimeout | QueryOpt QueryOption_SlaveOk |
ion_AwaitData | QueryOption_Exhaust | QueryOption_PartialResults QueryOption_OplogReplay |
QueryOption_NoCursorTimeout |
QueryOption_AwaitData |
QueryOption_Exhaust |
QueryOption_PartialResults,
QueryOption_AllSupportedForSharding = QueryOption_CursorTailable |
QueryOption_SlaveOk |
QueryOption_OplogReplay |
QueryOption_NoCursorTimeout |
QueryOption_AwaitData |
QueryOption_PartialResults,
}; };
enum MONGO_CLIENT_API UpdateOptions { enum MONGO_CLIENT_API UpdateOptions {
/** Upsert - that is, insert the item if no matching item is found. */ /** Upsert - that is, insert the item if no matching item is found. */
UpdateOption_Upsert = 1 << 0, UpdateOption_Upsert = 1 << 0,
/** Update multiple documents (if multiple documents match query ex pression). /** Update multiple documents (if multiple documents match query ex pression).
(Default is update a single document and stop.) */ (Default is update a single document and stop.) */
UpdateOption_Multi = 1 << 1, UpdateOption_Multi = 1 << 1,
 End of changes. 1 change blocks. 
4 lines changed or deleted 14 lines changed or added


 distinct_scan.h   distinct_scan.h 
skipping to change at line 82 skipping to change at line 82
* Used by the distinct command. Executes a mutated index scan over th e provided bounds. * Used by the distinct command. Executes a mutated index scan over th e provided bounds.
* However, rather than looking at every key in the bounds, it skips to the next value of the * However, rather than looking at every key in the bounds, it skips to the next value of the
* _params.fieldNo-th indexed field. This is because distinct only car es about distinct values * _params.fieldNo-th indexed field. This is because distinct only car es about distinct values
* for that field, so there is no point in examining all keys with the same value for that * for that field, so there is no point in examining all keys with the same value for that
* field. * field.
* *
* Only created through the getDistinctRunner path. See db/query/get_r unner.cpp * Only created through the getDistinctRunner path. See db/query/get_r unner.cpp
*/ */
class DistinctScan : public PlanStage { class DistinctScan : public PlanStage {
public: public:
/**
* Keeps track of what this distinct scan is currently doing so tha
t it
* can do the right thing on the next call to work().
*/
enum ScanState {
// Need to initialize the underlying index traversal machinery.
INITIALIZING,
// Skipping keys in order to check whether we have reached the
end.
CHECKING_END,
// Retrieving the next key, and applying the filter if necessar
y.
GETTING_NEXT,
// The index scan is finished.
HIT_END
};
DistinctScan(const DistinctParams& params, WorkingSet* workingSet); DistinctScan(const DistinctParams& params, WorkingSet* workingSet);
virtual ~DistinctScan() { } virtual ~DistinctScan() { }
virtual StageState work(WorkingSetID* out); virtual StageState work(WorkingSetID* out);
virtual bool isEOF(); virtual bool isEOF();
virtual void prepareToYield(); virtual void prepareToYield();
virtual void recoverFromYield(); virtual void recoverFromYield();
virtual void invalidate(const DiskLoc& dl, InvalidationType type); virtual void invalidate(const DiskLoc& dl, InvalidationType type);
virtual PlanStageStats* getStats(); virtual PlanStageStats* getStats();
skipping to change at line 112 skipping to change at line 130
// The WorkingSet we annotate with results. Not owned by us. // The WorkingSet we annotate with results. Not owned by us.
WorkingSet* _workingSet; WorkingSet* _workingSet;
// Index access. // Index access.
const IndexDescriptor* _descriptor; // owned by Collection -> Index Catalog const IndexDescriptor* _descriptor; // owned by Collection -> Index Catalog
const IndexAccessMethod* _iam; // owned by Collection -> IndexCatal og const IndexAccessMethod* _iam; // owned by Collection -> IndexCatal og
// The cursor we use to navigate the tree. // The cursor we use to navigate the tree.
boost::scoped_ptr<BtreeIndexCursor> _btreeCursor; boost::scoped_ptr<BtreeIndexCursor> _btreeCursor;
// Have we hit the end of the index scan? // Keeps track of what work we need to do next.
bool _hitEnd; ScanState _scanState;
// For yielding. // For yielding.
BSONObj _savedKey; BSONObj _savedKey;
DiskLoc _savedLoc; DiskLoc _savedLoc;
DistinctParams _params; DistinctParams _params;
// _checker gives us our start key and ensures we stay in bounds. // _checker gives us our start key and ensures we stay in bounds.
boost::scoped_ptr<IndexBoundsChecker> _checker; boost::scoped_ptr<IndexBoundsChecker> _checker;
int _keyEltsToUse; int _keyEltsToUse;
 End of changes. 2 change blocks. 
2 lines changed or deleted 23 lines changed or added


 endian.h   endian.h 
skipping to change at line 181 skipping to change at line 181
return uint128(Load64VariableLength(p, len)); return uint128(Load64VariableLength(p, len));
} else { } else {
return uint128( return uint128(
Load64VariableLength(static_cast<const char *>(p) + 8, len - 8), Load64VariableLength(static_cast<const char *>(p) + 8, len - 8),
Load64(p)); Load64(p));
} }
} }
}; };
// This one is safe to take as it's an extension // This one is safe to take as it's an extension
#define htonll(x) ghtonll(x) // #define htonll(x) ghtonll(x) // XXX Conflicts on OS X Yosemite
// ntoh* and hton* are the same thing for any size and bytesex, // ntoh* and hton* are the same thing for any size and bytesex,
// since the function is an involution, i.e., its own inverse. // since the function is an involution, i.e., its own inverse.
#define gntohl(x) ghtonl(x) #define gntohl(x) ghtonl(x)
#define gntohs(x) ghtons(x) #define gntohs(x) ghtons(x)
#define gntohll(x) ghtonll(x) #define gntohll(x) ghtonll(x)
#define ntohll(x) htonll(x) // #define ntohll(x) htonll(x) // XXX Conflicts on OS X Yosemite
#endif // UTIL_ENDIAN_ENDIAN_H_ #endif // UTIL_ENDIAN_ENDIAN_H_
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 index_catalog.h   index_catalog.h 
skipping to change at line 180 skipping to change at line 180
/** /**
* Given some criteria, will search through all in-progress index b uilds * Given some criteria, will search through all in-progress index b uilds
* and will kill ones that match. (namespace, index name, and/or in dex key spec) * and will kill ones that match. (namespace, index name, and/or in dex key spec)
* Returns the list of index specs that were killed, for use in res tarting them later. * Returns the list of index specs that were killed, for use in res tarting them later.
*/ */
std::vector<BSONObj> killMatchingIndexBuilds(const IndexKillCriteri a& criteria); std::vector<BSONObj> killMatchingIndexBuilds(const IndexKillCriteri a& criteria);
// ---- modify single index // ---- modify single index
/* Updates the expireAfterSeconds field of the given index to the v /**
alue in newExpireSecs. * Updates the expireAfterSeconds field of the given index to the v
alue in newExpireSecs.
* The specified index must already contain an expireAfterSeconds f ield, and the value in * The specified index must already contain an expireAfterSeconds f ield, and the value in
* that field and newExpireSecs must both be numeric. * that field and newExpireSecs must both be numeric. Returns an u
nowned pointer to the
* descriptor for the new index definition.
*
* It is invalid to dereference 'oldDesc' after calling this method
. This method broadcasts
* an invalidateAll() on the cursor cache to notify other users of
the IndexCatalog that
* this descriptor is now invalid.
*/ */
void updateTTLSetting( const IndexDescriptor* idx, long long newExp const IndexDescriptor* updateTTLSetting( const IndexDescriptor* old
ireSeconds ); Desc,
long long newExpireSeconds
);
bool isMultikey( const IndexDescriptor* idex ); bool isMultikey( const IndexDescriptor* idex );
// --- these probably become private? // --- these probably become private?
/** /**
* disk creation order * disk creation order
* 1) system.indexes entry * 1) system.indexes entry
* 2) collection's NamespaceDetails * 2) collection's NamespaceDetails
* a) info + head * a) info + head
 End of changes. 3 change blocks. 
5 lines changed or deleted 16 lines changed or added


 index_filter_commands.h   index_filter_commands.h 
skipping to change at line 78 skipping to change at line 78
/** /**
* It's fine to return NONE here because plan cache commands * It's fine to return NONE here because plan cache commands
* create explicit read context to access collection info cache. * create explicit read context to access collection info cache.
* Refer to dbcommands.cpp on how locktype() is handled. * Refer to dbcommands.cpp on how locktype() is handled.
*/ */
virtual LockType locktype() const; virtual LockType locktype() const;
virtual bool slaveOk() const; virtual bool slaveOk() const;
virtual bool slaveOverrideOk() const;
virtual void help(std::stringstream& ss) const; virtual void help(std::stringstream& ss) const;
/** /**
* One action type defined for index filter commands: * One action type defined for index filter commands:
* - planCacheIndexFilter * - planCacheIndexFilter
*/ */
virtual Status checkAuthForCommand(ClientBasic* client, const std:: string& dbname, virtual Status checkAuthForCommand(ClientBasic* client, const std:: string& dbname,
const BSONObj& cmdObj); const BSONObj& cmdObj);
/** /**
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 keep_mutations.h   keep_mutations.h 
skipping to change at line 76 skipping to change at line 76
// Not owned here. Should be the full query expression tree. // Not owned here. Should be the full query expression tree.
const MatchExpression* _filter; const MatchExpression* _filter;
// We read from our child... // We read from our child...
bool _doneReadingChild; bool _doneReadingChild;
// ...until it's out of results, at which point we put any flagged results back in the query // ...until it's out of results, at which point we put any flagged results back in the query
// stream. // stream.
bool _doneReturningFlagged; bool _doneReturningFlagged;
// Stats // Stats.
CommonStats _commonStats; CommonStats _commonStats;
unordered_set<WorkingSetID>::const_iterator _flaggedIterator; // Our copy of the working set's flagged results.
std::vector<WorkingSetID> _flagged;
// Iterator pointing into _flagged.
std::vector<WorkingSetID>::const_iterator _flaggedIterator;
}; };
} // namespace mongo } // namespace mongo
 End of changes. 2 change blocks. 
2 lines changed or deleted 6 lines changed or added


 owned_pointer_map.h   owned_pointer_map.h 
skipping to change at line 40 skipping to change at line 40
class OwnedPointerMap { class OwnedPointerMap {
MONGO_DISALLOW_COPYING(OwnedPointerMap); MONGO_DISALLOW_COPYING(OwnedPointerMap);
public: public:
typedef typename std::map<K, T*, Compare> MapType; typedef typename std::map<K, T*, Compare> MapType;
OwnedPointerMap(); OwnedPointerMap();
~OwnedPointerMap(); ~OwnedPointerMap();
/** Access the map. */ /** Access the map. */
const MapType& map() { return _map; } const MapType& map() const { return _map; }
MapType& mutableMap() { return _map; } MapType& mutableMap() { return _map; }
void clear(); void clear();
private: private:
MapType _map; MapType _map;
}; };
template<class K, class T, class Compare> template<class K, class T, class Compare>
OwnedPointerMap<K, T, Compare>::OwnedPointerMap() { OwnedPointerMap<K, T, Compare>::OwnedPointerMap() {
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 owned_pointer_vector.h   owned_pointer_vector.h 
skipping to change at line 18 skipping to change at line 18
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli ed. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli ed.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once #pragma once
#include <cstring>
#include <vector> #include <vector>
#include "mongo/base/disallow_copying.h" #include "mongo/base/disallow_copying.h"
namespace mongo { namespace mongo {
/** /**
* An std::vector wrapper that deletes pointers within a vector on dest ruction. The objects * An std::vector wrapper that deletes pointers within a vector on dest ruction. The objects
* referenced by the vector's pointers are 'owned' by an object of this class. * referenced by the vector's pointers are 'owned' by an object of this class.
* NOTE that an OwnedPointerVector<T> wraps an std::vector<T*>. * NOTE that an OwnedPointerVector<T> wraps an std::vector<T*>.
*/ */
template<class T> template<class T>
class OwnedPointerVector { class OwnedPointerVector {
MONGO_DISALLOW_COPYING(OwnedPointerVector); MONGO_DISALLOW_COPYING(OwnedPointerVector);
public: public:
OwnedPointerVector(); OwnedPointerVector() {}
~OwnedPointerVector(); ~OwnedPointerVector() { clear(); }
/**
* Takes ownership of all pointers contained in 'other'.
* NOTE: argument is intentionally taken by value.
*/
OwnedPointerVector(std::vector<T*> other) { _vector.swap(other); }
/**
* Takes ownership of all pointers contained in 'other'.
* NOTE: argument is intentionally taken by value.
*/
OwnedPointerVector& operator=(std::vector<T*> other) {
clear();
_vector.swap(other);
return *this;
}
typedef typename std::vector<T*>::const_iterator const_iterator; typedef typename std::vector<T*>::const_iterator const_iterator;
typedef typename std::vector<T*>::const_reverse_iterator const_reve rse_iterator; typedef typename std::vector<T*>::const_reverse_iterator const_reve rse_iterator;
/** Access the vector. */ /** Access the vector. */
const std::vector<T*>& vector() const { return _vector; } const std::vector<T*>& vector() const { return _vector; }
std::vector<T*>& mutableVector() { return _vector; } std::vector<T*>& mutableVector() { return _vector; }
std::size_t size() const { return _vector.size(); } std::size_t size() const { return _vector.size(); }
bool empty() const { return _vector.empty(); } bool empty() const { return _vector.empty(); }
const_iterator begin() const { return _vector.begin(); } const_iterator begin() const { return _vector.begin(); }
const_reverse_iterator rbegin() const { return _vector.rbegin(); } const_reverse_iterator rbegin() const { return _vector.rbegin(); }
const_iterator end() const { return _vector.end(); } const_iterator end() const { return _vector.end(); }
const_reverse_iterator rend() const { return _vector.rend(); } const_reverse_iterator rend() const { return _vector.rend(); }
T* operator[] (size_t i) const { return _vector[i]; }
T* back() const { return _vector.back(); }
T* front() const { return _vector.front(); }
void push_back(T* ptr) { _vector.push_back(ptr); }
/**
* Deletes all pointers in the vector, then sets its size to 0.
*/
void clear(); void clear();
/**
* Deletes the pointer at 'it', then erases it from the vector.
*/
void erase(const_iterator it) {
delete *it;
// vector::erase(const_iterator) is new in c++11, so converting
to non-const iterator.
_vector.erase(_vector.begin() + (it - begin()));
}
//
// extensions
//
/**
* Releases the entire vector to allow you to transfer ownership.
*
* Leaves the OwnedPointerVector empty.
* Named after the similar method and pattern in std::auto_ptr.
*/
std::vector<T*> release() {
std::vector<T*> out;
out.swap(_vector);
return out;
}
/**
* Releases ownership of a single element.
*
* Sets that element to NULL and does not change size().
*/
T* releaseAt(size_t i) {
T* out = _vector[i];
_vector[i] = NULL;
return out;
}
T* popAndReleaseBack() {
T* out = _vector.back();
_vector.pop_back();
return out;
}
void popAndDeleteBack() {
delete popAndReleaseBack();
}
private: private:
std::vector<T*> _vector; std::vector<T*> _vector;
}; };
template<class T> template<class T>
OwnedPointerVector<T>::OwnedPointerVector() { inline void OwnedPointerVector<T>::clear() {
}
template<class T>
OwnedPointerVector<T>::~OwnedPointerVector() {
clear();
}
template<class T>
void OwnedPointerVector<T>::clear() {
for( typename std::vector<T*>::iterator i = _vector.begin(); i != _ vector.end(); ++i ) { for( typename std::vector<T*>::iterator i = _vector.begin(); i != _ vector.end(); ++i ) {
delete *i; delete *i;
} }
_vector.clear(); _vector.clear();
} }
} // namespace mongo } // namespace mongo
 End of changes. 5 change blocks. 
12 lines changed or deleted 76 lines changed or added


 path.h   path.h 
skipping to change at line 129 skipping to change at line 129
BSONElementIterator( const ElementPath* path, const BSONObj& contex t ); BSONElementIterator( const ElementPath* path, const BSONObj& contex t );
virtual ~BSONElementIterator(); virtual ~BSONElementIterator();
void reset( const ElementPath* path, const BSONObj& context ); void reset( const ElementPath* path, const BSONObj& context );
bool more(); bool more();
Context next(); Context next();
private: private:
/**
* Helper for more(). Recurs on _subCursor (which traverses the re
mainder of a path through
* subdocuments of an array).
*/
bool subCursorHasMore();
const ElementPath* _path; const ElementPath* _path;
BSONObj _context; BSONObj _context;
enum State { BEGIN, IN_ARRAY, DONE } _state; enum State { BEGIN, IN_ARRAY, DONE } _state;
Context _next; Context _next;
struct ArrayIterationState { struct ArrayIterationState {
void reset( const FieldRef& ref, int start ); void reset( const FieldRef& ref, int start );
void startIterator( BSONElement theArray ); void startIterator( BSONElement theArray );
 End of changes. 1 change blocks. 
0 lines changed or deleted 7 lines changed or added


 plan_cache_commands.h   plan_cache_commands.h 
skipping to change at line 73 skipping to change at line 73
/** /**
* It's fine to return NONE here because plan cache commands * It's fine to return NONE here because plan cache commands
* create explicit read context to access collection info cache. * create explicit read context to access collection info cache.
* Refer to dbcommands.cpp on how locktype() is handled. * Refer to dbcommands.cpp on how locktype() is handled.
*/ */
virtual LockType locktype() const; virtual LockType locktype() const;
virtual bool slaveOk() const; virtual bool slaveOk() const;
virtual bool slaveOverrideOk() const;
virtual void help(std::stringstream& ss) const; virtual void help(std::stringstream& ss) const;
/** /**
* Two action types defined for plan cache commands: * Two action types defined for plan cache commands:
* - planCacheRead * - planCacheRead
* - planCacheWrite * - planCacheWrite
*/ */
virtual Status checkAuthForCommand(ClientBasic* client, const std:: string& dbname, virtual Status checkAuthForCommand(ClientBasic* client, const std:: string& dbname,
const BSONObj& cmdObj); const BSONObj& cmdObj);
/** /**
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 str.h   str.h 
skipping to change at line 20 skipping to change at line 20
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli ed. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli ed.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once #pragma once
/* Things in the mongoutils namespace /**
(1) are not database specific, rather, true utilities * String utilities.
(2) are cross platform *
(3) may require boost headers, but not libs * TODO: De-inline.
(4) are clean and easy to use in any c++ project without pulling in lots * TODO: Retire the mongoutils namespace, and move str under the mongo name
of other stuff space.
*/
Note: within this module, we use int for all offsets -- there are no uns
igned offsets
and no size_t's. If you need 3 gigabyte long strings, don't use this mo
dule.
*/
#include <string> #include <string>
#include <sstream> #include <sstream>
// this violates the README rules for mongoutils:
#include "mongo/bson/util/builder.h" #include "mongo/bson/util/builder.h"
namespace mongoutils { namespace mongoutils {
namespace str { namespace str {
/** the idea here is to make one liners easy. e.g.: /** the idea here is to make one liners easy. e.g.:
return str::stream() << 1 << ' ' << 2; return str::stream() << 1 << ' ' << 2;
skipping to change at line 217 skipping to change at line 213
inline void stripTrailing(std::string& s, const char *chars) { inline void stripTrailing(std::string& s, const char *chars) {
std::string::iterator i = s.end(); std::string::iterator i = s.end();
while( s.begin() != i ) { while( s.begin() != i ) {
i--; i--;
if( contains(chars, *i) ) { if( contains(chars, *i) ) {
s.erase(i); s.erase(i);
} }
} }
} }
} } // namespace str
} // namespace mongoutils
} namespace mongo {
using namespace mongoutils;
} // namespace mongo
 End of changes. 4 change blocks. 
14 lines changed or deleted 10 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/