Class: Ilios::Cassandra::Result

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
ext/ilios/ilios.c

Instance Method Summary collapse

Instance Method Details

#eachObject



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'ext/ilios/result.c', line 233

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_pageObject



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
# File 'ext/ilios/result.c', line 42

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) {
        cass_future_free(result_future);
        rb_raise(eExecutionError, "Unable to wait executing: %s", cass_error_desc(error_code));
    }

    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;
}