Skip to content

Commit c5ac3d0

Browse files
authored
Increase MAX_KEYS to 47 (#32)
1 parent e306185 commit c5ac3d0

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

statshouse.hpp

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class TransportUDPBase {
161161
SAFE_DATAGRAM_SIZE = 508, // https://stackoverflow.com/questions/1098897/what-is-the-largest-safe-udp-packet-size-on-the-internet
162162
DEFAULT_DATAGRAM_SIZE = 1232,
163163
MAX_DATAGRAM_SIZE = 65507, // https://stackoverflow.com/questions/42609561/udp-maximum-packet-size/42610200
164-
MAX_KEYS = 16,
164+
MAX_KEYS = 47,
165165
MAX_FULL_KEY_SIZE = 1024, // roughly metric plus all tags
166166
};
167167

@@ -438,7 +438,7 @@ class TransportUDPBase {
438438
return (i < 10) ? (1 | (uint32_t('0' + i) << 8)) : (2 | (uint32_t('0' + i/10) << 8) | (uint32_t('0' + i%10) << 16));
439439
}
440440
static uint32_t get_tag_name_tl(size_t i) {
441-
static constexpr std::array<uint32_t, MAX_KEYS + 1> names{
441+
static constexpr std::array<uint32_t, MAX_KEYS> names{
442442
pack_key_name(0),
443443
pack_key_name(1),
444444
pack_key_name(2),
@@ -456,9 +456,38 @@ class TransportUDPBase {
456456
pack_key_name(14),
457457
pack_key_name(15),
458458
pack_key_name(16),
459-
// we add extra key on purpose. statshouse will show receive error "tag 16 does not exist" if we overflow
459+
pack_key_name(17),
460+
pack_key_name(18),
461+
pack_key_name(19),
462+
pack_key_name(20),
463+
pack_key_name(21),
464+
pack_key_name(22),
465+
pack_key_name(23),
466+
pack_key_name(24),
467+
pack_key_name(25),
468+
pack_key_name(26),
469+
pack_key_name(27),
470+
pack_key_name(28),
471+
pack_key_name(29),
472+
pack_key_name(30),
473+
pack_key_name(31),
474+
pack_key_name(32),
475+
pack_key_name(33),
476+
pack_key_name(34),
477+
pack_key_name(35),
478+
pack_key_name(36),
479+
pack_key_name(37),
480+
pack_key_name(38),
481+
pack_key_name(39),
482+
pack_key_name(40),
483+
pack_key_name(41),
484+
pack_key_name(42),
485+
pack_key_name(43),
486+
pack_key_name(44),
487+
pack_key_name(45),
488+
pack_key_name(46),
460489
};
461-
static_assert(names[MAX_KEYS] != 0, "please add key names to array when increasing MAX_KEYS");
490+
static_assert(names[MAX_KEYS - 1] != 0, "please add key names to array when increasing MAX_KEYS");
462491
if (i >= names.size())
463492
return 0; // if even more tags added, we do not care, so empty string is good enough.
464493
return names[i];

0 commit comments

Comments
 (0)