@@ -145,25 +145,28 @@ requestOtherRanksToStoreVertex(int currank, int world_size, VertexId vertexId, E
145
145
}
146
146
147
147
// 该方法负责char *指针的delete
148
+ // TODO: 不负责read的delete
148
149
int processRecvRead (const char *filename, size_t pos) {
149
150
ifstream infile (filename);
150
- string read ;
151
+ string * read = new string ;
151
152
infile.seekg (pos);
152
- getline (infile, read );
153
+ getline (infile, * read );
153
154
infile.close ();
154
- delete filename;
155
- if (requestWriteRead (read ) == 0 ) return 0 ;
155
+ delete[] filename;
156
+ if (requestWriteRead (* read ) == 0 ) return 0 ;
156
157
return 1 ;
157
158
}
158
159
159
160
// 该方法负责char *指针的delete
160
161
int processRecvEdge (EdgeList *edgeList, char *value, ReadId readId, KMERPOS_t kmerpos) {
161
- string strValue (string (value, 0 , getK ()));
162
-
163
- VertexId sourceVertex = getId (strValue.substr (0 , strValue.size ()-1 ));
164
- VertexId sinkVertex = getId (strValue.substr (1 , strValue.size ()-1 ));
162
+ string *strValue = new string (value, 0 , getK ()-1 );
163
+ VertexId sourceVertex = getId (*strValue);
164
+ delete strValue;
165
+ strValue = new string (value, 1 , getK ()-1 );
166
+ VertexId sinkVertex = getId (*strValue);
167
+ delete strValue;
165
168
int flag = addNewEdge (edgeList, value, sourceVertex, sinkVertex, readId, kmerpos);
166
- delete value;
169
+ delete[] value;
167
170
return flag;
168
171
}
169
172
@@ -175,7 +178,7 @@ int processRecvVertex(VertexList *vertexList, SetOfID *tangleList, VertexId vert
175
178
flag = addVertex (vertexList, vertexId, edgeId, 0 , vertexMode);
176
179
177
180
if (MULTI_OUT_DEGREE == (flag & MULTI_OUT_DEGREE)) {
178
- tangleList->safe_insert (vertexId);
181
+ // tangleList->safe_insert(vertexId);
179
182
}
180
183
return flag;
181
184
}
@@ -275,11 +278,12 @@ void *receiverRunner(void *args) {
275
278
char *kmer = nullptr ;
276
279
ReadId readId;
277
280
MPI_Unpack (pack, packSize, &position, &strLen, 1 , MPI_INT, MPI_COMM_WORLD);
278
- kmer = new char [strLen];
281
+ kmer = new char [strLen+ 1 ];
279
282
if (strLen != getK ()) {
280
283
cout << " Trasmission error: " << strLen << endl;
281
284
}
282
285
MPI_Unpack (pack, packSize, &position, kmer, strLen, MPI_CHAR, MPI_COMM_WORLD);
286
+ kmer[strLen] = ' \0 ' ;
283
287
MPI_Unpack (pack, packSize, &position, &readId, 1 , my_MPI_SIZE_T, MPI_COMM_WORLD);
284
288
KMERPOS_t kmerpos;
285
289
MPI_Unpack (pack, packSize, &position, &kmerpos, 1 , MPI_UNSIGNED, MPI_COMM_WORLD);
@@ -394,14 +398,14 @@ item::item() {
394
398
}
395
399
396
400
// 不能与线程并行的共存
397
- void sendSuperContigToRankHead (int headrank, int currank, string superContig) {
401
+ void sendSuperContigToRankHead (int headrank, int currank, string & superContig) {
398
402
int msgsize = superContig.size ();
399
403
MPI_Send (&msgsize, 1 , MPI_INT, headrank, TAG (currank, headrank), MPI_COMM_WORLD);
400
404
MPI_Send (superContig.c_str (), superContig.size (), MPI_CHAR, headrank, TAG (currank, headrank), MPI_COMM_WORLD);
401
405
}
402
406
403
407
// 不能与线程并行的共存
404
- string reduceSuperContigFromOthers (int currank, int world_size, string superContig) {
408
+ string reduceSuperContigFromOthers (int currank, int world_size, string & superContig) {
405
409
stringstream sc;
406
410
sc << superContig;
407
411
// cout << superContig;
0 commit comments