MCPcopy Create free account
hub / github.com/catboost/catboost / BuildVector

Method BuildVector

contrib/libs/flatbuffers/src/binary_annotator.cpp:1036–1381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036void BinaryAnnotator::BuildVector(
1037 const uint64_t vector_offset, const reflection::Object *const table,
1038 const reflection::Field *const field, const uint64_t parent_table_offset,
1039 const std::map<uint16_t, VTable::Entry> vtable_fields) {
1040 if (ContainsSection(vector_offset)) { return; }
1041
1042 BinaryRegionComment vector_length_comment;
1043 vector_length_comment.type = BinaryRegionCommentType::VectorLength;
1044
1045 const bool is_64_bit_vector =
1046 field->type()->base_type() == reflection::BaseType::Vector64;
1047
1048 flatbuffers::Optional<uint64_t> vector_length;
1049 uint32_t vector_length_size_type = 0;
1050 BinaryRegionType region_type = BinaryRegionType::Uint32;
1051 BinarySectionType section_type = BinarySectionType::Vector;
1052
1053 if (is_64_bit_vector) {
1054 auto v = ReadScalar<uint64_t>(vector_offset);
1055 if (v.has_value()) { vector_length = v.value(); }
1056 vector_length_size_type = sizeof(uint64_t);
1057 region_type = BinaryRegionType::Uint64;
1058 section_type = BinarySectionType::Vector64;
1059 } else {
1060 auto v = ReadScalar<uint32_t>(vector_offset);
1061 if (v.has_value()) { vector_length = v.value(); }
1062 vector_length_size_type = sizeof(uint32_t);
1063 region_type = BinaryRegionType::Uint32;
1064 section_type = BinarySectionType::Vector;
1065 }
1066
1067 if (!vector_length.has_value()) {
1068 const uint64_t remaining = RemainingBytes(vector_offset);
1069 SetError(vector_length_comment, BinaryRegionStatus::ERROR_INCOMPLETE_BINARY,
1070 "4");
1071
1072 AddSection(
1073 vector_offset,
1074 MakeSingleRegionBinarySection(
1075 std::string(table->name()->c_str()) + "." + field->name()->c_str(),
1076 BinarySectionType::Vector,
1077 MakeBinaryRegion(vector_offset, remaining,
1078 BinaryRegionType::Unknown, remaining, 0,
1079 vector_length_comment)));
1080 return;
1081 }
1082
1083 // Validate there are enough bytes left in the binary to process all the
1084 // items.
1085 const uint64_t last_item_offset =
1086 vector_offset + vector_length_size_type +
1087 vector_length.value() * GetElementSize(field);
1088
1089 if (!IsValidOffset(last_item_offset - 1)) {
1090 SetError(vector_length_comment, BinaryRegionStatus::ERROR_LENGTH_TOO_LONG);
1091 AddSection(
1092 vector_offset,
1093 MakeSingleRegionBinarySection(

Callers

nothing calls this directly

Calls 15

SetErrorFunction · 0.85
MakeBinaryRegionFunction · 0.85
NumToStringFunction · 0.85
GetRegionTypeFunction · 0.85
GetTypeSizeFunction · 0.85
IsUnionTypeFunction · 0.85
MakeBinarySectionFunction · 0.85
idMethod · 0.80
stringClass · 0.50
IsScalarFunction · 0.50
to_stringFunction · 0.50

Tested by

no test coverage detected