MCPcopy Create free account
hub / github.com/ByConity/ByConity / addElementSafe

Function addElementSafe

src/DataTypes/Serializations/SerializationTuple.cpp:69–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68template <typename F>
69static void addElementSafe(size_t num_elems, IColumn & column, F && impl)
70{
71 /// We use the assumption that tuples of zero size do not exist.
72 size_t old_size = column.size();
73
74 try
75 {
76 impl();
77
78 // Check that all columns now have the same size.
79 size_t new_size = column.size();
80 for (auto i : collections::range(1, num_elems))
81 {
82 const auto & element_column = extractElementColumn(column, i);
83 if (element_column.size() != new_size)
84 {
85 // This is not a logical error because it may work with
86 // user-supplied data.
87 throw Exception(ErrorCodes::SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH,
88 "Cannot read a tuple because not all elements are present");
89 }
90 }
91 }
92 catch (...)
93 {
94 for (const auto & i : collections::range(0, num_elems))
95 {
96 auto & element_column = extractElementColumn(column, i);
97 if (element_column.size() > old_size)
98 element_column.popBack(1);
99 }
100
101 throw;
102 }
103}
104
105void SerializationTuple::deserializeBinary(IColumn & column, ReadBuffer & istr) const
106{

Callers 4

deserializeBinaryMethod · 0.70
deserializeTextMethod · 0.70
deserializeTextJSONMethod · 0.70
deserializeTextCSVMethod · 0.70

Calls 4

rangeFunction · 0.85
ExceptionClass · 0.50
sizeMethod · 0.45
popBackMethod · 0.45

Tested by

no test coverage detected