Skip to content

Instantly share code, notes, and snippets.

@cscotta
Created May 14, 2011 20:33
Show Gist options
  • Save cscotta/972601 to your computer and use it in GitHub Desktop.
Save cscotta/972601 to your computer and use it in GitHub Desktop.
Map Operation
// Sample Event Stream:
{ "event_type": "identification", "name": "nachos" }
{ "event_type": "event", "data": {"meat_type": "carnitas", "cheese_temp": 103, "vegetables": ["tomatoes", "olives"] } }
{ "event_type": "event", "data": {"meat_type": "beef", "cheese_temp": 101, "vegetables": ["tomatoes", "olives"] } }
{ "event_type": "event", "data": {"meat_type": "chicken", "cheese_temp": 98, "vegetables": ["tomatoes", "olives"] } }
// Sample Query:
{
"stream_id" : "nachos",
"stages":
[
{
"query_type": "map",
"key": "cheese_temp",
"result_key": "cheese_temp_celsius",
"operation": "(value - 32) * (5/9)"
}
]
}
// Sample results:
{ "meat_type": "carnitas", "cheese_temp": 103, "vegetables": ["tomatoes", "olives"], "cheese_temp_celsius":39.44444444444444 }
{ "meat_type": "beef", "cheese_temp": 101, "vegetables": ["tomatoes", "olives"], "cheese_temp_celsius":38.333333333333336 }
{ "meat_type": "chicken", "cheese_temp": 98, "vegetables": ["tomatoes", "olives"], "cheese_temp_celsius":36.66666666666667 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment