49 std::set<std::string>
const& processesToKeep,
50 std::vector<unsigned int>
const& nEntries,
51 std::vector<unsigned int>& finalIndexToStoredIndex)
const {
54 bool isModified =
false;
55 unsigned int finalSize = 0;
56 for (
auto const&
process : storedProcesses) {
57 if (processesToKeep.find(
process) == processesToKeep.end()) {
67 std::vector<std::string> finalProcesses;
68 finalProcesses.reserve(finalSize);
69 finalIndexToStoredIndex.reserve(finalSize);
70 for (
unsigned int iStored = 0; iStored < storedProcesses.size(); ++iStored) {
71 if (processesToKeep.find(storedProcesses[iStored]) != processesToKeep.end()) {
72 finalProcesses.emplace_back(storedProcesses[iStored]);
73 finalIndexToStoredIndex.emplace_back(iStored);
84 std::set<std::string>
const& processesToKeep,
85 std::vector<unsigned int>
const& nEntries,
86 std::vector<unsigned int>& finalIndexToStoredIndex,
87 std::vector<std::string>
const& firstFileFinalProcesses)
const {
90 std::vector<std::string> finalProcesses;
92 finalProcesses.reserve(storedProcesses.size());
93 finalIndexToStoredIndex.reserve(storedProcesses.size());
97 for (
unsigned int iFirst = 0; iFirst < firstFileFinalProcesses.size(); ++iFirst) {
99 for (
unsigned int iStored = 0; iStored < storedProcesses.size(); ++iStored) {
100 std::string const& storedProcess = storedProcesses[iStored];
101 if (firstFileFinalProcesses[iFirst] == storedProcess) {
103 if (processesToKeep.find(storedProcess) != processesToKeep.end()) {
104 finalProcesses.emplace_back(storedProcess);
105 finalIndexToStoredIndex.emplace_back(iStored);
112 bool isModified =
true;
113 if (storedProcesses == finalProcesses) {
133 std::vector<unsigned int>
const& nEntries) {
146 }
else if (!storedProcesses.empty()) {
149 }
else if (storedProcesses.empty()) {
172 std::vector<std::string>& finalProcesses,
173 std::vector<unsigned int>
const& nEntries,
174 std::vector<unsigned int>
const& finalIndexToStoredIndex)
const {
178 assert(!storedProcesses.empty());
179 std::vector<unsigned int> newCacheIndices;
180 if (!finalProcesses.empty()) {
185 std::vector<unsigned int> oldOffsets;
186 oldOffsets.reserve(storedProcesses.size());
188 for (
auto const& entries : nEntries) {
189 oldOffsets.emplace_back(offset);
193 unsigned int nFinalProcesses = finalProcesses.size();
194 std::vector<unsigned int> newOffsets;
195 newOffsets.reserve(nFinalProcesses);
197 for (
unsigned int iNew = 0; iNew < nFinalProcesses; ++iNew) {
198 newOffsets.emplace_back(offset);
199 offset += nEntries[finalIndexToStoredIndex[iNew]];
202 unsigned int nOuterLoop = storedCacheIndices.size() / storedProcesses.size();
203 assert(nOuterLoop * storedProcesses.size() == storedCacheIndices.size());
204 newCacheIndices.reserve(nOuterLoop * nFinalProcesses);
205 unsigned int storedOuterOffset = 0;
207 for (
unsigned int k = 0;
k < nOuterLoop; ++
k) {
208 for (
unsigned int j = 0;
j < nFinalProcesses; ++
j) {
209 unsigned int storedIndex = finalIndexToStoredIndex[
j];
210 unsigned int oldCacheIndex = storedCacheIndices[storedOuterOffset + storedIndex];
213 newCacheIndex = oldCacheIndex - oldOffsets[storedIndex] + newOffsets[
j];
215 newCacheIndices.emplace_back(newCacheIndex);
217 storedOuterOffset += storedProcesses.size();
225 std::vector<unsigned int>
const& storedCacheIndices,
226 std::vector<unsigned int>
const& nEntries) {
235 for (
unsigned int k = 0;
k < storedProcesses.size(); ++
k) {
237 firstFileToStored[
j] =
k;
238 newNEntries[
j] = nEntries[
k];
246 unsigned int nCacheIndexVectors = storedCacheIndices.size() / storedProcesses.size();
247 assert(storedProcesses.size() * nCacheIndexVectors == storedCacheIndices.size());
249 unsigned int storedIndex = 0;
250 for (
unsigned int k = 0;
k < nCacheIndexVectors; ++
k) {
253 unsigned int iStored = firstFileToStored[
j];
257 unsigned int oldCacheIndex = storedCacheIndices[storedIndex];
272 unsigned int entriesThisFile = 0;
273 for (
auto const& entries : nEntries) {
274 entriesThisFile += entries;
void initializeFromPrimaryInput(StoredProcessBlockHelper const &storedProcessBlockHelper)
unsigned int outerOffset() const final
unsigned int processBlockIndex(std::string const &processName, EventToProcessBlockIndexes const &) const final
unsigned int outerOffset_
bool firstFileDropProcessesAndReorderStored(StoredProcessBlockHelper &storedProcessBlockHelper, std::set< std::string > const &processesToKeep, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > &finalIndexToStoredIndex) const
void clearAfterOutputFilesClose()
void setProcessesWithProcessBlockProducts(std::vector< std::string > val)
std::vector< unsigned int > const & cacheIndexVectorsPerFile() const final
unsigned int nProcessesInFirstFile_
static constexpr unsigned int invalidProcessIndex()
static constexpr unsigned int invalidCacheIndex()
ProcessBlockHelperBase const * topProcessBlockHelper() const final
void fillEntriesFromPrimaryInput(std::vector< unsigned int > nEntries)
std::vector< unsigned int > cacheEntriesPerFile_
std::vector< std::vector< unsigned int > > const & processBlockCacheIndices() const final
std::vector< std::string > const & topProcessesWithProcessBlockProducts() const final
std::vector< std::vector< unsigned int > > nEntries_
unsigned int cacheIndexOffset_
unsigned int nProcessesInFirstFile() const final
std::vector< std::vector< unsigned int > > const & nEntries() const final
bool initializedFromInput_
std::vector< unsigned int > cacheIndexVectorsPerFile_
std::vector< unsigned int > const & cacheEntriesPerFile() const final
std::vector< std::string > const & processesWithProcessBlockProducts() const
std::vector< std::string > const & processesWithProcessBlockProducts() const
void setProcessBlockCacheIndices(std::vector< unsigned int > val)
bool dropProcessesAndReorderStored(StoredProcessBlockHelper &storedProcessBlockHelper, std::set< std::string > const &processesToKeep, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > &finalIndexToStoredIndex, std::vector< std::string > const &firstFileFinalProcesses) const
std::vector< unsigned int > const & processBlockCacheIndices() const
void setProcessesWithProcessBlockProducts(std::vector< std::string > const &val)
void fillFromPrimaryInput(StoredProcessBlockHelper const &storedProcessBlockHelper, std::vector< unsigned int > const &nEntries)
unsigned int index() const
tuple size
Write out results.
std::vector< std::vector< unsigned int > > processBlockCacheIndices_
void dropProcessesAndReorderStoredImpl(StoredProcessBlockHelper &storedProcessBlockHelper, std::vector< std::string > &finalProcesses, std::vector< unsigned int > const &nEntries, std::vector< unsigned int > const &finalIndexToStoredIndex) const
void fillFromPrimaryInputWhenNotEmpty(std::vector< std::string > const &storedProcesses, std::vector< unsigned int > const &storedCacheIndices, std::vector< unsigned int > const &nEntries)