@@ -256,7 +256,14 @@ get_key_response client::get_key_for_conn(unsigned int command_index, unsigned i
256256 iter = obj_iter_type (m_config, command_index);
257257
258258 *key_index = m_obj_gen->get_key_index (iter);
259- m_key_len = snprintf (m_key_buffer, sizeof (m_key_buffer)-1 , " %s%llu" , m_obj_gen->get_key_prefix (), *key_index);
259+
260+ if (!m_config->data_import || m_config->generate_keys ) {
261+ m_obj_gen->generate_key (*key_index);
262+ } else {
263+ /* For SET command we already read a completes item (see create_set_request()) */
264+ if (command_index == GET_CMD_IDX)
265+ dynamic_cast <import_object_generator*>(m_obj_gen)->read_next_key (*key_index);
266+ }
260267
261268 return available_for_conn;
262269}
@@ -277,7 +284,7 @@ bool client::create_arbitrary_request(unsigned int command_index, struct timeval
277284 get_key_response res = get_key_for_conn (command_index, conn_id, &key_index);
278285 /* If key not available for this connection, we have a bug of sending partial request */
279286 assert (res == available_for_conn);
280- cmd_size += m_connections[conn_id]->send_arbitrary_command (arg, m_key_buffer, m_key_len );
287+ cmd_size += m_connections[conn_id]->send_arbitrary_command (arg, m_obj_gen-> get_key (), m_obj_gen-> get_key_len () );
281288 } else if (arg->type == data_type) {
282289 unsigned int value_len;
283290 const char *value = m_obj_gen->get_value (0 , &value_len);
@@ -313,7 +320,7 @@ bool client::create_set_request(struct timeval& timestamp, unsigned int conn_id)
313320 unsigned int value_len;
314321 const char *value = m_obj_gen->get_value (key_index, &value_len);
315322
316- m_connections[conn_id]->send_set_command (×tamp, m_key_buffer, m_key_len ,
323+ m_connections[conn_id]->send_set_command (×tamp, m_obj_gen-> get_key (), m_obj_gen-> get_key_len () ,
317324 value, value_len, m_obj_gen->get_expiry (),
318325 m_config->data_offset );
319326 }
@@ -328,7 +335,7 @@ bool client::create_get_request(struct timeval& timestamp, unsigned int conn_id)
328335 return false ;
329336
330337 if (res == available_for_conn) {
331- m_connections[conn_id]->send_get_command (×tamp, m_key_buffer, m_key_len , m_config->data_offset );
338+ m_connections[conn_id]->send_get_command (×tamp, m_obj_gen-> get_key (), m_obj_gen-> get_key_len () , m_config->data_offset );
332339 }
333340
334341 return true ;
@@ -346,7 +353,7 @@ bool client::create_mget_request(struct timeval& timestamp, unsigned int conn_id
346353 /* Not supported in cluster mode */
347354 assert (res == available_for_conn);
348355
349- m_keylist->add_key (m_key_buffer, m_key_len );
356+ m_keylist->add_key (m_obj_gen-> get_key (), m_obj_gen-> get_key_len () );
350357 }
351358
352359 m_connections[conn_id]->send_mget_command (×tamp, m_keylist);
@@ -378,6 +385,11 @@ void client::create_request(struct timeval timestamp, unsigned int conn_id)
378385
379386 // are we set or get? this depends on the ratio
380387 else if (m_set_ratio_count < m_config->ratio .a ) {
388+ /* Before we can create a SET request, we need to read the next imported item */
389+ if (m_config->data_import ) {
390+ dynamic_cast <import_object_generator*>(m_obj_gen)->read_next_item ();
391+ }
392+
381393 if (!create_set_request (timestamp, conn_id))
382394 return ;
383395
@@ -482,57 +494,51 @@ unsigned long long int verify_client::get_errors(void)
482494 return m_errors;
483495}
484496
485- void verify_client::create_request (struct timeval timestamp, unsigned int conn_id)
486- {
487- // TODO: Refactor client::create_request so this can be unified.
488- if (m_set_ratio_count < m_config->ratio .a ) {
489- // Prepare a GET request that will be compared against a previous
490- // SET request.
491- data_object *obj = m_obj_gen->get_object (obj_iter_type (m_config, 0 ));
492- unsigned int key_len;
493- const char *key = obj->get_key (&key_len);
497+ bool verify_client::create_wait_request (struct timeval & timestamp, unsigned int conn_id) {
498+ // Nothing to do
499+ return true ;
500+ }
501+
502+ bool verify_client::create_set_request (struct timeval & timestamp, unsigned int conn_id) {
503+ unsigned long long key_index;
504+ get_key_response res = get_key_for_conn (SET_CMD_IDX, conn_id, &key_index);
505+ if (res == not_available)
506+ return false ;
507+
508+ if (res == available_for_conn) {
494509 unsigned int value_len;
495- const char *value = obj ->get_value (&value_len);
510+ const char *value = m_obj_gen ->get_value (key_index, &value_len);
496511
497- m_connections[conn_id]->send_verify_get_command (×tamp, key, key_len ,
498- value, value_len, obj-> get_expiry (),
512+ m_connections[conn_id]->send_verify_get_command (×tamp, m_obj_gen-> get_key (), m_obj_gen-> get_key_len () ,
513+ value, value_len,
499514 m_config->data_offset );
515+ }
500516
501- m_set_ratio_count++;
502- } else if (m_get_ratio_count < m_config->ratio .b ) {
503- // We don't really care about GET operations, all we do here is keep
504- // the object generator synced.
505- int iter = obj_iter_type (m_config, 2 );
506-
507- if (m_config->multi_key_get > 0 ) {
508- unsigned int keys_count;
517+ return true ;
518+ }
509519
510- keys_count = m_config->ratio .b - m_get_ratio_count;
511- if ((int )keys_count > m_config->multi_key_get )
512- keys_count = m_config->multi_key_get ;
513- m_keylist->clear ();
514- while (m_keylist->get_keys_count () < keys_count) {
515- unsigned int keylen;
516- const char *key = m_obj_gen->get_key (iter, &keylen);
520+ bool verify_client::create_get_request (struct timeval & timestamp, unsigned int conn_id) {
521+ // Just Keep object generator synced
522+ unsigned long long key_index;
523+ get_key_for_conn (GET_CMD_IDX, conn_id, &key_index);
517524
518- assert (key != NULL ) ;
519- assert (keylen > 0 );
525+ return true ;
526+ }
520527
521- m_keylist->add_key (key, keylen);
522- }
528+ bool verify_client::create_mget_request (struct timeval & timestamp, unsigned int conn_id) {
529+ // Just Keep object generator synced
530+ unsigned long long key_index;
531+ unsigned int keys_count = m_config->ratio .b - m_get_ratio_count;
532+ if ((int )keys_count > m_config->multi_key_get )
533+ keys_count = m_config->multi_key_get ;
523534
524- m_get_ratio_count += keys_count;
525- } else {
526- unsigned int keylen;
527- m_obj_gen->get_key (iter, &keylen);
528- m_get_ratio_count++;
529- }
535+ m_keylist->clear ();
536+ for (unsigned int i = 0 ; i < keys_count; i++) {
530537
531- // We don't really send this request, but need to count it to be in sync.
532- m_reqs_processed++;
533- } else {
534- m_get_ratio_count = m_set_ratio_count = 0 ;
538+ get_key_for_conn (GET_CMD_IDX, conn_id, &key_index);
535539 }
540+
541+ return true ;
536542}
537543
538544void verify_client::handle_response (unsigned int conn_id, struct timeval timestamp,
0 commit comments