File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,9 @@ namespace chunk_assignment
94
94
template <typename Chunk_t>
95
95
void mergeChunks (std::vector<Chunk_t> &);
96
96
97
+ auto mergeChunksFromSameSourceID (std::vector<WrittenChunkInfo> const &)
98
+ -> std::map<unsigned int, std::vector<ChunkInfo>>;
99
+
97
100
struct PartialAssignment
98
101
{
99
102
ChunkTable notAssigned;
Original file line number Diff line number Diff line change @@ -174,6 +174,21 @@ namespace chunk_assignment
174
174
} while (stillChanging);
175
175
}
176
176
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
+
177
192
template void mergeChunks<ChunkInfo>(std::vector<ChunkInfo> &);
178
193
template void
179
194
mergeChunks<WrittenChunkInfo>(std::vector<WrittenChunkInfo> &);
Original file line number Diff line number Diff line change @@ -237,7 +237,10 @@ void init_Chunk(py::module &m)
237
237
.def (" available" , &host_info::methodAvailable);
238
238
239
239
py::bind_vector<ChunkTable>(m, " ChunkTable" )
240
- .def (" merge_chunks" , &chunk_assignment::mergeChunks<WrittenChunkInfo>);
240
+ .def (" merge_chunks" , &chunk_assignment::mergeChunks<WrittenChunkInfo>)
241
+ .def (
242
+ " merge_chunks_from_same_sourceID" ,
243
+ &chunk_assignment::mergeChunksFromSameSourceID);
241
244
242
245
using namespace chunk_assignment ;
243
246
You can’t perform that action at this time.
0 commit comments