Class: Ilios::Cassandra::Statement

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

Instance Method Summary collapse

Instance Method Details

#bind(hash) ⇒ Object



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'ext/ilios/statement.c', line 231

static VALUE statement_bind(VALUE self, VALUE hash)
{
    CassandraStatement *cassandra_statement;
    statement_bind_context ctx;
    VALUE bound_values;

    Check_Type(hash, T_HASH);
    TypedData_Get_Struct(self, CassandraStatement, &cassandra_statement_data_type, cassandra_statement);

    // Merge into a copy instead of mutating in place: the previous hash may be
    // shared with a frozen (Ractor-shareable) statement or be iterated by an
    // execution on another thread.
    if (NIL_P(cassandra_statement->bound_values)) {
        bound_values = rb_hash_new();
    } else {
        bound_values = rb_hash_dup(cassandra_statement->bound_values);
    }
    RB_OBJ_WRITE(self, &cassandra_statement->bound_values, bound_values);

    ctx.prepared = cassandra_statement->prepared;
    ctx.statement = cassandra_statement->statement;
    ctx.bound_values = bound_values;

    rb_hash_foreach(hash, hash_cb, (VALUE)&ctx);
    return self;
}

#idempotent=(idempotent) ⇒ Object



282
283
284
285
286
287
288
289
290
# File 'ext/ilios/statement.c', line 282

static VALUE statement_idempotent(VALUE self, VALUE idempotent)
{
    CassandraStatement *cassandra_statement;

    GET_STATEMENT(self, cassandra_statement);
    cassandra_statement->idempotent = RTEST(idempotent) ? idempotency_true : idempotency_false;
    cass_statement_set_is_idempotent(cassandra_statement->statement, cassandra_statement->idempotent == idempotency_true ? cass_true : cass_false);
    return self;
}

#page_size=(page_size) ⇒ Object



264
265
266
267
268
269
270
271
272
# File 'ext/ilios/statement.c', line 264

static VALUE statement_page_size(VALUE self, VALUE page_size)
{
    CassandraStatement *cassandra_statement;

    GET_STATEMENT(self, cassandra_statement);
    cassandra_statement->page_size = NUM2INT(page_size);
    cass_statement_set_paging_size(cassandra_statement->statement, cassandra_statement->page_size);
    return self;
}