void InteropInputStream::Position(int32_t pos) { if (pos > len) { IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_MEMORY, "Requested input stream position is out of bounds", "memPtr", mem->PointerLong(), "len", len, "pos", pos); } this->pos = pos; }
int32_t BinaryObjectImpl::FindField(const int32_t fieldId) const { BinaryObjectHeader header(mem->Data() + start); int32_t flags = header.GetFlags(); int32_t footerBegin = header.GetFooterOffset() + start; int32_t footerEnd = footerBegin + header.GetFooterLength(); if ((mem->Length() - start) < footerEnd) { IGNITE_ERROR_FORMATTED_3(ignite::IgniteError::IGNITE_ERR_MEMORY, "Not enough data in the binary object", "memPtr", mem->PointerLong(), "len", (mem->Length() - start), "footerEnd", footerEnd); } if (flags & IGNITE_BINARY_FLAG_OFFSET_ONE_BYTE) { for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 5) { int32_t currentFieldId = BinaryUtils::UnsafeReadInt32(*mem, schemaPos); if (fieldId == currentFieldId) return (BinaryUtils::UnsafeReadInt8(*mem, schemaPos + 4) & 0xFF) + start; } } else if (flags & IGNITE_BINARY_FLAG_OFFSET_TWO_BYTES) { for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 6) { int32_t currentFieldId = BinaryUtils::UnsafeReadInt32(*mem, schemaPos); if (fieldId == currentFieldId) return (BinaryUtils::UnsafeReadInt16(*mem, schemaPos + 4) & 0xFFFF) + start; } } else { for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 8) { int32_t currentFieldId = BinaryUtils::UnsafeReadInt32(*mem, schemaPos); if (fieldId == currentFieldId) return BinaryUtils::UnsafeReadInt32(*mem, schemaPos + 4) + start; } } return -1; }