Skip to content

Commit

Permalink
Updated minor changes for syntax and comments for variables used based
Browse files Browse the repository at this point in the history
on PR review #16
  • Loading branch information
ameyb committed Aug 6, 2019
1 parent 49aafda commit 01c49bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/yugabyte/sample/apps/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ public static enum Type {

// The path to the certificate to be used for the SSL connection.
public String sslCert = null;

//Number of devices to simulate data for CassandraEventData workload
public int num_devices = 100;

//Number of Event Types per device to simulate data for CassandraEventData workload
public int num_event_types = 100;


Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/yugabyte/sample/apps/CassandraEventData.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class CassandraEventData extends AppBase {
static List<DataSource> dataSources = new CopyOnWriteArrayList<DataSource>();
// The number of devices to simulate.
private static int num_devices = 100;
// The number of event types
// The number of event types.
private static int num_event_types = 100;
// The shared prepared select statement for fetching the data.
private static volatile PreparedStatement preparedSelect;
Expand Down Expand Up @@ -130,7 +130,7 @@ private PreparedStatement getPreparedInsert() {
if (preparedInsert == null) {
// Create the prepared statement object.
String insert_stmt = String.format("INSERT INTO %s (device_id, ts, event_type, value) VALUES "
+ "(:device_id, :ts,:event_type, :value);", getTableName());
+ "(:device_id, :ts, :event_type, :value);", getTableName());
preparedInsert = getCassandraClient().prepare(insert_stmt);
}
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public long doRead() {

// Bind the select statement.
BoundStatement select = getPreparedSelect().bind().setString("deviceId", dataSource.getDeviceId())
.setLong("startTs", startTs).setLong("endTs", endTs).setString("event_type", dataSource.getEvent_type())
.setLong("startTs", startTs).setLong("endTs", endTs).setString("event_type", dataSource.getEventType())
.setInt("readBatchSize", appConfig.cassandraReadBatchSize);
// Make the query.
ResultSet rs = getCassandraClient().execute(select);
Expand All @@ -211,7 +211,7 @@ public long doWrite(int threadIdx) {
long ts = dataSource.getDataEmitTs();
for (int i = 0; i < appConfig.cassandraBatchSize; i++) {
batch.add(getPreparedInsert().bind().setString("device_id", dataSource.getDeviceId()).setLong("ts", ts)
.setString("event_type", dataSource.getEvent_type())
.setString("event_type", dataSource.getEventType())
.setBytesUnsafe("value", getValue(dataSource.getDeviceId())));
numKeysWritten++;
ts++;
Expand Down Expand Up @@ -280,9 +280,8 @@ public String toString() {
return getDeviceId();
}

public String getEvent_type() {
Random rand = new Random();
return Integer.toString(rand.nextInt(num_event_types));
public String getEventType() {
return Integer.toString(random.nextInt(num_event_types));
}

}
Expand Down

0 comments on commit 01c49bb

Please sign in to comment.