Skip to content

Commit af68ff8

Browse files
committed
fix
1 parent a7afeca commit af68ff8

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

contrib/kafka/filters/network/source/serialization.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,49 @@ template <> inline uint32_t EncodingContext::computeSize(const Uuid&) const {
12291229
return 2 * sizeof(uint64_t);
12301230
}
12311231

1232+
// Specializations for primitive types that don't have compact encoding
1233+
// These must be declared before the generic template
1234+
1235+
/**
1236+
* Template overload for int8_t.
1237+
* This data type is not compacted, so we just point to non-compact implementation.
1238+
*/
1239+
template <> inline uint32_t EncodingContext::computeCompactSize(const int8_t& arg) const {
1240+
return computeSize(arg);
1241+
}
1242+
1243+
/**
1244+
* Template overload for int16_t.
1245+
* This data type is not compacted, so we just point to non-compact implementation.
1246+
*/
1247+
template <> inline uint32_t EncodingContext::computeCompactSize(const int16_t& arg) const {
1248+
return computeSize(arg);
1249+
}
1250+
1251+
/**
1252+
* Template overload for uint16_t.
1253+
* This data type is not compacted, so we just point to non-compact implementation.
1254+
*/
1255+
template <> inline uint32_t EncodingContext::computeCompactSize(const uint16_t& arg) const {
1256+
return computeSize(arg);
1257+
}
1258+
1259+
/**
1260+
* Template overload for bool.
1261+
* This data type is not compacted, so we just point to non-compact implementation.
1262+
*/
1263+
template <> inline uint32_t EncodingContext::computeCompactSize(const bool& arg) const {
1264+
return computeSize(arg);
1265+
}
1266+
1267+
/**
1268+
* Template overload for double.
1269+
* This data type is not compacted, so we just point to non-compact implementation.
1270+
*/
1271+
template <> inline uint32_t EncodingContext::computeCompactSize(const double& arg) const {
1272+
return computeSize(arg);
1273+
}
1274+
12321275
/**
12331276
* For non-primitive types, call `computeCompactSize` on them, to delegate the work to the entity
12341277
* itself. The entity may use the information in context to decide which fields are included etc.
@@ -1534,6 +1577,46 @@ inline uint32_t EncodingContext::encodeCompact(const int64_t& arg, Buffer::Insta
15341577
return encode(arg, dst);
15351578
}
15361579

1580+
/**
1581+
* int8_t is not encoded in compact fashion, so we just delegate to normal implementation.
1582+
*/
1583+
template <>
1584+
inline uint32_t EncodingContext::encodeCompact(const int8_t& arg, Buffer::Instance& dst) {
1585+
return encode(arg, dst);
1586+
}
1587+
1588+
/**
1589+
* int16_t is not encoded in compact fashion, so we just delegate to normal implementation.
1590+
*/
1591+
template <>
1592+
inline uint32_t EncodingContext::encodeCompact(const int16_t& arg, Buffer::Instance& dst) {
1593+
return encode(arg, dst);
1594+
}
1595+
1596+
/**
1597+
* uint16_t is not encoded in compact fashion, so we just delegate to normal implementation.
1598+
*/
1599+
template <>
1600+
inline uint32_t EncodingContext::encodeCompact(const uint16_t& arg, Buffer::Instance& dst) {
1601+
return encode(arg, dst);
1602+
}
1603+
1604+
/**
1605+
* bool is not encoded in compact fashion, so we just delegate to normal implementation.
1606+
*/
1607+
template <>
1608+
inline uint32_t EncodingContext::encodeCompact(const bool& arg, Buffer::Instance& dst) {
1609+
return encode(arg, dst);
1610+
}
1611+
1612+
/**
1613+
* double is not encoded in compact fashion, so we just delegate to normal implementation.
1614+
*/
1615+
template <>
1616+
inline uint32_t EncodingContext::encodeCompact(const double& arg, Buffer::Instance& dst) {
1617+
return encode(arg, dst);
1618+
}
1619+
15371620
/**
15381621
* Template overload for variable-length uint32_t (VAR_UINT).
15391622
* Encode the value in 7-bit chunks + marker if field is the last one.

0 commit comments

Comments
 (0)