class Rubydex::Query
Public Class Methods
static VALUE rdxr_query_parse(VALUE klass, VALUE query) {
Check_Type(query, T_STRING);
struct CParseResult result = rdx_cypher_parse(StringValueCStr(query));
if (result.error != NULL) {
raise_query_error(result.error, result.error_kind);
}
return TypedData_Wrap_Struct(klass, &query_type, result.query);
}
Parses a Cypher query into an opaque, reusable object without needing a graph. Raises Rubydex::QuerySyntaxError on a syntax error, so a query can be validated before building a graph.
static VALUE rdxr_cypher_schema(int argc, VALUE *argv, VALUE self) {
VALUE format;
rb_scan_args(argc, argv, "01", &format);
const char *output = rdx_cypher_schema(rdxi_symbol_or_string_cstr(format, "table"));
VALUE result = output == NULL ? rb_utf8_str_new_cstr("") : rb_utf8_str_new_cstr(output);
if (output != NULL) {
free_c_string(output);
}
return result;
}
Returns a description of the queryable Cypher schema. format may be :table (default) or :json. The schema is static, so it does not require a graph.
Public Instance Methods
static VALUE rdxr_query_run(VALUE self, VALUE graph_obj) {
void *query;
TypedData_Get_Struct(self, void *, &query_type, query);
// Wrap first, so the result set has an owner that frees it even if a later step raises.
QueryResultData *data;
VALUE result = TypedData_Make_Struct(cQueryResult, QueryResultData, &query_result_type, data);
data->result_set = NULL;
data->graph_obj = graph_obj;
data->rows = Qnil;
struct CExecuteResult executed = rdx_query_execute(query, rdxi_graph_from_object(graph_obj));
if (executed.error != NULL) {
raise_query_error(executed.error, executed.error_kind);
}
data->result_set = executed.result_set;
return result;
}
Runs this parsed query against graph exactly once and returns the result set. Read it as Ruby objects with Rubydex::Query::Result#rows, or format it with Rubydex::Query::Result#render. Raises Rubydex::QueryExecutionError when the query fails against the graph.