MCPcopy Create free account
hub / github.com/comaps/comaps / IndexFileReader

Method IndexFileReader

generator/intermediate_data.cpp:289–314  ·  view source on GitHub ↗

IndexFileReader ---------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

287
288// IndexFileReader ---------------------------------------------------------------------------------
289IndexFileReader::IndexFileReader(string const & name)
290{
291 FileReader fileReader(name);
292 m_elements.clear();
293 size_t const fileSize = base::checked_cast<size_t>(fileReader.Size());
294 if (fileSize == 0)
295 return;
296
297 LOG_SHORT(LINFO, ("Offsets reading is started for file", fileReader.GetName()));
298 CHECK_EQUAL(0, fileSize % sizeof(Element), ("Damaged file."));
299
300 try
301 {
302 m_elements.resize(fileSize / sizeof(Element));
303 }
304 catch (std::bad_alloc const &)
305 {
306 LOG(LCRITICAL, ("Insufficient memory for required offset map"));
307 }
308
309 fileReader.Read(0, &m_elements[0], fileSize);
310
311 sort(m_elements.begin(), m_elements.end(), ElementComparator());
312
313 LOG_SHORT(LINFO, ("Offsets reading is finished"));
314}
315
316bool IndexFileReader::GetValueByKey(Key key, Value & value) const
317{

Callers

nothing calls this directly

Calls 8

ElementComparatorClass · 0.85
clearMethod · 0.45
SizeMethod · 0.45
GetNameMethod · 0.45
resizeMethod · 0.45
ReadMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected