Пример #1
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  const Pair items[] = { { "apple", 1 }, { "orange", 2 }, { "banana", 3 }, { "mango", 4 }, { NULL, 0 } };

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                'class': 'SimpleStrategy', 'replication_factor': '3' };");

  execute_query(session,
                "CREATE TABLE examples.maps (key text, \
                items map<text, int>, \
                PRIMARY KEY (key))");


  insert_into_maps(session, "test", items);
  select_from_maps(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #2
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  Basic input = { cass_true, 0.001f, 0.0002, 1, 2 };
  Basic output;
  const CassPrepared* prepared = NULL;
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.basic (key text, \
                                              bln boolean, \
                                              flt float, dbl double,\
                                              i32 int, i64 bigint, \
                                              PRIMARY KEY (key));");

  insert_into_basic(session, "prepared_test", &input);

  if (prepare_select_from_basic(session, &prepared) == CASS_OK) {
    select_from_basic(session, prepared, "prepared_test", &output);

    assert(input.bln == output.bln);
    assert(input.flt == output.flt);
    assert(input.dbl == output.dbl);
    assert(input.i32 == output.i32);
    assert(input.i64 == output.i64);
    cass_prepared_free(prepared);
  }

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #3
0
 inline ~CassandraClusterSession()
 {
     session.clear();  // Should do this before freeing cluster
     if (cluster)
         cass_cluster_free(cluster);
     if (semaphore)
         delete semaphore;
 }
CassDriver::~CassDriver() {
  cass_prepared_free(insert_prepared_);
  cass_prepared_free(select_prepared_);
  cass_prepared_free(delete_prepared_);
  CassFuture* close_future = cass_session_close(session_);
  cass_future_wait(close_future);
  cass_future_free(close_future);
  cass_cluster_free(cluster_);
}
Пример #5
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  Basic input = { cass_true, 0.001f, 0.0002, 1, 2 };
  Basic output;

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.basic (key text, \
                                              bln boolean, \
                                              flt float, dbl double,\
                                              i32 int, i64 bigint, \
                                              PRIMARY KEY (key));");

  insert_into_basic(session, "test", &input);
  select_from_basic(session, "test", &output);

  assert(input.bln == output.bln);
  assert(input.flt == output.flt);
  assert(input.dbl == output.dbl);
  assert(input.i32 == output.i32);
  assert(input.i64 == output.i64);

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #6
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  char* hosts = "127.0.0.1";

  const char* items[] = { "apple", "orange", "banana", "mango", NULL };

  cass_cluster_set_protocol_version(cluster, 2);

  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '1' };");

  execute_query(session,
                "CREATE TABLE examples.collections (key text, \
                                                    items set<text>, \
                                                    PRIMARY KEY (key))");


  insert_into_collections(session, "test", items);
  select_from_collections(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #7
0
static void
php_cassandra_cluster_dtor(php5to7_zend_resource rsrc TSRMLS_DC)
{
  CassCluster *cluster = (CassCluster*) rsrc->ptr;

  if (cluster) {
    cass_cluster_free(cluster);
    CASSANDRA_G(persistent_clusters)--;
    rsrc->ptr = NULL;
  }
}
Пример #8
0
DbConnection::~DbConnection()
{
    if ( session_ )
        cass_session_free( session_ );
    if ( cluster_ )
        cass_cluster_free( cluster_ );
    if ( prepared_insert_ )
        cass_prepared_free( prepared_insert_ );
    if ( prepared_delete_ )
        cass_prepared_free( prepared_delete_ );
}
Пример #9
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  const CassPrepared* prepared = NULL;

  Pair pairs[] = { {"a", "1"}, {"b", "2"}, { NULL, NULL} };

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.pairs (key text, \
                                              value text, \
                                              PRIMARY KEY (key));");

  if (prepare_insert_into_batch(session, &prepared) == CASS_OK) {
    insert_into_batch_with_prepared(session, prepared, pairs);
  }

  cass_prepared_free(prepared);

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #10
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.async (key text, \
                                              bln boolean, \
                                              flt float, dbl double,\
                                              i32 int, i64 bigint, \
                                              PRIMARY KEY (key));");

  execute_query(session, "USE examples");

  insert_into_async(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #11
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' };");


  execute_query(session,
                "CREATE TABLE examples.date_time (key text PRIMARY KEY,  d date, t time)");

  insert_into(session, "test");
  select_from(session, "test");

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);

  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #12
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;

  uuid_gen = cass_uuid_gen_new();

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  schema_meta = cass_session_get_schema_meta(session);

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' }");
Пример #13
0
/**
 * librdf_storage_cassandra_close:
 * @storage: the storage
 *
 * Close the cassandra storage.
 * 
 * Return value: non 0 on failure
 **/
static int
librdf_storage_cassandra_close(librdf_storage* storage)
{

    librdf_storage_cassandra_instance* context;
    context = (librdf_storage_cassandra_instance*)storage->instance;

    if (context->session) {
	cass_session_free(context->session);
	context->session = 0;
    }

    if (context->cluster) {
	cass_cluster_free(context->cluster);
	context->session = 0;
    }

}
Пример #14
0
  /**
   * Cleanup the driver connection
   */
  void cleanup() {
    if (session_) {
      cass_session_free(session_);
      session_ = NULL;
    }

    if (cluster_) {
      cass_cluster_free(cluster_);
      cluster_ = NULL;
    }

    if (connect_future_) {
      cass_future_free(connect_future_);
      connect_future_ = NULL;
    }

    if (ssl_) {
      cass_ssl_free(ssl_);
      ssl_ = NULL;
    }
  }
Пример #15
0
bool Connection::open()
{
	if (_is_open) {
		return true;
	}

	CassCluster* cluster = cass_cluster_new();

	cass_cluster_set_protocol_version(cluster, 2);
	cass_cluster_set_contact_points(cluster, _host_string);
	cass_cluster_set_port(cluster, _port);

	CassFuture* future = cass_cluster_connect(cluster);

	_session = cass_future_get_session(future);
	_is_open = cass_future_error_code(future) == CASS_OK && _session != nullptr;

	cass_future_free(future);
	cass_cluster_free(cluster);

	return _is_open;
}
Пример #16
0
int main(int argc, char* argv[]) {
  CassCluster* cluster = NULL;
  CassSession* session = cass_session_new();
  CassFuture* close_future = NULL;
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }
  cluster = create_cluster(hosts);

  uuid_gen = cass_uuid_gen_new();

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  schema_meta = cass_session_get_schema_meta(session);

  execute_query(session,
                "CREATE KEYSPACE examples WITH replication = { \
                           'class': 'SimpleStrategy', 'replication_factor': '3' }");
Пример #17
0
int main() {
  CassCluster* cluster = create_cluster();
  CassSession* session = cass_session_new();

  uuid_gen = cass_uuid_gen_new();

  uv_mutex_init(&mutex);
  uv_cond_init(&cond);

  connect_session(session, cluster, on_session_connect);

  /* Code running in parallel with queries */

  wait_exit();

  uv_cond_destroy(&cond);
  uv_mutex_destroy(&mutex);

  cass_cluster_free(cluster);
  cass_uuid_gen_free(uuid_gen);
  cass_session_free(session);

  return 0;
}
Пример #18
0
int main(int argc, char* argv[]) {
  /* Setup and connect to cluster */
  CassFuture* connect_future = NULL;
  CassCluster* cluster = cass_cluster_new();
  CassSession* session = cass_session_new();
  CassSsl* ssl = cass_ssl_new();
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }

  cass_cluster_set_contact_points(cluster, hosts);

  /* Only verify the certification and not the identity */
  cass_ssl_set_verify_flags(ssl, CASS_SSL_VERIFY_PEER_CERT);

  if (!load_trusted_cert_file("cert.pem", ssl)) {
    fprintf(stderr, "Failed to load certificate disabling peer verification\n");
    cass_ssl_set_verify_flags(ssl, CASS_SSL_VERIFY_NONE);
  }

  cass_cluster_set_ssl(cluster, ssl);

  connect_future = cass_session_connect(session, cluster);

  if (cass_future_error_code(connect_future) == CASS_OK) {
    CassFuture* close_future = NULL;

    /* Build statement and execute query */
    const char* query = "SELECT release_version FROM system.local";
    CassStatement* statement = cass_statement_new(query, 0);

    CassFuture* result_future = cass_session_execute(session, statement);

    if (cass_future_error_code(result_future) == CASS_OK) {
      /* Retrieve result set and get the first row */
      const CassResult* result = cass_future_get_result(result_future);
      const CassRow* row = cass_result_first_row(result);

      if (row) {
        const CassValue* value = cass_row_get_column_by_name(row, "release_version");

        const char* release_version;
        size_t release_version_length;
        cass_value_get_string(value, &release_version, &release_version_length);
        printf("release_version: '%.*s'\n", (int)release_version_length,
               release_version);
      }

      cass_result_free(result);
    } else {
      /* Handle error */
      const char* message;
      size_t message_length;
      cass_future_error_message(result_future, &message, &message_length);
      fprintf(stderr, "Unable to run query: '%.*s'\n", (int)message_length,
                                                            message);
    }

    cass_statement_free(statement);
    cass_future_free(result_future);

    /* Close the session */
    close_future = cass_session_close(session);
    cass_future_wait(close_future);
    cass_future_free(close_future);
  } else {
      /* Handle error */
      const char* message;
      size_t message_length;
      cass_future_error_message(connect_future, &message, &message_length);
      fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length,
                                                          message);
  }

  cass_future_free(connect_future);
  cass_cluster_free(cluster);
  cass_session_free(session);
  cass_ssl_free(ssl);

  return 0;
}
Пример #19
0
/* functions implementing storage api */
static int
librdf_storage_cassandra_init(librdf_storage* storage, const char *name,
                           librdf_hash* options)
{

    char *name_copy;
    librdf_storage_cassandra_instance* context;
  
    if(!name) {
	if(options)
	    librdf_free_hash(options);
	return 1;
    }
  
    context = LIBRDF_CALLOC(librdf_storage_cassandra_instance*, 1,
			    sizeof(*context));
    if(!context) {
	if(options)
	    librdf_free_hash(options);
	return 1;
    }

    librdf_storage_set_instance(storage, context);
  
    context->storage = storage;
    context->name_len = strlen(name);
//    context->transaction = 0;

    name_copy = LIBRDF_MALLOC(char*, context->name_len + 1);
    if(!name_copy) {
	if(options)
	    librdf_free_hash(options);
	return 1;
    }

    strcpy(name_copy, name);
    context->name = name_copy;

    // Add options here.

    /* no more options, might as well free them now */
    if(options)
	librdf_free_hash(options);

    // FIXME: Hard-coded;
    context->session = cass_session_new();
    context->cluster = cass_cluster_new();

    cass_cluster_set_contact_points(context->cluster, name);

    CassFuture* future = cass_session_connect(context->session,
					      context->cluster);

    CassError rc = cass_future_error_code(future);
    if (rc != CASS_OK) {
	fprintf(stderr, "Cassandra: %s\n", cass_error_desc(rc));
	cass_cluster_free(context->cluster);
	cass_session_free(context->session);
	free(context->name);
	free(context);
	return 1;
    }

    cass_future_free(future);

    return 0;

}
Пример #20
0
void CassandraClient::close() {
    logger.information("Closing down cluster connection");
    cass_session_close(session);
    cass_cluster_free(cluster);
}
Пример #21
0
int main() {
  int i;
  CassMetrics metrics;
  uv_thread_t threads[NUM_THREADS];
  CassCluster* cluster = NULL;
  CassSession* session = NULL;
  CassFuture* close_future = NULL;

  status_init(&status, NUM_THREADS);

  cass_log_set_level(CASS_LOG_INFO);

  cluster = create_cluster();
  uuid_gen = cass_uuid_gen_new();
  session = cass_session_new();

  if (connect_session(session, cluster) != CASS_OK) {
    cass_cluster_free(cluster);
    cass_session_free(session);
    return -1;
  }

  execute_query(session,
                "INSERT INTO songs (id, title, album, artist, tags) VALUES "
                "(a98d21b2-1900-11e4-b97b-e5e358e71e0d, "
                "'La Petite Tonkinoise', 'Bye Bye Blackbird', 'Joséphine Baker', { 'jazz', '2013' });");


  for (i = 0; i < NUM_THREADS; ++i) {
#if DO_SELECTS
    uv_thread_create(&threads[i], run_select_queries, (void*)session);
#else
    uv_thread_create(&threads[i], run_insert_queries, (void*)session);
#endif
  }

  while (status_wait(&status, 5) > 0) {
    cass_session_get_metrics(session, &metrics);
    printf("rate stats (requests/second): mean %f 1m %f 5m %f 10m %f\n",
           metrics.requests.mean_rate,
           metrics.requests.one_minute_rate,
           metrics.requests.five_minute_rate,
           metrics.requests.fifteen_minute_rate);
  }

  cass_session_get_metrics(session, &metrics);
  printf("final stats (microseconds): min %llu max %llu median %llu 75th %llu 95th %llu 98th %llu 99th %llu 99.9th %llu\n",
         (unsigned long long int)metrics.requests.min, (unsigned long long int)metrics.requests.max,
         (unsigned long long int)metrics.requests.median, (unsigned long long int)metrics.requests.percentile_75th,
         (unsigned long long int)metrics.requests.percentile_95th, (unsigned long long int)metrics.requests.percentile_98th,
         (unsigned long long int)metrics.requests.percentile_99th, (unsigned long long int)metrics.requests.percentile_999th);

  for (i = 0; i < NUM_THREADS; ++i) {
    uv_thread_join(&threads[i]);
  }

  close_future = cass_session_close(session);
  cass_future_wait(close_future);
  cass_future_free(close_future);
  cass_cluster_free(cluster);
  cass_uuid_gen_free(uuid_gen);

  status_destroy(&status);

  return 0;
}
Пример #22
0
MultipleNodesTest::~MultipleNodesTest() {
  cass_uuid_gen_free(uuid_gen);
  cass_cluster_free(cluster);
}
Пример #23
0
int main(int argc, char* argv[]) {
  /* Setup and connect to cluster */
  CassFuture* connect_future = NULL;
  CassCluster* cluster = cass_cluster_new();
  CassSession* session = cass_session_new();
  char* hosts = "127.0.0.1";
  if (argc > 1) {
    hosts = argv[1];
  }

  /* Add contact points */
  cass_cluster_set_contact_points(cluster, hosts);

  /* Provide the cluster object as configuration to connect the session */
  connect_future = cass_session_connect(session, cluster);

  if (cass_future_error_code(connect_future) == CASS_OK) {
    CassFuture* close_future = NULL;

    /* Build statement and execute query */
    const char* query = "SELECT keyspace_name "
                        "FROM system.schema_keyspaces;";
    CassStatement* statement = cass_statement_new(query, 0);

    CassFuture* result_future = cass_session_execute(session, statement);

    if (cass_future_error_code(result_future) == CASS_OK) {
      /* Retrieve result set and iterate over the rows */
      const CassResult* result = cass_future_get_result(result_future);
      CassIterator* rows = cass_iterator_from_result(result);

      while (cass_iterator_next(rows)) {
        const CassRow* row = cass_iterator_get_row(rows);
        const CassValue* value = cass_row_get_column_by_name(row, "keyspace_name");

        const char* keyspace_name;
        size_t keyspace_name_length;
        cass_value_get_string(value, &keyspace_name, &keyspace_name_length);
        printf("keyspace_name: '%.*s'\n", (int)keyspace_name_length,
                                               keyspace_name);
      }

      cass_result_free(result);
      cass_iterator_free(rows);
    } else {
      /* Handle error */
      const char* message;
      size_t message_length;
      cass_future_error_message(result_future, &message, &message_length);
      fprintf(stderr, "Unable to run query: '%.*s'\n", (int)message_length,
                                                            message);
    }

    cass_statement_free(statement);
    cass_future_free(result_future);

    /* Close the session */
    close_future = cass_session_close(session);
    cass_future_wait(close_future);
    cass_future_free(close_future);
  } else {
    /* Handle error */
    const char* message;
    size_t message_length;
    cass_future_error_message(connect_future, &message, &message_length);
    fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length,
                                                        message);
  }

  cass_future_free(connect_future);
  cass_cluster_free(cluster);
  cass_session_free(session);

  return 0;
}
Пример #24
0
int main() { 
	char sql[1024];
	time_t start, stop;

	FILE *fp = fopen("/Users/carybourgeois/flights_exercise/flights_from_pg.csv", "r") ; 
	
	CassError rc = CASS_OK;
	CassCluster* cluster = create_cluster();
	CassSession* session = NULL;
	CassFuture* close_future = NULL;

	rc = connect_session(cluster, &session);
	if(rc != CASS_OK) {
		return -1;
	}
	
	execute_stmt(session, 
					"CREATE KEYSPACE IF NOT EXISTS exercise WITH \
						replication = {'class': 'SimpleStrategy','replication_factor': '1'};");
						
	execute_stmt(session,
					"USE exercise;");
						
	execute_stmt(session,
					"DROP TABLE IF EXISTS flights;");
					
	execute_stmt(session,
					"CREATE TABLE flights ( \
						id int, year int, day_of_month int, fl_date varchar, \
						airline_id int, carrier varchar, fl_num int, origin_airport_id int, \
						origin varchar, origin_city_name varchar, origin_state_abr varchar, dest varchar, \
						dest_city_name varchar, dest_state_abr varchar, dep_time int, arr_time int, \
						actual_elapsed_time int, air_time int, distance int, air_time_grp int, \
						PRIMARY KEY (carrier, origin, air_time_grp, id));");

 	time(&start);
 	
 	if ( fp != NULL ) {
 		int i = 0;  
   		while(!feof(fp)) {           
        	i++;
                  
   			fscanf(fp, "%d, %d, %d, %[^,], %d, %[^,], %d, %d, %[^,], %[^,], %[^,], %[^,], %[^,], %[^,], %d, %d, %d, %d, %d \n", 
      			&Flight.id, &Flight.year, &Flight.day_of_month, Flight.fl_date, 
      			&Flight.airline_id, Flight.carrier, &Flight.fl_num, &Flight.origin_airport_id,
      			Flight.origin, Flight.origin_city_name, Flight.origin_state_abr, Flight.dest,
      			Flight.dest_city_name, Flight.dest_state_abr, &Flight.dep_time, &Flight.arr_time,
      			&Flight.actual_elapsed_time, &Flight.air_time, &Flight.distance);
      
    		sprintf(sql, "INSERT INTO flights (id, year, day_of_month, fl_date, airline_id, carrier, fl_num, origin_airport_id, origin, origin_city_name, origin_state_abr, dest, dest_city_name, dest_state_abr, dep_time, arr_time, actual_elapsed_time, air_time, distance, air_time_grp) VALUES (%d, %d, %d, \'%s\', %d, \'%s\', %d, %d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', %d, %d, %d, %d, %d, %d);\n", 
        		Flight.id, Flight.year, Flight.day_of_month, Flight.fl_date, 
      			Flight.airline_id, Flight.carrier, Flight.fl_num, Flight.origin_airport_id,
      			Flight.origin, Flight.origin_city_name, Flight.origin_state_abr, Flight.dest,
      			Flight.dest_city_name, Flight.dest_state_abr, Flight.dep_time, Flight.arr_time,
      			Flight.actual_elapsed_time, Flight.air_time, Flight.distance, Flight.air_time/10 );
      			
      		/* printf("%s", sql); */
      		execute_stmt(session, sql);
           
        	/* if (i > 999) break; */
                               
		}  /* EOF */ 
		printf("%d Records loaded.\n", i);
   
	}  /* File exists */ 
	
	time(&stop);
 
    printf("%.f Seconds total load time.\n", difftime(start, stop));   
   
	close_future = cass_session_close(session);
  	cass_future_wait(close_future);
	cass_future_free(close_future);
	cass_cluster_free(cluster);
	
	fclose( fp ); 
	
	return 0;   
  
}
Пример #25
0
 void operator()(CassCluster* ptr) {
   if (ptr != NULL) {
     cass_cluster_free(ptr);
   }
 }