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

Method read

gpcontrib/gpcloud/src/s3bucket_reader.cpp:96–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96uint64_t S3BucketReader::read(char* buf, uint64_t count) {
97 S3_CHECK_OR_DIE(this->upstreamReader != NULL, S3RuntimeError, "upstreamReader is NULL");
98 uint64_t readCount = 0;
99 while (true) {
100 if (this->needNewReader) {
101 if (this->keyIndex >= this->keyList.contents.size()) {
102 S3DEBUG("Read finished for segment: %d", s3ext_segid);
103 return 0;
104 }
105 BucketContent& key = this->getNextKey();
106
107 this->upstreamReader->open(constructReaderParams(key));
108 this->needNewReader = false;
109
110 // ignore header line if it is not the first file
111 if (hasHeader && !this->isFirstFile) {
112 readCount = readWithoutHeaderLine(buf, count);
113 if (readCount != 0) {
114 return readCount;
115 }
116 }
117 }
118
119 readCount = this->upstreamReader->read(buf, count);
120 if (readCount != 0) {
121 return readCount;
122 }
123
124 // Finished one file, continue to next
125 this->upstreamReader->close();
126 this->needNewReader = true;
127 this->isFirstFile = false;
128 }
129}
130
131void S3BucketReader::close() {
132 if (this->upstreamReader != NULL) {

Callers 1

readWithoutHeaderLineMethod · 0.45

Calls 3

sizeMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected