| 94 | } |
| 95 | |
| 96 | uint64_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 | |
| 131 | void S3BucketReader::close() { |
| 132 | if (this->upstreamReader != NULL) { |
no test coverage detected