@Override public long computeHash(int seed, Set<String> hashAttributes, AttributesMap attributes) { return identity(seed) .putString(id) .hash(); }
@Override public long computeHash(int seed, Set<String> hashAttributes, AttributesMap attributes) { return identity(seed) .putString(name) .hash(); }
@Override public long computeHash(int seed, Set<String> hashAttributes, AttributesMap attributes) { return identity(seed) .putString(name) .hash(); }
protected Experiment(Experiments owner, String name) { this.owner = owner; this.name = name; this.filter = FilterExpression.alwaysTrue(); this.hashAttributes = EMPTY_SET; this.allocations = new Allocations(); this.treatments = Maps.newConcurrentMap(); this.overrides = Maps.newConcurrentMap(); this.seed = (int) IdentityBuilder.seed(0).putString(name).hash(); }
/** * generates a hash code used to assign identity to treatment * @param seed a seed value to randomize the resulting hash from experiment to experiment for the same identity * @param hashAttributes a set of attributes that should be used to compute the hash code * @param attributes a map of attribute values */ public long computeHash(int seed, Set<String> hashAttributes, AttributesMap attributes) { final IdentityBuilder builder = IdentityBuilder.seed(seed); final Iterable<String> names = hashAttributes.isEmpty() ? attributes.keySet() : hashAttributes; for (String name : names) { final Class<?> type = attributes.getType(name); if (type == String.class) { builder.putString(attributes.getString(name)); } else if (type == Long.class) { builder.putLong(attributes.getNumber(name)); } else if (type == Boolean.class) { builder.putBoolean(attributes.getBoolean(name)); } } return builder.hash(); }