I figured it out. I wasn't performing a deep copy.
I changed the code to this, and now it is giving me what I was expoecting:
$epoch_result(ts: time, key: SumStats::Key, result: SumStats::Result) =
{
local tmp: table[string] of count;
if ("prefix" in result)
{
local i = 0;
local payload = SumStats::key2str(key);
for (bytei in payload)
{
bytei = string_to_ascii_hex(bytei);
if (i !in BytePatterns::other_counts)
{
BytePatterns::other_counts[i] = copy(tmp);
}
if (bytei !in BytePatterns::other_counts[i])
{
BytePatterns::other_counts[i][bytei] = 0;
}
BytePatterns::other_counts[i][bytei] += 1;
i += 1;
}
}