def __AggregateTotal(self, size, key, proto, namespace, stat_kind):
    kind_name = key.kind()

    entity_key_size = (len(proto.key().app()) +
                       len(proto.key().path().SerializeToString()) +
                       len(proto.entity_group().SerializeToString()))

    type_index_size, type_index_count = self.__GetTypeIndexStat(namespace,
                                                                kind_name,
                                                                entity_key_size)
    property_index_count = 0
    property_index_size = 0
    for prop_list in (proto.property_list(), proto.raw_property_list()):
      for prop in prop_list:
        index_size, index_count = self.__GetPropertyIndexStat(namespace,
                                                              kind_name,
                                                              entity_key_size,
                                                              prop)
        property_index_size += index_size
        property_index_count += index_count

    builtin_index_size = type_index_size + property_index_size
    builtin_index_count = type_index_count + property_index_count


    if stat_kind == stats.GlobalStat:
      count = 0
    else:
      count = 1


    self.__Increment(self.whole_app_stats, count, _GLOBAL_KEY, size,
                     builtin_index_count=builtin_index_count,
                     builtin_index_size=builtin_index_size)


    name_id = namespace
    if not name_id:
      name_id = 1

    if (stat_kind == stats.NamespaceStat) and (namespace == ''):
      count = 0


    self.__Increment(self.whole_app_stats, count,
                     (stats.NamespaceStat, name_id, ''),
                     size,
                     builtin_index_count=builtin_index_count,
                     builtin_index_size=builtin_index_size,
                     subject_namespace=namespace)

    if stat_kind == stats.NamespaceGlobalStat:
      count = 0


    self.__Increment(
        self.namespace_stats, count,
        (stats.NamespaceGlobalStat, 'total_entity_usage', namespace), size,
        builtin_index_count=builtin_index_count,
        builtin_index_size=builtin_index_size)
Aggregate total datastore stats.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/datastore/datastore_stats_generator.py/DatastoreStatsProcessor.__AggregateTotal