# nb -v run driver=cql yaml=cql-iot tags=phase:schema host=dsehost
description: |
  put workload descript here
scenarios:
  default:
    sample: run foo

params:
  # think about what params we wanna supply and iterate
  instrument: TEMPLATE(instrument,false)

bindings:
  machine_id: Mod(<<sources:10000>>); ToHashedUUID() -> java.util.UUID
  sensor_name: HashedLineToString('data/variable_words.txt')
  time: Mul(<<timespeed:100>>L); Div(<<sources:10000>>L); ToDate()
  cell_timestamp: Mul(<<timespeed:100>>L); Div(<<sources:10000>>L); Mul(1000L)
  sensor_value: Normal(0.0,5.0); Add(100.0) -> double
  station_id: Div(<<sources:10000>>);Mod(<<stations:100>>); ToHashedUUID() -> java.util.UUID
  data: HashedFileExtractToString('data/lorem_ipsum_full.txt',800,1200)
blocks:
  schema:
    params:
      prepared: false
    ops:
      create-table: |
        create table if not exists <<keyspace:baselines>>.<<table:iot>> (
        machine_id UUID,     // source machine
        sensor_name text,    // sensor name
        time timestamp,      // timestamp of collection
        sensor_value double, //
        station_id UUID,     // source location
        data text,
        PRIMARY KEY ((machine_id, sensor_name), time)
        );
  main-write:
    params:
      ratio: <<write_ratio:9>>
      cl: <<write_cl:LOCAL_QUORUM>>
      idempotent: true
      instrument: TEMPLATE(instrument-writes,TEMPLATE(instrument,false))
    ops:
      insert-main: |
        insert into <<keyspace:baselines>>.<<table:iot>>
        (machine_id, sensor_name, time, sensor_value, station_id, data)
        values ({machine_id}, {sensor_name}, {time}, {sensor_value}, {station_id}, {data})
        using timestamp {cell_timestamp}