| 146 | } |
| 147 | |
| 148 | void S3KeyWriter::completeKeyWriting() { |
| 149 | // make sure the buffer is clear |
| 150 | this->flushBuffer(); |
| 151 | |
| 152 | // wait for all threads to complete |
| 153 | for (size_t i = 0; i < threadList.size(); i++) { |
| 154 | pthread_join(threadList[i], NULL); |
| 155 | } |
| 156 | this->threadList.clear(); |
| 157 | |
| 158 | this->checkQueryCancelSignal(); |
| 159 | |
| 160 | vector<string> etags; |
| 161 | // it is equivalent to foreach(e in etagList) push_back(e.second); |
| 162 | // transform(etagList.begin(), etagList.end(), etags.begin(), |
| 163 | // [](std::pair<const uint64_t, string>& p) { return p.second; }); |
| 164 | etags.reserve(etagList.size()); |
| 165 | |
| 166 | for (map<uint64_t, string>::iterator i = etagList.begin(); i != etagList.end(); i++) { |
| 167 | etags.push_back(i->second); |
| 168 | } |
| 169 | |
| 170 | if (!this->etagList.empty() && !this->uploadId.empty()) { |
| 171 | this->s3Interface->completeMultiPart(this->params.getS3Url(), this->uploadId, etags); |
| 172 | } |
| 173 | |
| 174 | S3DEBUG("Segment %d has finished uploading \"%s\"", s3ext_segid, |
| 175 | this->params.getS3Url().getFullUrlForCurl().c_str()); |
| 176 | |
| 177 | this->buffer.clear(); |
| 178 | this->etagList.clear(); |
| 179 | this->uploadId.clear(); |
| 180 | } |
no test coverage detected