Event MapReduce Algorithm
Events encapsulate communication between the game process and spectators. They can perform many functions, including funneling spectator inputs, analyzing and responding to chat events, and inspecting logs. They are composed of a key:value pair.
We designed Genvid scalability around a MapReduce algorithm which filters the events coming from multiple sources (web spectators, game client, live chat, logs, etc.) and combines them into a limited number of outcomes. This drastically reduces both frequency and bandwidth impacts.
The schema is written in JSON and contains the definition for your events. It is divided with the map and reduce portion. Note that the where clause is present for both the map and reduce.
Schema example
{
"version": "1.7.0",
"event": {
"game": {
"maps": [
{
"id": "changeColor",
"source": "userinput",
"where": {"key": ["changeColor", "<name>"], "name": "<color>", "type": "string"},
"key": ["changeColor", "<name>", "<color>"], "value": 1
},
{
"id": "cheer",
"source": "userinput",
"where": {"key": ["cheer"], "name": "<name>", "type": "string"},
"key": ["cheer", "<name>"], "value": 1
}
],
"reductions": [
{
"id": "changeColor",
"where": {"key": ["changeColor", "<name>", "<color>"]},
"key": ["<name>", "<color>"],
"value": ["$count"],
"period": 250
},
{
"id": "cheer",
"where": {"key": ["cheer", "<name>"]},
"key": ["<name>"],
"value": ["$sum"],
"period": 250,
},
{
"id": "cheerbattle",
"where": {"key": ["cheer", "<name>"]},
"key": ["<name>"],
"value": ["$sum"],
"period": 1000,
"reset": {
"mode": "periodic",
"count": 60
}
}
]
}
}
}
Schema content
In your schema, the document must be made with this exact structure:
First depth level
A
version
field is present and it needs to be 1.7.0.An
event
field that contains the rest of the definition.
Second depth level
A game
field that contains the map and reduce portions.
Third depth level
A
maps
field which contains your map definition.A
reductions
field which contains your reduce definition.
Map and reduce both use the where
clause to filter through
the results. Note that it is possible to divide the map
and reduce into their own documents, so it is not mandatory
to have both placed inside the same document.