static mrb_value
mrb_grn_index_cursor_class_open_raw(mrb_state *mrb, mrb_value klass)
{
  grn_ctx *ctx = (grn_ctx *)mrb->ud;
  mrb_value mrb_table_cursor;
  mrb_value mrb_index;
  mrb_value mrb_options = mrb_nil_value();
  grn_obj *index_cursor;
  grn_table_cursor *table_cursor;
  grn_obj *index;
  grn_id rid_min = GRN_ID_NIL;
  grn_id rid_max = GRN_ID_MAX;
  int flags = 0;
  mrb_value mrb_index_cursor;

  mrb_get_args(mrb, "oo|H", &mrb_table_cursor, &mrb_index, &mrb_options);

  table_cursor = DATA_PTR(mrb_table_cursor);
  index = DATA_PTR(mrb_index);
  if (!mrb_nil_p(mrb_options)) {
    /* TODO */
  }
  index_cursor = grn_index_cursor_open(ctx, table_cursor, index,
                                       rid_min, rid_max, flags);
  grn_mrb_ctx_check(mrb);

  mrb_index_cursor = mrb_funcall(mrb, klass, "new", 1,
                                 mrb_cptr_value(mrb, index_cursor));
  mrb_iv_set(mrb, mrb_index_cursor, mrb_intern_lit(mrb, "@index"), mrb_index);
  return mrb_index_cursor;
}
/*
 * Opens cursor to iterate posting in the index column.
 *
 * @example
 *   # TODO
 *
 * @overload open_cursor(table_cursor, options={})
 *   @param [TableCursor] The table cursor for table of the index column.
 *   @param [::Hash] options
 *   @option options [Boolean] :with_section (nil)
 *      Includes section info the posting. It is enabled by default if
 *      the index column is created with @:with_section@ flag.
 *   @option options [Boolean] :with_weight (nil)
 *      Includes weight info the posting. It is enabled by default if
 *      the index column is created with @:with_weight@ flag.
 *   @option options [Boolean] :with_position (nil)
 *      Includes position info the posting. It is enabled by default if
 *      the index column is created with @:with_position@ flag.
 */
static VALUE
rb_grn_index_column_open_cursor (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context;
    grn_obj *column;
    grn_obj *range_object;
    grn_table_cursor *table_cursor;
    grn_id rid_min = GRN_ID_NIL;
    grn_id rid_max = GRN_ID_MAX;
    int flags = 0;
    grn_obj *index_cursor;
    VALUE rb_table_cursor;
    VALUE options;
    VALUE rb_with_section, rb_with_weight, rb_with_position;
    VALUE rb_table;
    VALUE rb_lexicon;
    VALUE rb_cursor;

    rb_grn_index_column_deconstruct(SELF(self), &column, &context,
                                    NULL, NULL,
                                    NULL, NULL,
                                    NULL, &range_object,
                                    NULL, NULL);

    rb_scan_args(argc, argv, "11", &rb_table_cursor, &options);
    rb_grn_scan_options(options,
                        "with_section", &rb_with_section,
                        "with_weight", &rb_with_weight,
                        "with_position", &rb_with_position,
                        NULL);

    table_cursor = RVAL2GRNTABLECURSOR(rb_table_cursor, NULL);
    rb_table = GRNOBJECT2RVAL(Qnil, context, range_object, GRN_FALSE);
    rb_lexicon = rb_iv_get(rb_table_cursor, "@table");

    if (NIL_P(rb_with_section)) {
        flags |= column->header.flags & GRN_OBJ_WITH_SECTION;
    } else if (RVAL2CBOOL(rb_with_section)) {
        flags |= GRN_OBJ_WITH_SECTION;
    }

    if (NIL_P(rb_with_weight)) {
        flags |= column->header.flags & GRN_OBJ_WITH_WEIGHT;
    } else if (RVAL2CBOOL(rb_with_weight)) {
        flags |= GRN_OBJ_WITH_WEIGHT;
    }

    if (NIL_P(rb_with_position)) {
        flags |= column->header.flags & GRN_OBJ_WITH_POSITION;
    } else if (RVAL2CBOOL(rb_with_position)) {
        flags |= GRN_OBJ_WITH_POSITION;
    }

    index_cursor = grn_index_cursor_open(context, table_cursor,
                                         column, rid_min, rid_max, flags);

    rb_cursor = GRNINDEXCURSOR2RVAL(context, index_cursor, rb_table, rb_lexicon);

    if (rb_block_given_p())
        return rb_ensure(rb_yield, rb_cursor, rb_grn_object_close, rb_cursor);
    else
        return rb_cursor;
}