Add key type param to KeyValue and support ints in count_by