'Insert records according to key'

def _insert(self, key, records, count):

    if (key not in self.records):
        assert (key not in self.counts)
        self.records[key] = records
        self.counts[key] = count
    else:
        self.records[key] = np.vstack((self.records[key], records))
        assert (key in self.counts)
        self.counts[key] += count
