From 01c49bb7e696d6ae82001c62ef74bac434efcbea Mon Sep 17 00:00:00 2001 From: ameyb Date: Tue, 6 Aug 2019 14:53:06 -0500 Subject: [PATCH] Updated minor changes for syntax and comments for variables used based on PR review #16 --- .../java/com/yugabyte/sample/apps/AppConfig.java | 4 ++-- .../yugabyte/sample/apps/CassandraEventData.java | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/yugabyte/sample/apps/AppConfig.java b/src/main/java/com/yugabyte/sample/apps/AppConfig.java index 35a6495..7908d28 100644 --- a/src/main/java/com/yugabyte/sample/apps/AppConfig.java +++ b/src/main/java/com/yugabyte/sample/apps/AppConfig.java @@ -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; diff --git a/src/main/java/com/yugabyte/sample/apps/CassandraEventData.java b/src/main/java/com/yugabyte/sample/apps/CassandraEventData.java index 6976458..0024082 100644 --- a/src/main/java/com/yugabyte/sample/apps/CassandraEventData.java +++ b/src/main/java/com/yugabyte/sample/apps/CassandraEventData.java @@ -69,7 +69,7 @@ public class CassandraEventData extends AppBase { static List dataSources = new CopyOnWriteArrayList(); // 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; @@ -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); } } @@ -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); @@ -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++; @@ -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)); } }