using System.Collections.Generic;
public static void Main()
val = (val % 10000 == 0) ? val /= 10000 : 9999;
UInt32 score = (uint)val;
Console.WriteLine("Parsing AdInfoScore = {0}\n", val);
Console.WriteLine("AlgoId: {0}", ParseAlgoId(score));
Console.WriteLine("UserIdType: {0}", ParseUserIdType(score));
Console.WriteLine("AnnIndexId: {0}\n", ParseAnnIndexId(score));
Console.WriteLine("\n-------------------");
Console.WriteLine("GPT-Embedding Algos");
Console.WriteLine("-------------------");
List<UInt32> userIdTypes = new List<UInt32> { 3, 4, 5, 8 };
List<UInt32> algoIds = new List<UInt32> {23, 28, 32, 33};
foreach (UInt32 algo in algoIds)
Console.WriteLine("\nAlgoId: {0}", algo);
foreach (UInt32 userIdType in userIdTypes)
UInt32 adInfoScore = BuildSelectionMetadata(isAstro, false, algo, userIdType, annIndexId);
Console.WriteLine("\tAdInfoScore(AlgoId={0}, UserIdType={1}, AnnIndexId={2}) : {3}", algo, userIdType, annIndexId, ((long)adInfoScore)*10000);
Console.WriteLine("================================================================");
Console.WriteLine("\n------------------");
Console.WriteLine("GPT-Scraping Algos");
Console.WriteLine("------------------");
userIdTypes = new List<UInt32> { 3, 4, 5, 8 };
algoIds = new List<UInt32> {211, 213, 223, 224};
foreach (UInt32 algo in algoIds)
Console.WriteLine("\nAlgoId: {0}", algo);
foreach (UInt32 userIdType in userIdTypes)
UInt32 adInfoScore = BuildSelectionMetadata(isAstro, false, algo, userIdType, annIndexId);
Console.WriteLine("\tAdInfoScore(AlgoId={0}, UserIdType={1}, AnnIndexId={2}) : {3}", algo, userIdType, annIndexId, ((long)adInfoScore)*10000);
public static UInt32 BuildSelectionMetadata(bool isAstro,
output |= ((algoId & 0xFF) << 16);
output |= ((userIdType & 0xF) << 12);
output |= ((annIndexId & 0xF) << 8);
public static UInt32 ParseUserIdType(UInt32 adInfoScore)
if (IsValid(adInfoScore))
return ((adInfoScore & 0x0000F000) >> 12);
public static UInt32 ParseAlgoId(UInt32 adInfoScore)
if (IsValid(adInfoScore))
return ((adInfoScore & 0x00FF0000) >> 16);
public static UInt32 ParseAnnIndexId(UInt32 adInfoScore)
if (IsValid(adInfoScore))
return ((adInfoScore & 0x00000F00) >> 8);
public static bool IsValid(UInt32 adInfoScore)
return (0 == ((adInfoScore) & 0x0F0000FF));