Skip to content

Instantly share code, notes, and snippets.

View DanteLore's full-sized avatar
👾

Dan Taylor DanteLore

👾
View GitHub Profile
{
"namespace": "logicalgenetics.sale",
"type": "record",
"name": "sale",
"fields": [
{"name": "beer_id", "type": "int"},
{"name": "bar", "type": "int"},
{"name": "price", "type": "int"}
]
}
object SaleProducer {
// ...
def createSale : GenericRecord = {
val sale: GenericRecord = new GenericData.Record(schema)
sale.put("beer_id", beerIds(Random.nextInt(beerIds.size)).toInt)
sale.put("bar", Random.nextInt(4) + 1) // There are 4 bars (i.e. 4 cash registers)
sale.put("price", if(Random.nextDouble() > 0.75) 2 else 1) // Beer festival; 1 token per half
sale