This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"namespace": "logicalgenetics.sale", | |
"type": "record", | |
"name": "sale", | |
"fields": [ | |
{"name": "beer_id", "type": "int"}, | |
{"name": "bar", "type": "int"}, | |
{"name": "price", "type": "int"} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |