Petr Onderka has submitted this change and it was merged. Change subject: Command like parameter for specifying frequency of progress reporting for idumps create ......................................................................
Command like parameter for specifying frequency of progress reporting for idumps create Change-Id: Ide79612764b81b65471c14581aea69cbcaf46b55 --- M README.md M main.cpp 2 files changed, 27 insertions(+), 1 deletion(-) Approvals: Petr Onderka: Verified; Looks good to me, approved diff --git a/README.md b/README.md index 88cb0c4..798da78 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,9 @@ The remaining parameters specify what dumps to creates, just as in `update`. +There is also an optional parameter `--report` which has to be followed by a number *n* specifying that progress should be reported every *n* revisions. +If *n* is 0, progress reporting is turned off. If this parameter is specified, it has to come right before the “name of the wiki” parameter. + Example: idumps c enwiki 20130823 enwiki-20130823-pages-meta-history.xml sc sc.id diff --git a/main.cpp b/main.cpp index 62cb24e..26fba7c 100644 --- a/main.cpp +++ b/main.cpp @@ -12,6 +12,7 @@ #include "XmlWriter.h" #include "Dump.h" #include "FetchText.h" +#include "StringHelpers.h" #include "format.h" void printUsage() @@ -174,6 +175,28 @@ if (parameters.size() < 3 + 2) throw ParametersException("Not enough parameters."); + std::uint32_t reportPeriod = 10000; + + if (parameters.front() == "--report") + { + parameters.pop(); + + bool success; + long parsed = tryParseLong(parameters.front(), success); + + if (!success || parsed < 0 || parsed > 0xFFFFFFFF) + { + throw UserException( + str(fmt::Format("The value {0} is not valid report period.") << parameters.front())); + } + + reportPeriod = parsed; + parameters.pop(); + } + + if (parameters.size() < 3 + 2) + throw ParametersException("Not enough parameters."); + std::string name, timestamp; readNameAndTimestamp(parameters, name, timestamp); @@ -184,7 +207,7 @@ std::unique_ptr<CompositeWriter> writer(new CompositeWriter(writers)); - ProgressWriterWrapper progressWriter(std::move(writer), 10000); + ProgressWriterWrapper progressWriter(std::move(writer), reportPeriod); if (inputFileName == "-") { -- To view, visit https://gerrit.wikimedia.org/r/84759 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ide79612764b81b65471c14581aea69cbcaf46b55 Gerrit-PatchSet: 1 Gerrit-Project: operations/dumps/incremental Gerrit-Branch: gsoc Gerrit-Owner: Petr Onderka <gsv...@gmail.com> Gerrit-Reviewer: Petr Onderka <gsv...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits