File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,9 @@ namespace chunk_assignment
9494 template <typename Chunk_t>
9595 void mergeChunks (std::vector<Chunk_t> &);
9696
97+ auto mergeChunksFromSameSourceID (std::vector<WrittenChunkInfo> const &)
98+ -> std::map<unsigned int, std::vector<ChunkInfo>>;
99+
97100 struct PartialAssignment
98101 {
99102 ChunkTable notAssigned;
Original file line number Diff line number Diff line change @@ -174,6 +174,21 @@ namespace chunk_assignment
174174 } while (stillChanging);
175175 }
176176
177+ auto mergeChunksFromSameSourceID (std::vector<WrittenChunkInfo> const &table)
178+ -> std::map<unsigned int, std::vector<ChunkInfo>>
179+ {
180+ std::map<unsigned int , std::vector<ChunkInfo>> sortedBySourceID;
181+ for (auto const &chunk : table)
182+ {
183+ sortedBySourceID[chunk.sourceID ].emplace_back (chunk);
184+ }
185+ for (auto &pair : sortedBySourceID)
186+ {
187+ mergeChunks (pair.second );
188+ }
189+ return sortedBySourceID;
190+ }
191+
177192 template void mergeChunks<ChunkInfo>(std::vector<ChunkInfo> &);
178193 template void
179194 mergeChunks<WrittenChunkInfo>(std::vector<WrittenChunkInfo> &);
Original file line number Diff line number Diff line change @@ -239,7 +239,10 @@ void init_Chunk(py::module &m)
239239 .def (" available" , &host_info::methodAvailable);
240240
241241 py::bind_vector<ChunkTable>(m, " ChunkTable" )
242- .def (" merge_chunks" , &chunk_assignment::mergeChunks<WrittenChunkInfo>);
242+ .def (" merge_chunks" , &chunk_assignment::mergeChunks<WrittenChunkInfo>)
243+ .def (
244+ " merge_chunks_from_same_sourceID" ,
245+ &chunk_assignment::mergeChunksFromSameSourceID);
243246
244247 using namespace chunk_assignment ;
245248
You can’t perform that action at this time.
0 commit comments