MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / array_schema_from_capnp

Function array_schema_from_capnp

tiledb/sm/serialization/array_schema.cc:941–1187  ·  view source on GitHub ↗

#TODO Add security validation on incoming URI

Source from the content-addressed store, hash-verified

939
940// #TODO Add security validation on incoming URI
941shared_ptr<ArraySchema> array_schema_from_capnp(
942 const capnp::ArraySchema::Reader& schema_reader,
943 const URI& uri,
944 shared_ptr<MemoryTracker> memory_tracker) {
945 // Deserialize and validate array_type
946 ArrayType array_type = ArrayType::DENSE;
947 Status st = array_type_enum(schema_reader.getArrayType(), &array_type);
948 if (!st.ok()) {
949 throw std::runtime_error(
950 "[Deserialization::array_schema_from_capnp] " +
951 std::string(schema_reader.getArrayType().cStr()) +
952 " is not a valid ArrayType identifer.");
953 }
954
955 try {
956 ensure_array_type_is_valid(std::underlying_type_t<ArrayType>(array_type));
957 } catch (std::exception& e) {
958 std::throw_with_nested(
959 std::runtime_error("[Deserialization::array_schema_from_capnp] "));
960 }
961
962 // Deserialize and validate tile_order
963 Layout tile_order = Layout::ROW_MAJOR;
964 st = layout_enum(schema_reader.getTileOrder().cStr(), &tile_order);
965 if (!st.ok()) {
966 throw std::runtime_error(
967 "[Deserialization::array_schema_from_capnp] " +
968 std::string(schema_reader.getTileOrder().cStr()) +
969 " is not a valid tile order identifer.");
970 }
971
972 try {
973 ensure_tile_order_is_valid(std::underlying_type_t<Layout>(tile_order));
974 } catch (std::exception& e) {
975 std::throw_with_nested(
976 std::runtime_error("[Deserialization::array_schema_from_capnp] "));
977 }
978
979 // Deserialize and validate cell_order
980 Layout cell_order = Layout::ROW_MAJOR;
981 st = layout_enum(schema_reader.getCellOrder().cStr(), &cell_order);
982 if (!st.ok()) {
983 throw std::runtime_error(
984 "[Deserialization::array_schema_from_capnp] " +
985 std::string(schema_reader.getCellOrder().cStr()) +
986 " is not a valid cell order identifer.");
987 }
988
989 try {
990 ensure_cell_order_is_valid(std::underlying_type_t<Layout>(cell_order));
991 } catch (std::exception& e) {
992 std::throw_with_nested(
993 std::runtime_error("[Deserialization::array_schema_from_capnp] "));
994 }
995
996 // Deserialize URI
997 // #TODO Add security validation
998 URI uri_deserialized = URI();

Callers 6

array_schema_deserializeFunction · 0.85
array_create_from_capnpFunction · 0.85
array_schema.ccFile · 0.85
fragment_info_from_capnpFunction · 0.85
array_from_capnpFunction · 0.85

Calls 15

array_type_enumFunction · 0.85
layout_enumFunction · 0.85
domain_from_capnpFunction · 0.85
attribute_from_capnpFunction · 0.85
enumeration_from_capnpFunction · 0.85
getArrayTypeMethod · 0.80

Tested by

no test coverage detected