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

Method fill

gpcontrib/gpcloud/src/s3key_reader.cpp:101–145  ·  view source on GitHub ↗

returning uint64_t(-1) means error

Source from the content-addressed store, hash-verified

99
100// returning uint64_t(-1) means error
101uint64_t ChunkBuffer::fill() {
102 UniqueLock statusLock(&this->statusMutex);
103
104 while (this->status != ReadyToFill) {
105 pthread_cond_wait(&this->statusCondVar, &this->statusMutex);
106 }
107
108 if (S3QueryIsAbortInProgress() || this->isError()) {
109 this->setSharedError(true);
110 this->status = ReadyToRead;
111 pthread_cond_signal(&this->statusCondVar);
112 return -1;
113 }
114
115 uint64_t offset = this->curFileOffset;
116 uint64_t leftLen = this->chunkDataSize;
117
118 uint64_t readLen = 0;
119
120 if (leftLen != 0) {
121 try {
122 readLen = this->s3Interface->fetchData(offset, this->chunkData, leftLen, this->s3Url);
123 if (readLen != leftLen) {
124 S3DEBUG("Failed to fetch expected data from S3");
125 this->setSharedError(true, S3PartialResponseError(leftLen, readLen));
126 } else {
127 S3DEBUG("Got %" PRIu64 " bytes from S3", readLen);
128 }
129 } catch (S3Exception& e) {
130 S3DEBUG("Failed to fetch expected data from S3");
131 this->setSharedError(true);
132 }
133 }
134
135 if (offset + leftLen >= offsetMgr.getKeySize()) {
136 readLen = 0; // Nothing to read, EOF
137 S3DEBUG("Reached the end of file");
138 this->eof = true;
139 }
140
141 this->status = ReadyToRead;
142 pthread_cond_signal(&this->statusCondVar);
143
144 return (this->isError()) ? -1 : readLen;
145}
146
147static void* DownloadThreadFunc(void* data) {
148 MaskThreadSignals();

Callers 1

DownloadThreadFuncFunction · 0.80

Calls 6

isErrorMethod · 0.95
setSharedErrorMethod · 0.95
fetchDataMethod · 0.80
S3QueryIsAbortInProgressFunction · 0.70
getKeySizeMethod · 0.45

Tested by

no test coverage detected