93 char schemaString[128];
94 read(schemaString, 128);
103#if WDC_READ_DEBUG > 0
120 for (uint32_t i = 0; i < sectionCount; i++)
128 read(&sh,
sizeof(sh));
142 read(&sh,
sizeof(sh));
155 LOG_INFO <<
"DB2Reader step 2 done: sectionCount=" << sectionCount
186 uint32_t fieldId = 0;
192 info.additional_data_size != 0)
195 offset += info.additional_data_size;
210 uint32_t fieldId = 0;
214 if (info.storage_type ==
COMP_COMMON_DATA && info.additional_data_size != 0)
216 unsigned char* ptr = commonRaw + offset;
217 std::map<uint32_t, uint32_t> vals;
218 for (uint32_t i = 0; i < info.additional_data_size / 8; i++)
221 std::memcpy(&
id, ptr, 4); ptr += 4;
222 std::memcpy(&val, ptr, 4); ptr += 4;
226 offset += info.additional_data_size;
240 for (uint32_t si = 0; si < sectionCount; si++)
245 uint32_t entryCount = 0;
246 read(&entryCount, 4);
258 uint32_t previousStringTableSize = 0;
260 for (uint32_t si = 0; si < sectionCount; si++)
268 LOG_INFO <<
"DB2Reader step 8: section " << si
280 const uint32_t recordDataOfs = sec.
fileOffset;
281 const uint32_t recordDataSize = sec.
isNormal
289 LOG_INFO <<
"DB2Reader step 8: section " << si
290 <<
" record data out of bounds (ofs=" << recordDataOfs
291 <<
" size=" << recordDataSize
293 <<
"), marking encrypted for " <<
fullname();
339 read(&entry,
sizeof(entry));
340 if (entry.newRowId != entry.copiedRowId)
370 const size_t relStart =
getPos();
379 uint32_t numEntries = 0;
380 read(&numEntries, 4);
383 for (uint32_t i = 0; i < numEntries; i++)
385 uint32_t foreignID, recIndex;
405 LOG_INFO <<
"DB2Reader step 8 done: data sections parsed, pos=" <<
getPos()
409 uint32_t totalRecordCount = 0;
411 for (uint32_t si = 0; si < sectionCount; si++)
415 LOG_INFO <<
"DB2Reader step 9: section " << si
423 bool isZeroed =
true;
430 LOG_INFO <<
"DB2Reader: section " << si
431 <<
" record data out of file bounds, treating as encrypted in "
451 uint32_t firstVal = 0;
452 std::memcpy(&firstVal, ptr, 4);
453 isZeroed = (firstVal == 0);
463 LOG_INFO <<
"DB2Reader: skipping encrypted section " << si <<
" in " <<
fullname();
470 const bool hasIDMap = !sec.
idList.empty();
471 const bool emptyIDMap = hasIDMap &&
472 std::all_of(sec.
idList.begin(), sec.
idList.end(), [](uint32_t
id) { return id == 0; });
488 std::memcpy(&
id, recPtr + idInfo.
field_offset_bits / 8, std::min(fieldSize, 4u));
531 std::unordered_map<uint32_t, size_t> idToLocationIndex;
537 auto it = idToLocationIndex.find(srcID);
538 if (it != idToLocationIndex.end())
555 LOG_INFO <<
"DB2Reader step 11 done: idToRecordIndex built for " <<
fullname();
559 std::unordered_map<uint64_t, uint32_t> sectionLocalToRecordID;
561 sectionLocalToRecordID[(uint64_t(loc.sectionIndex) << 32) | loc.localIndex] = loc.recordID;
563 for (uint32_t si = 0; si < sectionCount; si++)
568 const uint64_t key = (uint64_t(si) << 32) | recIndex;
569 auto it = sectionLocalToRecordID.find(key);
570 if (it != sectionLocalToRecordID.end())
579 <<
" sections=" << sectionCount;
631 unsigned int recordIndexInSection,
632 unsigned int fieldIndex,
633 unsigned int arrayIndex,
634 unsigned int arraySize,
636 unsigned int& result)
const
638 const unsigned char* recordOffset =
getRecordOffset(sectionIndex, recordIndexInSection);
650 fieldSize /= arraySize;
655 std::memcpy(&result, fieldOffset, std::min(fieldSize, 4u));
658 if (bitsPerElement < 32)
659 result &= (1u << bitsPerElement) - 1;
675 auto valIt = mapIt->second.find(recordID);
676 if (valIt != mapIt->second.end())
677 result = valIt->second;
687 LOG_ERROR <<
"DB2Reader: missing pallet offset for field " << fieldIndex;
690 const uint32_t offset = it->second + index * 4;
700 LOG_ERROR <<
"DB2Reader: missing pallet offset for field " << fieldIndex;
703 const uint32_t offset = it->second + index * arraySize * 4 + arrayIndex * 4;
bool readFieldValue(unsigned int sectionIndex, unsigned int recordIndexInSection, unsigned int fieldIndex, unsigned int arrayIndex, unsigned int arraySize, uint32_t recordID, unsigned int &result) const