1919from threading import Thread
2020import time
2121from optparse import OptionParser
22+ import uuid
2223
2324from greplin import scales
2425
5960KEYSPACE = "testkeyspace" + str (int (time .time ()))
6061TABLE = "testtable"
6162
63+ COLUMN_VALUES = {
64+ 'int' : 42 ,
65+ 'text' : "'42'" ,
66+ 'float' : 42.0 ,
67+ 'uuid' : uuid .uuid4 (),
68+ 'timestamp' : "'2016-02-03 04:05+0000'"
69+ }
70+
6271
6372def setup (options ):
6473 log .info ("Using 'cassandra' package from %s" , cassandra .__path__ )
@@ -82,7 +91,7 @@ def setup(options):
8291 thekey text,
8392 """
8493 for i in range (options .num_columns ):
85- create_table_query += "col{} text ,\n " .format (i )
94+ create_table_query += "col{} {} ,\n " .format (i , options . column_type )
8695 create_table_query += "PRIMARY KEY (thekey))"
8796
8897 session .execute (create_table_query .format (TABLE ))
@@ -122,7 +131,7 @@ def benchmark(thread_class):
122131 insert_query += ") VALUES ('{}'" .format ('key' )
123132
124133 for i in range (options .num_columns ):
125- insert_query += ", '{}' " .format (i )
134+ insert_query += ", {} " .format (COLUMN_VALUES [ options . column_type ] )
126135 insert_query += ")"
127136
128137 values = None
@@ -206,6 +215,9 @@ def parse_options():
206215 help = 'Specify the keyspace name for the schema' )
207216 parser .add_option ('--keep-data' , action = 'store_true' , dest = 'keep_data' , default = False ,
208217 help = 'Keep the data after the benchmark' )
218+ parser .add_option ('--column-type' , type = 'str' , dest = 'column_type' , default = 'text' ,
219+ help = 'Specify the column type for the schema (supported: int, text, float, uuid, timestamp)' )
220+
209221
210222 options , args = parser .parse_args ()
211223
0 commit comments