summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/split_vector_command.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-01-25 17:50:03 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-01-30 09:34:20 -0500
commit2922aea4adf8e8fe9bab3a5d6e986e7aecba7228 (patch)
tree6504c17080aafcd6e0280a0f8fb2d8c19514240a /src/mongo/db/s/split_vector_command.cpp
parent03028591aec8f6e8f08c8c2be2f829772822d7dd (diff)
downloadmongo-2922aea4adf8e8fe9bab3a5d6e986e7aecba7228.tar.gz
SERVER-27809 Move regular chunk split to the balancer
Diffstat (limited to 'src/mongo/db/s/split_vector_command.cpp')
-rw-r--r--src/mongo/db/s/split_vector_command.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/mongo/db/s/split_vector_command.cpp b/src/mongo/db/s/split_vector_command.cpp
index ec70e321202..f02a7d68fa3 100644
--- a/src/mongo/db/s/split_vector_command.cpp
+++ b/src/mongo/db/s/split_vector_command.cpp
@@ -62,10 +62,10 @@ using std::string;
using std::stringstream;
using std::vector;
-namespace dps = ::mongo::dotted_path_support;
-
namespace {
+const int kMaxObjectPerChunk{250000};
+
BSONObj prettyKey(const BSONObj& keyPattern, const BSONObj& key) {
return key.replaceFieldNames(keyPattern).clientReadable();
}
@@ -73,13 +73,16 @@ BSONObj prettyKey(const BSONObj& keyPattern, const BSONObj& key) {
class SplitVector : public Command {
public:
SplitVector() : Command("splitVector", false) {}
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
+
+ bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
- virtual bool slaveOk() const {
+
+ bool slaveOk() const override {
return false;
}
- virtual void help(stringstream& help) const {
+
+ void help(stringstream& help) const override {
help << "Internal command.\n"
"examples:\n"
" { splitVector : \"blog.post\" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, "
@@ -93,9 +96,10 @@ public:
" 'force' will produce one split point even if data is small; defaults to false\n"
"NOTE: This command may take a while to run";
}
- virtual Status checkAuthForCommand(Client* client,
- const std::string& dbname,
- const BSONObj& cmdObj) {
+
+ Status checkAuthForCommand(Client* client,
+ const std::string& dbname,
+ const BSONObj& cmdObj) override {
if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource(
ResourcePattern::forExactNamespace(NamespaceString(parseNs(dbname, cmdObj))),
ActionType::splitVector)) {
@@ -103,15 +107,17 @@ public:
}
return Status::OK();
}
- virtual std::string parseNs(const string& dbname, const BSONObj& cmdObj) const {
+
+ std::string parseNs(const string& dbname, const BSONObj& cmdObj) const override {
return parseNsFullyQualified(dbname, cmdObj);
}
+
bool run(OperationContext* txn,
const string& dbname,
BSONObj& jsobj,
- int,
+ int options,
string& errmsg,
- BSONObjBuilder& result) {
+ BSONObjBuilder& result) override {
//
// 1.a We'll parse the parameters in two steps. First, make sure the we can use the split
// index to get a good approximation of the size of the chunk -- without needing to
@@ -141,7 +147,7 @@ public:
maxSplitPoints = maxSplitPointsElem.numberLong();
}
- long long maxChunkObjects = Chunk::MaxObjectPerChunk;
+ long long maxChunkObjects = kMaxObjectPerChunk;
BSONElement MaxChunkObjectsElem = jsobj["maxChunkObjects"];
if (MaxChunkObjectsElem.isNumber()) {
maxChunkObjects = MaxChunkObjectsElem.numberLong();
@@ -274,7 +280,7 @@ public:
// to be removed at the end. If a key appears more times than entries allowed on a
// chunk, we issue a warning and split on the following key.
auto tooFrequentKeys = SimpleBSONObjComparator::kInstance.makeBSONObjSet();
- splitKeys.push_back(dps::extractElementsBasedOnTemplate(
+ splitKeys.push_back(dotted_path_support::extractElementsBasedOnTemplate(
prettyKey(idx->keyPattern(), currKey.getOwned()), keyPattern));
exec->setYieldPolicy(PlanExecutor::YIELD_AUTO, collection);
@@ -283,7 +289,7 @@ public:
currCount++;
if (currCount > keyCount && !forceMedianSplit) {
- currKey = dps::extractElementsBasedOnTemplate(
+ currKey = dotted_path_support::extractElementsBasedOnTemplate(
prettyKey(idx->keyPattern(), currKey.getOwned()), keyPattern);
// Do not use this split key if it is the same used in the previous split
// point.