Skip to content

Commit 1a84ee5

Browse files
authored
Merger: add ability to configure compression level (AliceO2Group#13656)
1 parent b2e9ae6 commit 1a84ee5

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

Framework/AODMerger/src/aodMerger.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int main(int argc, char* argv[])
3939
bool skipParentFilesList = false;
4040
int verbosity = 2;
4141
int exitCode = 0; // 0: success, >0: failure
42+
int compression = 505;
4243

4344
int option_index = 0;
4445
static struct option long_options[] = {
@@ -47,8 +48,9 @@ int main(int argc, char* argv[])
4748
{"max-size", required_argument, nullptr, 2},
4849
{"skip-non-existing-files", no_argument, nullptr, 3},
4950
{"skip-parent-files-list", no_argument, nullptr, 4},
50-
{"verbosity", required_argument, nullptr, 5},
51-
{"help", no_argument, nullptr, 6},
51+
{"compression", no_argument, nullptr, 5},
52+
{"verbosity", required_argument, nullptr, 'v'},
53+
{"help", no_argument, nullptr, 'h'},
5254
{nullptr, 0, nullptr, 0}};
5355

5456
while (true) {
@@ -66,14 +68,17 @@ int main(int argc, char* argv[])
6668
} else if (c == 4) {
6769
skipParentFilesList = true;
6870
} else if (c == 5) {
71+
compression = atoi(optarg);
72+
} else if (c == 'v') {
6973
verbosity = atoi(optarg);
70-
} else if (c == 6) {
74+
} else if (c == 'h') {
7175
printf("AO2D merging tool. Options: \n");
7276
printf(" --input <inputfile.txt> Contains path to files to be merged. Default: %s\n", inputCollection.c_str());
7377
printf(" --output <outputfile.root> Target output ROOT file. Default: %s\n", outputFileName.c_str());
7478
printf(" --max-size <size in Bytes> Target directory size. Default: %ld. Set to 0 if file is not self-contained.\n", maxDirSize);
7579
printf(" --skip-non-existing-files Flag to allow skipping of non-existing files in the input list.\n");
7680
printf(" --skip-parent-files-list Flag to allow skipping the merging of the parent files list.\n");
81+
printf(" --compression <root compression id> Compression algorithm / level to use (default: %d)\n", compression);
7782
printf(" --verbosity <flag> Verbosity of output (default: %d).\n", verbosity);
7883
return -1;
7984
} else {
@@ -95,7 +100,7 @@ int main(int argc, char* argv[])
95100
std::map<std::string, int> offsets;
96101
std::map<std::string, int> unassignedIndexOffset;
97102

98-
auto outputFile = TFile::Open(outputFileName.c_str(), "RECREATE", "", 505);
103+
auto outputFile = TFile::Open(outputFileName.c_str(), "RECREATE", "", compression);
99104
TDirectory* outputDir = nullptr;
100105
long currentDirSize = 0;
101106

Framework/AODMerger/src/aodStrainer.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int main(int argc, char* argv[])
3939
double downsampling = 1.0;
4040
int verbosity = 2;
4141
int exitCode = 0; // 0: success, >0: failure
42+
int compression = 505;
4243

4344
std::random_device rd; // Seed generator
4445
std::mt19937 gen(rd()); // Mersenne Twister generator
@@ -51,7 +52,8 @@ int main(int argc, char* argv[])
5152
{"verbosity", required_argument, nullptr, 2},
5253
{"tables", required_argument, nullptr, 3},
5354
{"downsampling", required_argument, nullptr, 4},
54-
{"help", no_argument, nullptr, 5},
55+
{"compression", required_argument, nullptr, 5},
56+
{"help", no_argument, nullptr, 'h'},
5557
{nullptr, 0, nullptr, 0}};
5658

5759
while (true) {
@@ -69,12 +71,15 @@ int main(int argc, char* argv[])
6971
} else if (c == 4) {
7072
downsampling = atof(optarg);
7173
} else if (c == 5) {
74+
compression = atof(optarg);
75+
} else if (c == 'h') {
7276
printf("AO2D strainer tool. Options: \n");
7377
printf(" --input <%s> Contains path to files to be merged. Default: %s\n", inputAO2D.c_str(), inputAO2D.c_str());
7478
printf(" --output <%s> Target output ROOT file. Default: %s\n", outputFileName.c_str(), outputFileName.c_str());
7579
printf(" --verbosity <flag> Verbosity of output (default: %d).\n", verbosity);
7680
printf(" --tables <list of tables> Comma separated list of tables (default: %s).\n", tables.c_str());
7781
printf(" --downsampling <downsample> Fraction of DF to be kept (default: %f)\n", downsampling);
82+
printf(" --compression <root compression id> Compression algorithm / level to use (default: %d)\n", compression);
7883
return -1;
7984
} else {
8085
return -2;
@@ -95,7 +100,7 @@ int main(int argc, char* argv[])
95100
listOfTables.push_back(token);
96101
}
97102

98-
auto outputFile = TFile::Open(outputFileName.c_str(), "RECREATE", "", 505);
103+
auto outputFile = TFile::Open(outputFileName.c_str(), "RECREATE", "", compression);
99104
TDirectory* outputDir = nullptr;
100105
TString line(inputAO2D.c_str());
101106
if (line.BeginsWith("alien://") && !gGrid && !TGrid::Connect("alien:")) {

Framework/AODMerger/src/aodThinner.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ int main(int argc, char* argv[])
4242
std::string outputFileName("AO2D_thinned.root");
4343
int exitCode = 0; // 0: success, !=0: failure
4444
bool bOverwrite = false;
45+
int compression = 505;
4546

4647
int option_index = 1;
4748

@@ -50,6 +51,7 @@ int main(int argc, char* argv[])
5051
{"input", required_argument, nullptr, 'i'},
5152
{"output", required_argument, nullptr, 'o'},
5253
{"overwrite", no_argument, nullptr, 'O'},
54+
{"compression", no_argument, nullptr, 'c'},
5355
{"help", no_argument, nullptr, 'h'},
5456
{nullptr, 0, nullptr, 0}};
5557

@@ -69,12 +71,16 @@ int main(int argc, char* argv[])
6971
bOverwrite = true;
7072
printf("Overwriting existing output file if existing\n");
7173
break;
74+
case 'c':
75+
compression = atoi(optarg);
76+
break;
7277
case 'h':
7378
case '?':
7479
default:
7580
printf("AO2D thinning tool. Options: \n");
7681
printf(" --input/-i <inputfile.root> Contains input file path to the file to be thinned. Default: %s\n", inputFileName.c_str());
7782
printf(" --output/-o <outputfile.root> Target output ROOT file. Default: %s\n", outputFileName.c_str());
83+
printf(" --compression/-c <compression id> ROOT compression algorithm / level. Default: %d\n", compression);
7884
printf("\n");
7985
printf(" Optional Arguments:\n");
8086
printf(" --overwrite/-O Overwrite existing output file\n");
@@ -89,7 +95,7 @@ int main(int argc, char* argv[])
8995
TStopwatch clock;
9096
clock.Start(kTRUE);
9197

92-
auto outputFile = TFile::Open(outputFileName.c_str(), (bOverwrite) ? "RECREATE" : "CREATE", "", 505);
98+
auto outputFile = TFile::Open(outputFileName.c_str(), (bOverwrite) ? "RECREATE" : "CREATE", "", compression);
9399
if (outputFile == nullptr) {
94100
printf("Error: File %s exists or cannot be created!\n", outputFileName.c_str());
95101
return 1;

0 commit comments

Comments
 (0)