Search in sources :

Example 1 with CollectedUsages

use of com.intellij.internal.statistic.persistence.CollectedUsages in project intellij-community by JetBrains.

the class AbstractApplicationUsagesCollector method getApplicationUsages.

@NotNull
public Set<UsageDescriptor> getApplicationUsages(@NotNull ApplicationStatisticsPersistence persistence) {
    ObjectIntHashMap<String> result = new ObjectIntHashMap<>();
    long lastTimeSent = UsageStatisticsPersistenceComponent.getInstance().getLastTimeSent();
    for (CollectedUsages usageDescriptors : persistence.getApplicationData(getGroupId()).values()) {
        if (!usageDescriptors.usages.isEmpty() && usageDescriptors.collectionTime > lastTimeSent) {
            result.ensureCapacity(usageDescriptors.usages.size());
            for (UsageDescriptor usageDescriptor : usageDescriptors.usages) {
                String key = usageDescriptor.getKey();
                result.put(key, result.get(key, 0) + usageDescriptor.getValue());
            }
        }
    }
    if (result.isEmpty()) {
        return Collections.emptySet();
    } else {
        final THashSet<UsageDescriptor> descriptors = new THashSet<>(result.size());
        result.forEachEntry(new TObjectIntProcedure<String>() {

            @Override
            public boolean execute(String key, int value) {
                descriptors.add(new UsageDescriptor(key, value));
                return true;
            }
        });
        return descriptors;
    }
}
Also used : ObjectIntHashMap(com.intellij.util.containers.ObjectIntHashMap) CollectedUsages(com.intellij.internal.statistic.persistence.CollectedUsages) UsageDescriptor(com.intellij.internal.statistic.beans.UsageDescriptor) THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)1 CollectedUsages (com.intellij.internal.statistic.persistence.CollectedUsages)1 ObjectIntHashMap (com.intellij.util.containers.ObjectIntHashMap)1 THashSet (gnu.trove.THashSet)1 NotNull (org.jetbrains.annotations.NotNull)1