Skip to content

Commit

Permalink
Add --populate-only option
Browse files Browse the repository at this point in the history
This allows to use pillowfight purely in a document loading mode, for
use perhaps by another tool such as n1ql or fts.

Change-Id: Ie3cf3d53d7f3c916dbcc6d8e855b454cfb0e61c2
Reviewed-on: http://review.couchbase.org/64121
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information
mnunberg authored and Mark Nunberg committed Jun 16, 2016
1 parent f47e3eb commit 908395e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tools/cbc-pillowfight.cc
Expand Up @@ -118,7 +118,8 @@ class Configuration
o_writeJson("json"),
o_templatePairs("template"),
o_subdoc("subdoc"),
o_sdPathCount("pathcount")
o_sdPathCount("pathcount"),
o_populateOnly("populate-only")
{
o_multiSize.setDefault(100).abbrev('B').description("Number of operations to batch");
o_numItems.setDefault(1000).abbrev('I').description("Number of items to operate on");
Expand All @@ -140,6 +141,7 @@ class Configuration
o_templatePairs.argdesc("FIELD,MIN,MAX[,SEQUENTIAL]").hide();
o_subdoc.description("Use subdoc instead of fulldoc operations");
o_sdPathCount.description("Number of subdoc paths per command").setDefault(1);
o_populateOnly.description("Exit after documents have been populated");
}

void processOptions() {
Expand All @@ -155,6 +157,20 @@ class Configuration
maxCycles = o_numCycles.result();
}

if (o_populateOnly.passed()) {
// Determine how many iterations are required.
if (o_numCycles.passed()) {
throw std::runtime_error("--num-cycles incompatible with --populate-only");
}
size_t est = (o_numItems / o_numThreads) / o_multiSize;
while (est * o_numThreads * o_multiSize < o_numItems) {
est++;
}
maxCycles = est;
o_sequential.setDefault(true);
fprintf(stderr, "Populating using %lu cycles\n", maxCycles);
}

if (depr.iterations.passed()) {
fprintf(stderr, "The --num-iterations/-I option is deprecated. Use --batch-size\n");
opsPerCycle = depr.iterations.result();
Expand Down Expand Up @@ -239,6 +255,7 @@ class Configuration
parser.addOption(o_templatePairs);
parser.addOption(o_subdoc);
parser.addOption(o_sdPathCount);
parser.addOption(o_populateOnly);
params.addToParser(parser);
depr.addOptions(parser);
}
Expand Down Expand Up @@ -300,6 +317,9 @@ class Configuration
BoolOption o_subdoc;
UIntOption o_sdPathCount;

// Compound option
BoolOption o_populateOnly;

DeprecatedOptions depr;
} config;

Expand Down

0 comments on commit 908395e

Please sign in to comment.