MCPcopy Create free account
hub / github.com/alibaba/graph-learn / BeginNextFile

Method BeginNextFile

graphlearn/src/core/io/slice_reader.h:47–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 }
46
47 Status BeginNextFile(SourceType** ret) {
48 ++files_cursor_;
49
50 if (files_cursor_ >= source_.size()) {
51 return error::OutOfRange("All files completed");
52 }
53
54 current_ = &source_[files_cursor_];
55
56 FileSystem* fs = NULL;
57 Status s = env_->GetFileSystem(current_->path, &fs);
58 LOG_RETURN_IF_NOT_OK(s)
59
60 if (! SingleThreadMode(current_->path)) {
61 uint64_t file_size = 0;
62 s = fs->GetRecordCount(current_->path, &file_size);
63 LOG_RETURN_IF_NOT_OK(s)
64
65 int32_t slice_id = 0;
66 int32_t slice_count = 1;
67 if (IsDistributeShared(current_->path)) {
68 slice_id = env_->GetServerId() * thread_num_ + thread_id_;
69 slice_count = env_->GetServerCount() * thread_num_;
70 } else if (current_->local_shared) {
71 slice_id = thread_id_;
72 slice_count = thread_num_;
73 }
74
75 DataSlicer slicer(slice_id, slice_count, file_size);
76 offset_ = slicer.LocalStart();
77 end_ = offset_ + slicer.LocalSize();
78 LOG(INFO) << "file_size:" << file_size
79 << "thread id:" << thread_id_
80 << ", thread num:" << thread_num_
81 << ", offset:" << offset_
82 << ", end:" << end_;
83 s = fs->NewStructuredAccessFile(current_->path, offset_, end_, &reader_);
84 } else {
85 s = fs->NewStructuredAccessFile(current_->path, 0, 0, &reader_);
86 }
87 RETURN_IF_NOT_OK(s)
88
89 // set schema for hdfsFS
90 std::vector<DataType> types;
91 types.push_back(kInt64);
92 if (std::is_same<typename std::decay<SourceType>::type, EdgeSource>::value){
93 types.push_back(kInt64);
94 }
95 if (current_->IsWeighted()) {
96 types.push_back(kFloat);
97 }
98 if (current_->IsLabeled()) {
99 types.push_back(kInt32);
100 }
101 if (current_->IsAttributed()) {
102 types.push_back(kString);
103 }
104 reader_->SetSchema(types);

Callers

nothing calls this directly

Calls 13

GetFileSystemMethod · 0.80
GetServerIdMethod · 0.80
GetServerCountMethod · 0.80
LocalStartMethod · 0.80
LocalSizeMethod · 0.80
SetSchemaMethod · 0.80
GetSchemaMethod · 0.80
sizeMethod · 0.45
GetRecordCountMethod · 0.45
IsWeightedMethod · 0.45
IsLabeledMethod · 0.45

Tested by

no test coverage detected