MCPcopy Create free account
hub / github.com/apache/cloudberry / flushBuffer

Method flushBuffer

gpcontrib/gpcloud/src/s3key_writer.cpp:123–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void S3KeyWriter::flushBuffer() {
124 if (!this->buffer.empty()) {
125 UniqueLock queueLock(&this->mutex);
126 while (this->activeThreads >= this->params.getNumOfChunks()) {
127 pthread_cond_wait(&this->cv, &this->mutex);
128 }
129
130 // Most time query is canceled during uploadPartOfData(). This is the first chance to cancel
131 // and clean up upload.
132 this->checkQueryCancelSignal();
133
134 this->activeThreads++;
135
136 pthread_t writerThread;
137 ThreadParams* params = new ThreadParams();
138 params->keyWriter = this;
139 params->data.swap(this->buffer);
140 params->currentNumber = ++this->partNumber;
141 pthread_create(&writerThread, NULL, UploadThreadFunc, params);
142 threadList.emplace_back(writerThread);
143
144 this->buffer.reserve(this->params.getChunkSize());
145 }
146}
147
148void S3KeyWriter::completeKeyWriting() {
149 // make sure the buffer is clear

Callers 2

writeMethod · 0.95
completeKeyWritingMethod · 0.95

Calls 3

getNumOfChunksMethod · 0.80
getChunkSizeMethod · 0.45

Tested by

no test coverage detected