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

Method write

gpcontrib/gpcloud/src/s3key_writer.cpp:19–44  ·  view source on GitHub ↗

write() first fills up the data buffer before flush it out

Source from the content-addressed store, hash-verified

17
18// write() first fills up the data buffer before flush it out
19uint64_t S3KeyWriter::write(const char* buf, uint64_t count) {
20 // Defensive code
21 S3_CHECK_OR_DIE(buf != NULL, S3RuntimeError, "Buffer is NULL");
22 this->checkQueryCancelSignal();
23
24 uint64_t offset = 0;
25 while (offset < count) {
26 if (sharedError) {
27 std::rethrow_exception(sharedException);
28 }
29
30 uint64_t bufferRemaining = this->params.getChunkSize() - this->buffer.size();
31 uint64_t dataRemaining = count - offset;
32 uint64_t dataToBuffer = bufferRemaining < dataRemaining ? bufferRemaining : dataRemaining;
33
34 this->buffer.insert(this->buffer.end(), buf + offset, buf + offset + dataToBuffer);
35
36 if (this->buffer.size() == this->params.getChunkSize()) {
37 this->flushBuffer();
38 }
39
40 offset += dataToBuffer;
41 }
42
43 return count;
44}
45
46// This should be reentrant, has no side effects when called multiple times.
47void S3KeyWriter::close() {

Callers

nothing calls this directly

Calls 5

flushBufferMethod · 0.95
getChunkSizeMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected