selectIdVariationWithMurMurHash method
Implementation
String? selectIdVariationWithMurMurHash(
String visitorId, VariationGroup varGroup) {
int hashAlloc;
// We calculate the Hash allocation by the combination of : visitorId + idVariationGroup
String combinedId = varGroup.idVariationGroup + visitorId;
// Calculate the murmurHash algorithm
hashAlloc = (MurmurHash.v3(combinedId, 0) % 100);
Flagship.logger(
Level.DEBUG,
"########### The MurMurHash for the combined " +
varGroup.idVariationGroup +
" " +
visitorId +
" is : $hashAlloc #############");
int offsetAlloc = 0;
for (Variation itemVar in varGroup.variations) {
if (hashAlloc < itemVar.allocation + offsetAlloc) {
return itemVar.idVariation;
}
offsetAlloc += itemVar.allocation;
}
return null;
}