HPCC-12046 Change stats to use hash table and a value array

Also switch to using a StatsScopeId class, and clean up other code

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>