Skip to content

Commit 4ff6e16

Browse files
shahor02lkrcal
authored andcommitted
optionally store min-max raw TF range beyond random percentage
add SubTimeFrameFileSink options --data-sink-stf-min-id <int (def=-1)> --data-sink-stf-max-id <int (def=-1)> to force storage of TFs with ID matching this limits (on top of eventual random storage)
1 parent 0b7b83b commit 4ff6e16

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/common/SubTimeFrameFileSink.cxx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ bpo::options_description SubTimeFrameFileSink::getProgramOptions()
8888
OptionKeyStfSinkStfPercent,
8989
bpo::value<double>()->default_value(100.0),
9090
"Specifies probabilistic acceptance percentage for saving of each (Sub)TimeFrames, between 0.0 and 100. Default: 100.0")(
91+
OptionKeyStfSinkMinTFIDForceToStore,
92+
bpo::value<std::uint64_t>()->default_value(std::int64_t(0)),
93+
"Specifies min TF ID forced to store regardless of requested mean fraction")(
94+
OptionKeyStfSinkMaxTFIDForceToStore,
95+
bpo::value<std::uint64_t>()->default_value(std::int64_t(0)),
96+
"Specifies max TF ID forced to store regardless of requested mean fraction")(
9197
OptionKeyStfSinkFileSize,
9298
bpo::value<std::uint64_t>()->default_value(std::uint64_t(4) << 10), /* 4GiB */
9399
"Specifies target size for (Sub)TimeFrame files in MiB.")(
@@ -127,6 +133,8 @@ bool SubTimeFrameFileSink::loadVerifyConfig(const fair::mq::ProgOptions& pFMQPro
127133
mStfsPerFile = pFMQProgOpt.GetValue<std::uint64_t>(OptionKeyStfSinkStfsPerFile);
128134
mFileSize = std::max(std::uint64_t(1), pFMQProgOpt.GetValue<std::uint64_t>(OptionKeyStfSinkFileSize));
129135
mPercentageToSave = std::clamp(pFMQProgOpt.GetValue<double>(OptionKeyStfSinkStfPercent), 0.0, 100.0);
136+
mMinTFIDForceToStore = pFMQProgOpt.GetValue<std::uint64_t>(OptionKeyStfSinkMinTFIDForceToStore);
137+
mMaxTFIDForceToStore = pFMQProgOpt.GetValue<std::uint64_t>(OptionKeyStfSinkMaxTFIDForceToStore);
130138
mFileSize <<= 20; /* in MiB */
131139
mSidecar = pFMQProgOpt.GetValue<bool>(OptionKeyStfSinkSidecar);
132140
mEosMetaDir = pFMQProgOpt.GetValue<std::string>(OptionKeyStfSinkEpn2EosMetaDir);
@@ -197,6 +205,8 @@ bool SubTimeFrameFileSink::loadVerifyConfig(const fair::mq::ProgOptions& pFMQPro
197205
IDDLOG("(Sub)TimeFrame Sink :: root dir = {}", mRootDir);
198206
IDDLOG("(Sub)TimeFrame Sink :: file pattern = {}", mFileNamePattern);
199207
IDDLOG("(Sub)TimeFrame Sink :: stfs per file = {}", (mStfsPerFile > 0 ? std::to_string(mStfsPerFile) : "unlimited" ));
208+
IDDLOG("(Sub)TimeFrame Sink :: force min TFID = {}", (mMinTFIDForceToStore > 0 && mMinTFIDForceToStore <= mMaxTFIDForceToStore ? std::to_string(mMinTFIDForceToStore) : "none"));
209+
IDDLOG("(Sub)TimeFrame Sink :: force max TFID = {}", (mMinTFIDForceToStore > 0 && mMinTFIDForceToStore <= mMaxTFIDForceToStore ? std::to_string(mMaxTFIDForceToStore) : "none"));
200210
IDDLOG("(Sub)TimeFrame Sink :: stfs percentage = {:.4}", (mPercentageToSave));
201211
IDDLOG("(Sub)TimeFrame Sink :: max file size = {}", mFileSize);
202212
IDDLOG("(Sub)TimeFrame Sink :: sidecar files = {}", (mSidecar ? "yes" : "no"));
@@ -323,7 +333,7 @@ void SubTimeFrameFileSink::DataHandlerThread(const unsigned pIdx)
323333
}
324334

325335
// apply rejection rules
326-
bool lStfAccepted = (lUniformDist(lGen) <= mPercentageToSave) ? true : false;
336+
bool lStfAccepted = (lUniformDist(lGen) <= mPercentageToSave) || (lStf->id() <= mMaxTFIDForceToStore && lStf->id() >= mMinTFIDForceToStore) ? true : false;
327337

328338
if (mEnabled && mReady && lStfAccepted) {
329339
do {

src/common/SubTimeFrameFileSink.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class SubTimeFrameFileSink
4949
static constexpr const char* OptionKeyStfSinkFileName = "data-sink-file-name";
5050
static constexpr const char* OptionKeyStfSinkStfsPerFile = "data-sink-max-stfs-per-file";
5151
static constexpr const char* OptionKeyStfSinkStfPercent = "data-sink-stf-percentage";
52+
static constexpr const char* OptionKeyStfSinkMinTFIDForceToStore = "data-sink-stf-min-id";
53+
static constexpr const char* OptionKeyStfSinkMaxTFIDForceToStore = "data-sink-stf-max-id";
5254
static constexpr const char* OptionKeyStfSinkFileSize = "data-sink-max-file-size";
5355
static constexpr const char* OptionKeyStfSinkSidecar = "data-sink-sidecar";
5456
static constexpr const char* OptionKeyStfSinkEpn2EosMetaDir = "data-sink-epn2eos-meta-dir";
@@ -101,6 +103,8 @@ class SubTimeFrameFileSink
101103
std::string mCurrentDir;
102104
std::string mFileNamePattern;
103105
std::uint64_t mStfsPerFile;
106+
std::uint64_t mMinTFIDForceToStore = 0;
107+
std::uint64_t mMaxTFIDForceToStore = 0;
104108
double mPercentageToSave = 100.0;
105109
std::uint64_t mFileSize;
106110
bool mSidecar = false;

0 commit comments

Comments
 (0)