Class: Ilios::Cassandra::Result
- Inherits:
-
Object
- Object
- Ilios::Cassandra::Result
- Includes:
- Enumerable
- Defined in:
- ext/ilios/ilios.c
Instance Method Summary collapse
-
#each ⇒ Cassandra::Result, Enumerator
Yield the row of result into a block.
-
#next_page ⇒ Cassandra::Result?
Loads next page synchronously.
Instance Method Details
#each ⇒ Cassandra::Result, Enumerator
Yield the row of result into a block.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'ext/ilios/result.c', line 305 static VALUE result_each(VALUE self) { CassandraResult *cassandra_result; CassIterator *iterator; struct result_each_arg args; RETURN_ENUMERATOR(self, 0, 0); GET_RESULT(self, cassandra_result); iterator = cass_iterator_from_result(cassandra_result->result); args.cassandra_result = cassandra_result; args.iterator = iterator; rb_ensure(result_each_body, (VALUE)&args, result_each_ensure, (VALUE)iterator); return self; } |
#next_page ⇒ Cassandra::Result?
Loads next page synchronously
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'ext/ilios/result.c', line 41 static VALUE result_next_page(VALUE self) { CassandraResult *cassandra_result; CassandraStatement *cassandra_statement; CassandraSession *cassandra_session; CassFuture *result_future; CassError error_code; GET_RESULT(self, cassandra_result); if (cass_result_has_more_pages(cassandra_result->result) == cass_false) { return Qnil; } GET_STATEMENT(cassandra_result->statement_obj, cassandra_statement); GET_SESSION(cassandra_statement->session_obj, cassandra_session); // Reuse this result's own executed statement: it is not shared with other // executions and its previous request has already completed, so setting // the paging state cannot race with the driver's IO thread. cass_statement_set_paging_state(cassandra_result->executed_statement, cassandra_result->result); result_future = nogvl_session_execute(cassandra_session->session, cassandra_result->executed_statement); nogvl_future_wait(result_future); error_code = cass_future_error_code(result_future); if (error_code != CASS_OK) { VALUE error = ilios_future_error_new(eExecutionError, "Unable to wait executing", result_future); cass_future_free(result_future); rb_exc_raise(error); } cass_result_free(cassandra_result->result); if (cassandra_result->future) { cass_future_free(cassandra_result->future); } cassandra_result->result = cass_future_get_result(result_future); cassandra_result->future = result_future; return self; } |