54bool splitMock(
const std::vector<PPath> & vecInputFile,
const PPath & outputFile,
55 size_t offsetPart,
size_t sizePart,
size_t nbPart)
57 if(sizePart == 0lu && nbPart == 0lu){
58 std::cerr <<
"Error sizePart cannot be 0 id nbPart == 0, aborting split" << std::endl;
61 PPath outputExtension(outputFile.getExtension()), baseOutputFile(outputFile.eraseExtension());
63 for(std::vector<PPath>::const_iterator itFile(vecInputFile.begin()); itFile != vecInputFile.end() && b; ++itFile){
65 if(data_load(*itFile, vecTmpFile)){
66 size_t nbTimeIn(vecTmpFile.size());
68 if(offsetPart <= nbTimeIn){
69 sizePart = (nbTimeIn - offsetPart)/nbPart;
71 std::cerr <<
"splitMock : cannot split nbTimeIn = " << nbTimeIn <<
", into nbPart = "<<nbPart<<
" of size sizePart = "<<sizePart<<
" and offset offsetPart = " << offsetPart << std::endl;
74 for(
size_t i(0lu); i < nbPart; ++i){
76 splitVecTime(vecMessage, vecTmpFile, offsetPart + i*sizePart, sizePart);
86 }
else if(nbPart == 0lu){
87 if((sizePart + offsetPart) <= nbTimeIn){
88 nbPart = (nbTimeIn-offsetPart)/sizePart;
89 for(
size_t i(0lu); i < nbPart; ++i){
91 splitVecTime(vecMessage, vecTmpFile, offsetPart + i*sizePart, sizePart);
100 if((sizePart*nbPart + offsetPart) <= nbTimeIn){
101 for(
size_t i(0lu); i < nbPart; ++i){
103 splitVecTime(vecMessage, vecTmpFile, offsetPart + i*sizePart, sizePart);
107 std::cerr <<
"splitMock : cannot split nbTimeIn = " << nbTimeIn <<
", into nbPart = "<<nbPart<<
" of size sizePart = "<<sizePart<<
" and offset offsetPart = " << offsetPart << std::endl;
118int main(
int argc,
char** argv){
120 parser.parseArgument(argc, argv);
122 const OptionMode & defaultMode = parser.getDefaultMode();
123 std::vector<PPath> vecInputFile;
124 PPath outputFile(
"");
125 defaultMode.getValue(vecInputFile,
"input");
126 defaultMode.getValue(outputFile,
"output");
128 size_t offsetPart(0lu), sizePart(1lu), nbPart(0lu);
129 defaultMode.getValue(offsetPart,
"offset");
130 defaultMode.getValue(sizePart,
"sizepart");
131 defaultMode.getValue(nbPart,
"nbpart");
133 return splitMock(vecInputFile, outputFile, offsetPart, sizePart, nbPart) - 1;
bool splitMock(const std::vector< PPath > &vecInputFile, const PPath &outputFile, size_t offsetPart, size_t sizePart, size_t nbPart)
Merge mock files.
int main(int argc, char **argv)
PPath phoenix_mockMakeOutputFile(const PPath &baseFileName, size_t indexFile, const PPath &extentionFile)
Make the output file name.
OptionParser createOptionParser()
Create the OptionParser of this program.
void splitVecTime(VecTime &vecOutput, const VecTime vecInput, size_t offsetPart, size_t sizePart)
Split a vector of messages into an other.