MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / NewAppendableFile

Method NewAppendableFile

tensorflow/core/platform/s3/s3_file_system.cc:343–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343Status S3FileSystem::NewAppendableFile(const string& fname,
344 std::unique_ptr<WritableFile>* result) {
345 std::unique_ptr<RandomAccessFile> reader;
346 TF_RETURN_IF_ERROR(NewRandomAccessFile(fname, &reader));
347 std::unique_ptr<char[]> buffer(new char[kS3ReadAppendableFileBufferSize]);
348 Status status;
349 uint64 offset = 0;
350 StringPiece read_chunk;
351
352 string bucket, object;
353 TF_RETURN_IF_ERROR(ParseS3Path(fname, false, &bucket, &object));
354 result->reset(new S3WritableFile(bucket, object, this->GetS3Client()));
355
356 while (true) {
357 status = reader->Read(offset, kS3ReadAppendableFileBufferSize, &read_chunk,
358 buffer.get());
359 if (status.ok()) {
360 (*result)->Append(read_chunk);
361 offset += kS3ReadAppendableFileBufferSize;
362 } else if (status.code() == error::OUT_OF_RANGE) {
363 (*result)->Append(read_chunk);
364 break;
365 } else {
366 (*result).reset();
367 return status;
368 }
369 }
370
371 return Status::OK();
372}
373
374Status S3FileSystem::NewReadOnlyMemoryRegionFromFile(
375 const string& fname, std::unique_ptr<ReadOnlyMemoryRegion>* result) {

Callers 1

TEST_FFunction · 0.45

Calls 8

GetS3ClientMethod · 0.95
ParseS3PathFunction · 0.85
resetMethod · 0.45
ReadMethod · 0.45
getMethod · 0.45
okMethod · 0.45
AppendMethod · 0.45
codeMethod · 0.45

Tested by 1

TEST_FFunction · 0.36