public Builder() { this.item = new ActionCounts(); }
/** * {@inheritDoc} */ @Override public ExperimentCounts calculateExperimentCounts(Collection<BucketCounts> bucketsSet) { Map<Bucket.Label, BucketCounts> buckets = new HashMap<>(); for (BucketCounts bucket : bucketsSet) { buckets.put(bucket.getLabel(), bucket); } Counts jointActionCounts = new Counts(0, 0); Counts impressionCounts = new Counts(0, 0); Map<Event.Name, ActionCounts> experimentActionCounts = new HashMap<>(); for (BucketCounts bucket : bucketsSet) { jointActionCounts.addCount(bucket.getJointActionCounts()); impressionCounts.addCount(bucket.getImpressionCounts()); Map<Event.Name, ActionCounts> bucketActionCounts = bucket.getActionCounts(); for (ActionCounts bucketCounts : bucketActionCounts.values()) { Event.Name actionName = bucketCounts.getActionName(); ActionCounts currentExperimentCounts = experimentActionCounts.get(actionName); if (currentExperimentCounts == null) { experimentActionCounts.put(actionName, bucketCounts.clone()); } else { currentExperimentCounts.addCount(bucketCounts); } } } return new ExperimentCounts.Builder().withActionCounts(experimentActionCounts).withBuckets(buckets) .withImpressionCounts(impressionCounts).withJointActionCounts(jointActionCounts) .build(); }
@Override public AbstractContainerCounts clone() { AbstractContainerCounts cloned; try { cloned = (AbstractContainerCounts) super.clone(); } catch (CloneNotSupportedException e) { // Should never happen throw new AnalyticsException("AbstractContainerCounts clone not supported: " + e.getMessage(), e); } if (impressionCounts != null) { cloned.setImpressionCounts(impressionCounts.clone()); } if (jointActionCounts != null) { cloned.setJointActionCounts(jointActionCounts.clone()); } if (actionCounts != null) { Map<Event.Name, ActionCounts> clonedActions = new HashMap<>(); for (Entry<Name, ActionCounts> entry : actionCounts.entrySet()) { clonedActions.put(entry.getKey(), entry.getValue().clone()); } cloned.setActionCounts(clonedActions); } return cloned; } }
Map<Event.Name, ActionCounts> actionCounts = container.getActionCounts(); for (ActionCounts action : actionCounts.values()) { Event.Name actionName = action.getActionName(); Estimate rate; try { rate = metric.estimateRate(uniqueImpressions, action.getUniqueUserCount()); } catch (IllegalArgumentException iae) { if (LOGGER.isWarnEnabled())
ActionCounts action = actionCounts.get(actionName); ActionCounts otherAction = otherActionCounts.get(actionName); bucketUniqueCounts = action.getUniqueUserCount(); otherBucketUniqueCounts = otherAction.getUniqueUserCount();