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

Method GetChildren

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

Source from the content-addressed store, hash-verified

394}
395
396Status S3FileSystem::GetChildren(const string& dir,
397 std::vector<string>* result) {
398 string bucket, prefix;
399 TF_RETURN_IF_ERROR(ParseS3Path(dir, false, &bucket, &prefix));
400
401 if (prefix.back() != '/') {
402 prefix.push_back('/');
403 }
404
405 Aws::S3::Model::ListObjectsRequest listObjectsRequest;
406 listObjectsRequest.WithBucket(bucket.c_str())
407 .WithPrefix(prefix.c_str())
408 .WithMaxKeys(kS3GetChildrenMaxKeys)
409 .WithDelimiter("/");
410 listObjectsRequest.SetResponseStreamFactory(
411 []() { return Aws::New<Aws::StringStream>(kS3FileSystemAllocationTag); });
412
413 Aws::S3::Model::ListObjectsResult listObjectsResult;
414 do {
415 auto listObjectsOutcome =
416 this->GetS3Client()->ListObjects(listObjectsRequest);
417 if (!listObjectsOutcome.IsSuccess()) {
418 return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(),
419 ": ", listObjectsOutcome.GetError().GetMessage());
420 }
421
422 listObjectsResult = listObjectsOutcome.GetResult();
423 for (const auto& object : listObjectsResult.GetCommonPrefixes()) {
424 Aws::String s = object.GetPrefix();
425 s.erase(s.length() - 1);
426 Aws::String entry = s.substr(strlen(prefix.c_str()));
427 if (entry.length() > 0) {
428 result->push_back(entry.c_str());
429 }
430 }
431 for (const auto& object : listObjectsResult.GetContents()) {
432 Aws::String s = object.GetKey();
433 Aws::String entry = s.substr(strlen(prefix.c_str()));
434 if (entry.length() > 0) {
435 result->push_back(entry.c_str());
436 }
437 }
438 listObjectsRequest.SetMarker(listObjectsResult.GetNextMarker());
439 } while (listObjectsResult.GetIsTruncated());
440
441 return Status::OK();
442}
443
444Status S3FileSystem::Stat(const string& fname, FileStatistics* stats) {
445 string bucket, object;

Callers 1

TEST_FFunction · 0.45

Calls 11

GetS3ClientMethod · 0.95
ParseS3PathFunction · 0.85
c_strMethod · 0.80
GetErrorMethod · 0.80
UnknownClass · 0.50
backMethod · 0.45
push_backMethod · 0.45
GetResultMethod · 0.45
eraseMethod · 0.45
lengthMethod · 0.45
GetKeyMethod · 0.45

Tested by 1

TEST_FFunction · 0.36