MCPcopy Create free account
hub / github.com/NVIDIA/DALI / ParseIndexFile

Function ParseIndexFile

dali/operators/reader/loader/webdataset_loader.cc:118–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118inline void ParseIndexFile(std::vector<SampleDesc>& samples_container,
119 std::vector<ComponentDesc>& components_container,
120 const std::string& index_path) {
121 std::ifstream index_file(index_path);
122
123 // Index Checking
124 std::string global_meta;
125 getline(index_file, global_meta);
126 std::stringstream global_meta_stream(global_meta);
127 std::string index_version_str;
128 DALI_ENFORCE(global_meta_stream >> index_version_str,
129 IndexFileErrMsg(index_path, 0, "no version signature found"));
130 DALI_ENFORCE(
131 kSupportedIndexVersions.count(index_version_str) > 0,
132 IndexFileErrMsg(index_path, 0,
133 make_string("Unsupported version of the index file (",
134 index_version_str, ").")));
135 int index_version = ParseIndexVersion(index_version_str);
136
137 // Getting the number of samples in the index file
138 int64_t sample_desc_num_signed;
139 DALI_ENFORCE(global_meta_stream >> sample_desc_num_signed,
140 IndexFileErrMsg(index_path, 0, "no sample count found"));
141 DALI_ENFORCE(sample_desc_num_signed > 0,
142 IndexFileErrMsg(index_path, 0, "sample count must be positive"));
143
144 const size_t sample_desc_num = sample_desc_num_signed;
145 samples_container.reserve(samples_container.size() + sample_desc_num);
146 for (size_t sample_index = 0; sample_index < sample_desc_num; sample_index++) {
147 ParseSampleDesc(samples_container, components_container, index_file, index_path,
148 sample_index + 1, index_version);
149 }
150}
151
152std::tuple<std::string, std::string> split_name(const std::string& filepath) {
153 size_t dot_pos = filepath.find('.', filepath.rfind('/') + 1);

Callers 1

PrepareMetadataImplMethod · 0.85

Calls 6

IndexFileErrMsgFunction · 0.85
ParseIndexVersionFunction · 0.85
ParseSampleDescFunction · 0.85
make_stringFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected