• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rb_grn_context_check函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rb_grn_context_check函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_grn_context_check函数的具体用法?C++ rb_grn_context_check怎么用?C++ rb_grn_context_check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rb_grn_context_check函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rb_grn_patricia_trie_prefix_search

/*
 * call-seq:
 *   patricia_trie.prefix_search(prefix) -> Groonga::Hash
 *
 * キーが_prefix_に前方一致するレコードのIDがキーに入っている
 * Groonga::Hashを返す。マッチするレコードがない場合は空の
 * Groonga::Hashが返る。
 *
 */
static VALUE
rb_grn_patricia_trie_prefix_search (VALUE self, VALUE rb_prefix)
{
    grn_ctx *context;
    grn_obj *table, *key, *domain, *result;
    grn_id domain_id;
    VALUE rb_result;

    rb_grn_table_key_support_deconstruct(SELF(self), &table, &context,
					 &key, &domain_id, &domain,
					 NULL, NULL, NULL,
					 NULL);

    result = grn_table_create(context, NULL, 0, NULL,
			      GRN_OBJ_TABLE_HASH_KEY,
			      table, 0);
    rb_grn_context_check(context, self);
    rb_result = GRNOBJECT2RVAL(Qnil, context, result, GRN_TRUE);

    GRN_BULK_REWIND(key);
    RVAL2GRNKEY(rb_prefix, context, key, domain_id, domain, self);
    grn_pat_prefix_search(context, (grn_pat *)table,
			  GRN_BULK_HEAD(key), GRN_BULK_VSIZE(key),
			  (grn_hash *)result);
    rb_grn_context_check(context, self);

    return rb_result;
}
开发者ID:mallowlabs,项目名称:rroonga,代码行数:37,代码来源:rb-grn-patricia-trie.c


示例2: rb_grn_array_s_create

/*
 * call-seq:
 *   Groonga::Array.create(options={})                -> Groonga::Array
 *   Groonga::Array.create(options={}) {|table| ... }
 *
 * キーのないテーブルを生成する。ブロックを指定すると、そのブ
 * ロックに生成したテーブルが渡され、ブロックを抜けると自動的
 * にテーブルが破棄される。
 *
 * @example
 *   #無名一時テーブルを生成する。
 *   Groonga::Array.create
 *
 *   #無名永続テーブルを生成する。
 *   Groonga::Array.create(:path => "/tmp/array.grn")
 *
 *   #名前付き永続テーブルを生成する。ただし、ファイル名は気にしない。
 *   Groonga::Array.create(:name => "Bookmarks",
 *                         :persistent => true)
 *
 *   #それぞれのレコードに512バイトの値を格納できる無名一時テーブルを生成する。
 *   Groonga::Array.create(:value => 512)
 *
 * @param [::Hash] options The name and value
 *   pairs. Omitted names are initialized as the default value.
 * @option options [Grrnga::Context] :context (Groonga::Context.default) The context
 *   テーブルが利用するGrrnga::Context
 * @option options :name The name
 *   テーブルの名前。名前をつけると、Groonga::Context#[]に名
 *   前を指定してテーブルを取得することができる。省略すると
 *   無名テーブルになり、テーブルIDでのみ取得できる。
 * @option options :path The path
 *   テーブルを保存するパス。パスを指定すると永続テーブルとな
 *   り、プロセス終了後もレコードは保持される。次回起動時に
 *   Groonga::Context#[]で保存されたレコードを利用することが
 *   できる。省略すると一時テーブルになり、プロセスが終了する
 *   とレコードは破棄される。
 * @option options :persistent The persistent
 *   +true+ を指定すると永続テーブルとなる。 +path+ を省略した
 *   場合は自動的にパスが付加される。 +:context+ で指定した
 *   Groonga::Contextに結びついているデータベースが一時デー
 *   タベースの場合は例外が発生する。
 * @option options :value_type (nil) The value_type
 *   値の型を指定する。省略すると値のための領域を確保しない。
 *   値を保存したい場合は必ず指定すること。
 *   参考: Groonga::Type.new
 * @option options [Groonga::Record#n_sub_records] :sub_records The sub_records
 *   +true+ を指定すると#groupでグループ化したときに、
 *   Groonga::Record#n_sub_recordsでグループに含まれるレコー
 *   ドの件数を取得できる。
 */
static VALUE
rb_grn_array_s_create (int argc, VALUE *argv, VALUE klass)
{
    grn_ctx *context = NULL;
    grn_obj *value_type = NULL, *table;
    const char *name = NULL, *path = NULL;
    unsigned name_size = 0;
    grn_obj_flags flags = GRN_OBJ_TABLE_NO_KEY;
    VALUE rb_table;
    VALUE options, rb_context, rb_name, rb_path, rb_persistent;
    VALUE rb_value_type, rb_sub_records;

    rb_scan_args(argc, argv, "01", &options);

    rb_grn_scan_options(options,
			"context", &rb_context,
			"name", &rb_name,
                        "path", &rb_path,
			"persistent", &rb_persistent,
			"value_type", &rb_value_type,
			"sub_records", &rb_sub_records,
			NULL);

    context = rb_grn_context_ensure(&rb_context);

    if (!NIL_P(rb_name)) {
        name = StringValuePtr(rb_name);
	name_size = RSTRING_LEN(rb_name);
	flags |= GRN_OBJ_PERSISTENT;
    }

    if (!NIL_P(rb_path)) {
        path = StringValueCStr(rb_path);
	flags |= GRN_OBJ_PERSISTENT;
    }

    if (RVAL2CBOOL(rb_persistent))
	flags |= GRN_OBJ_PERSISTENT;

    if (!NIL_P(rb_value_type))
	value_type = RVAL2GRNOBJECT(rb_value_type, &context);

    if (RVAL2CBOOL(rb_sub_records))
	flags |= GRN_OBJ_WITH_SUBREC;

    table = grn_table_create(context, name, name_size, path,
			     flags, NULL, value_type);
    if (!table)
	rb_grn_context_check(context, rb_ary_new4(argc, argv));
//.........这里部分代码省略.........
开发者ID:iwaim,项目名称:rroonga,代码行数:101,代码来源:rb-grn-array.c


示例3: rb_grn_config_set

/*
 * Sets a configuration key and value pair.
 *
 * @overload config[]=(key, value)
 *   @param [String] key The key.
 *   @param [String] value The value to be assigned.
 *   @return [String] `value`.
 */
static VALUE
rb_grn_config_set (VALUE self, VALUE rb_key, VALUE rb_value)
{
    VALUE rb_value_original = rb_value;
    VALUE rb_context;
    grn_ctx *context;
    const char *key;
    int key_size;
    const char *value;
    int value_size;

    rb_context = rb_iv_get(self, "@context");
    context = rb_grn_context_ensure(&rb_context);

    rb_key = rb_grn_convert_to_string(rb_key);
    key = RSTRING_PTR(rb_key);
    key_size = RSTRING_LEN(rb_key);

    rb_value = rb_grn_convert_to_string(rb_value);
    value = RSTRING_PTR(rb_value);
    value_size = RSTRING_LEN(rb_value);

    {
        grn_rc rc;
        rc = grn_config_set(context,
                            key, key_size,
                            value, value_size);
        rb_grn_context_check(context, self);
        rb_grn_rc_check(rc, self);
    }

    return rb_value_original;
}
开发者ID:mtsmfm,项目名称:rroonga,代码行数:41,代码来源:rb-grn-config.c


示例4: rb_grn_config_get

/*
 * Gets a configuration value for key.
 *
 * @overload config[](key)
 *   @param [String] key The key.
 *   @return [String, nil] The value associated with `key`.
 *
 * @since 5.0.9
 */
static VALUE
rb_grn_config_get (VALUE self, VALUE rb_key)
{
    VALUE rb_context;
    VALUE rb_value;
    grn_ctx *context;
    const char *key;
    int key_size;
    const char *value;
    uint32_t value_size;

    rb_context = rb_iv_get(self, "@context");
    context = rb_grn_context_ensure(&rb_context);

    rb_key = rb_grn_convert_to_string(rb_key);
    key = RSTRING_PTR(rb_key);
    key_size = RSTRING_LEN(rb_key);

    {
        grn_rc rc;
        rc = grn_config_get(context,
                            key, key_size,
                            &value, &value_size);
        rb_grn_context_check(context, self);
        rb_grn_rc_check(rc, self);
    }

    if (value_size == 0) {
        rb_value = Qnil;
    } else {
        rb_value = rb_grn_context_rb_string_new(context, value, value_size);
    }

    return rb_value;
}
开发者ID:mtsmfm,项目名称:rroonga,代码行数:44,代码来源:rb-grn-config.c


示例5: rb_grn_patricia_trie_open_grn_rk_cursor

static grn_table_cursor *
rb_grn_patricia_trie_open_grn_rk_cursor (int argc, VALUE *argv, VALUE self,
					     grn_ctx **context)
{
    grn_obj *table;
    grn_table_cursor *cursor;
    void *prefix = NULL;
    unsigned prefix_size = 0;
    int offset = 0, limit = -1;
    int flags = GRN_CURSOR_PREFIX | GRN_CURSOR_RK;
    VALUE options, rb_prefix, rb_key_bytes, rb_key_bits;
    VALUE rb_greater_than, rb_less_than, rb_offset, rb_limit;

    rb_grn_table_deconstruct((RbGrnTable *)SELF(self), &table, context,
			     NULL, NULL,
			     NULL, NULL, NULL,
			     NULL);

    rb_scan_args(argc, argv, "11", &rb_prefix, &options);

    rb_grn_scan_options(options,
			"key_bytes", &rb_key_bytes,
                        "key_bites", &rb_key_bits,
                        "offset", &rb_offset,
                        "limit", &rb_limit,
			"greater_than", &rb_greater_than,
			"less_than", &rb_less_than,
			NULL);

    prefix = StringValuePtr(rb_prefix);
    if (!NIL_P(rb_key_bytes) && !NIL_P(rb_key_bits)) {
	rb_raise(rb_eArgError,
		 "should not specify both :key_bytes and :key_bits once: %s",
		 rb_grn_inspect(rb_ary_new4(argc, argv)));
    } else if (!NIL_P(rb_key_bytes)) {
	prefix_size = NUM2UINT(rb_key_bytes);
    } else if (!NIL_P(rb_key_bits)) {
	prefix_size = NUM2UINT(rb_key_bits);
	flags |= GRN_CURSOR_SIZE_BY_BIT;
    } else {
	prefix_size = RSTRING_LEN(rb_prefix);
    }
    if (!NIL_P(rb_offset))
	offset = NUM2INT(rb_offset);
    if (!NIL_P(rb_limit))
	limit = NUM2INT(rb_limit);

    if (RVAL2CBOOL(rb_greater_than))
	flags |= GRN_CURSOR_GT;
    if (RVAL2CBOOL(rb_less_than))
	flags |= GRN_CURSOR_LT;

    cursor = grn_table_cursor_open(*context, table,
				   prefix, prefix_size,
				   NULL, 0,
				   offset, limit, flags);
    rb_grn_context_check(*context, self);

    return cursor;
}
开发者ID:mallowlabs,项目名称:rroonga,代码行数:60,代码来源:rb-grn-patricia-trie.c


示例6: rb_grn_normalizer_s_normalize

/*
 * Normalizes the @[email protected]
 *
 * @example
 *   # Normalizes "ABC" with the default normalizer
 *   Groonga::Normalizer.normalize("AbC") # => "abc"
 *
 * @overload normalize(string)
 *   @return [String] The normalized string
 *   @param [String] string The original string
 */
static VALUE
rb_grn_normalizer_s_normalize (VALUE klass, VALUE rb_string)
{
    VALUE rb_context = Qnil;
    VALUE rb_encoded_string;
    VALUE rb_normalized_string;
    grn_ctx *context = NULL;
    grn_obj *grn_string;
    grn_obj *normalizer = GRN_NORMALIZER_AUTO;
    /* TODO: make customizable */
    int flags = GRN_STRING_REMOVE_BLANK;
    const char *normalized_string;
    unsigned int normalized_string_length;

    context = rb_grn_context_ensure(&rb_context);
    rb_encoded_string = rb_grn_context_rb_string_encode(context, rb_string);
    grn_string = grn_string_open(context,
                                 RSTRING_PTR(rb_encoded_string),
                                 RSTRING_LEN(rb_encoded_string),
                                 normalizer,
                                 flags);
    rb_grn_context_check(context, rb_string);
    grn_string_get_normalized(context, grn_string,
                              &normalized_string, &normalized_string_length,
                              NULL);
    rb_normalized_string =
        rb_grn_context_rb_string_new(context,
                                     normalized_string,
                                     normalized_string_length);
    grn_obj_close(context, grn_string);

    return rb_normalized_string;
}
开发者ID:keitahaga,项目名称:rroonga,代码行数:44,代码来源:rb-grn-normalizer.c


示例7: rb_grn_windows_event_logger_s_register

/*
 * @overload register(event_source_name, options={})
 *
 *   Registers Windows Event Log based logger that uses
 *   `event_source_name` as event source name.
 *
 *   @param event_source_name [String] The event source name.
 *   @param options [::Hash]
 *   @option options :context [Groonga::Context] (Groonga::Context.default)
 *     The context to be set logger.
 *
 *   @return [void]
 *
 *   @since 5.0.5
 */
static VALUE
rb_grn_windows_event_logger_s_register (int argc,
                                        VALUE *argv,
                                        VALUE klass)
{
    VALUE rb_event_source_name;
    VALUE rb_options;
    VALUE rb_context;
    const char *event_source_name;
    grn_ctx *context;
    grn_rc rc;

    rb_scan_args(argc, argv, "11", &rb_event_source_name, &rb_options);
    rb_event_source_name = rb_grn_convert_to_string(rb_event_source_name);
    event_source_name = StringValueCStr(rb_event_source_name);

    rb_grn_scan_options(rb_options,
                        "context", &rb_context,
                        NULL);
    context = rb_grn_context_ensure(&rb_context);

    rc = grn_windows_event_logger_set(context, event_source_name);
    rb_grn_context_check(context, rb_event_source_name);
    rb_grn_rc_check(rc, rb_event_source_name);

    return Qnil;
}
开发者ID:genki,项目名称:rroonga,代码行数:42,代码来源:rb-grn-windows-event-logger.c


示例8: rb_grn_index_column_get_sources

/*
 * call-seq:
 *   column.sources -> Groonga::Columnの配列
 *
 * インデックス対象となっているカラムの配列を返す。
 */
static VALUE
rb_grn_index_column_get_sources (VALUE self)
{
    grn_ctx *context = NULL;
    grn_obj *column;
    grn_obj sources;
    grn_id *source_ids;
    VALUE rb_sources;
    int i, n;

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

    GRN_OBJ_INIT(&sources, GRN_BULK, 0, GRN_ID_NIL);
    grn_obj_get_info(context, column, GRN_INFO_SOURCE, &sources);
    rb_grn_context_check(context, self);

    n = GRN_BULK_VSIZE(&sources) / sizeof(grn_id);
    source_ids = (grn_id *)GRN_BULK_HEAD(&sources);
    rb_sources = rb_ary_new2(n);
    for (i = 0; i < n; i++) {
	grn_obj *source;
	VALUE rb_source;

	source = grn_ctx_at(context, *source_ids);
	rb_source = GRNOBJECT2RVAL(Qnil, context, source, RB_GRN_FALSE);
	rb_ary_push(rb_sources, rb_source);
	source_ids++;
    }
    grn_obj_unlink(context, &sources);

    return rb_sources;
}
开发者ID:nobu,项目名称:rroonga,代码行数:41,代码来源:rb-grn-index-column.c


示例9: rb_grn_column_cache_array_reference

/*
 * @overload [](id)
 *   @param id [Integer, Groonga::Record] The record ID for the
 *     column value.
 *
 *   @return [Object] The value for the record ID.
 */
static VALUE
rb_grn_column_cache_array_reference (VALUE self, VALUE rb_id)
{
    RbGrnColumnCache *rb_grn_column_cache;
    grn_id id;
    void *value;
    size_t value_size = 0;

    TypedData_Get_Struct(self,
                         RbGrnColumnCache,
                         &data_type,
                         rb_grn_column_cache);

    if (!rb_grn_column_cache->column_cache) {
        return Qnil;
    }

    id = rb_grn_id_from_ruby_object(rb_id,
                                    rb_grn_column_cache->context,
                                    rb_grn_column_cache->table,
                                    self);
    value = grn_column_cache_ref(rb_grn_column_cache->context,
                                 rb_grn_column_cache->column_cache,
                                 id,
                                 &value_size);
    rb_grn_context_check(rb_grn_column_cache->context, self);
    GRN_TEXT_SET_REF(&(rb_grn_column_cache->buffer),
                     value,
                     value_size);

    return GRNBULK2RVAL(rb_grn_column_cache->context,
                        &(rb_grn_column_cache->buffer),
                        rb_grn_column_cache->range,
                        self);
}
开发者ID:kenhys,项目名称:rroonga,代码行数:42,代码来源:rb-grn-column-cache.c


示例10: rb_grn_database_initialize

/*
 * 既存のデータベースを開く。ブロックを指定した場合はブロッ
 * クに開いたデータベースを渡し、ブロックを抜けるときに閉じ
 * る。
 *
 * @overload new(path, options=nil)
 *   @!macro [new] database.new.arguments
 *     @param options [::Hash] The name and value
 *       pairs. Omitted names are initialized as the default value.
 *     @option options :context (Groonga::Context.default)
 *       データベースを結びつけるコンテキスト。省略すると
 *       {Groonga::Context.default} を利用する。
 *   @!macro database.new.arguments
 *   @return [Groonga::Database]
 * @overload new(path, options=nil)
 *   @!macro database.new.arguments
 *   @yield [database]
 *   @yieldparam [Groonga::Database] database 開いたデータベース
 */
static VALUE
rb_grn_database_initialize (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context;
    grn_obj *old_database, *database;
    const char *path;
    VALUE rb_path, options, rb_context;

    rb_scan_args(argc, argv, "11", &rb_path, &options);

    path = StringValuePtr(rb_path);
    rb_grn_scan_options(options,
                        "context", &rb_context,
                        NULL);

    context = rb_grn_context_ensure(&rb_context);

    old_database = grn_ctx_db(context);
    if (old_database)
        grn_obj_unlink(context, old_database);
    reset_floating_objects(rb_context);
    database = grn_db_open(context, path);
    rb_grn_object_assign(Qnil, self, rb_context, context, database);
    rb_grn_context_check(context, self);

    rb_iv_set(self, "@context", rb_context);
    if (!NIL_P(rb_context))
        rb_iv_set(rb_context, "database", self);

    return Qnil;
}
开发者ID:genki,项目名称:rroonga,代码行数:50,代码来源:rb-grn-database.c


示例11: rb_grn_flushable_flush

/*
 * Flush memory mapped data to disk.
 *
 * @overload flush(options={})
 *   @param [::Hash] options
 *   @option options [Boolean] :recursive (true) Whether to flush objects
 *     which a target object has recursively.
 *   @return [void]
 */
static VALUE
rb_grn_flushable_flush (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context = NULL;
    grn_obj *object = NULL;
    VALUE rb_recursive_p;
    VALUE rb_options;

    rb_scan_args(argc, argv, "01", &rb_options);
    rb_grn_scan_options(rb_options,
                        "recursive", &rb_recursive_p,
                        NULL);
    if (NIL_P(rb_recursive_p)) {
        rb_recursive_p = Qtrue;
    }

    rb_grn_object_deconstruct(SELF(self), &object, &context,
                              NULL, NULL, NULL, NULL);
    if (!object) {
        rb_raise(rb_eGrnClosed,
                 "can't access already closed Groonga object: <%s>",
                 rb_grn_inspect(self));
    }

    if (RVAL2CBOOL(rb_recursive_p)) {
        grn_obj_flush_recursive(context, object);
    } else {
        grn_obj_flush(context, object);
    }
    rb_grn_context_check(context, self);

    return Qnil;
}
开发者ID:genki,项目名称:rroonga,代码行数:42,代码来源:rb-grn-flushable.c


示例12: rb_grn_expression_append_object

/*
 * _object_ を追加し、 _n_arguments_ 個の引数を取る _operation_ を追加する。
 *
 * @overload append_object(object, operation=Groonga::Operator::PUSH, n_arguments=1)
 *   @param [Object] object 追加するオブジェクト
 *   @param [Groonga::Operator::XXX] operation 追加する _operation_
 *   @param [Integer] n_arguments _operation_ の取る引数
 * @return [Self] self
 *
 */
static VALUE
rb_grn_expression_append_object (int argc, VALUE *argv, VALUE self)
{
    VALUE rb_object, rb_operation, rb_n_arguments;
    grn_ctx *context = NULL;
    grn_obj *expression, *object;
    grn_operator operation = GRN_OP_PUSH;
    int n_arguments = 1;

    rb_scan_args(argc, argv, "12", &rb_object, &rb_operation, &rb_n_arguments);
    if (!NIL_P(rb_operation))
        operation = RVAL2GRNOPERATOR(rb_operation);
    if (!NIL_P(rb_n_arguments))
        n_arguments = NUM2INT(rb_n_arguments);

    rb_grn_expression_deconstruct(SELF(self), &expression, &context,
                                  NULL, NULL,
                                  NULL, NULL, NULL);

    object = RVAL2GRNOBJECT(rb_object, &context);
    grn_expr_append_obj(context, expression, object,
                        operation, n_arguments);
    rb_grn_context_check(context, self);
    rb_ary_push(rb_iv_get(self, "@objects"), rb_object);

    return self;
}
开发者ID:genki,项目名称:rroonga,代码行数:37,代码来源:rb-grn-expression.c


示例13: rb_grn_expression_initialize

static VALUE
rb_grn_expression_initialize (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context = NULL;
    grn_obj *expression;
    VALUE options, rb_context, rb_name;
    char *name = NULL;
    unsigned name_size = 0;

    rb_scan_args(argc, argv, "01", &options);
    rb_grn_scan_options(options,
                        "context", &rb_context,
                        "name", &rb_name,
                        NULL);

    context = rb_grn_context_ensure(&rb_context);

    if (!NIL_P(rb_name)) {
        name = StringValuePtr(rb_name);
        name_size = RSTRING_LEN(rb_name);
    }

    expression = grn_expr_create(context, name, name_size);
    rb_grn_context_check(context, self);
    rb_grn_object_assign(Qnil, self, rb_context, context, expression);
    rb_grn_context_register_floating_object(DATA_PTR(self));

    rb_iv_set(self, "@objects", rb_ary_new());

    return Qnil;
}
开发者ID:genki,项目名称:rroonga,代码行数:31,代码来源:rb-grn-expression.c


示例14: rb_grn_database_lock

/*
 * _database_ をロックする。ロックに失敗した場合は
 * {Groonga::ResourceDeadlockAvoided} 例外が発生する。
 *
 * @overload lock(options={})
 *   @!macro [new] database.lock.arguments
 *     @param [::Hash] options 利用可能なオプションは以下の通り。
 *     @option options :timeout
 *       ロックを獲得できなかった場合は _:timeout_ 秒間ロックの獲
 *       得を試みる。 _:timeout_ 秒以内にロックを獲得できなかった
 *       場合は例外が発生する。
 *   @!macro database.lock.arguments
 * @overload lock(options={})
 *   @yield ブロックを指定した場合はブロックを抜けたときにunlockする。
 *   @!macro database.lock.arguments
 */
static VALUE
rb_grn_database_lock (int argc, VALUE *argv, VALUE self)
{
    grn_ctx *context;
    grn_obj *database;
    int timeout = 0;
    grn_rc rc;
    VALUE options, rb_timeout;

    rb_scan_args(argc, argv, "01",  &options);

    rb_grn_database_deconstruct(SELF(self), &database, &context,
                                NULL, NULL, NULL, NULL);

    rb_grn_scan_options(options,
                        "timeout", &rb_timeout,
                        NULL);

    if (!NIL_P(rb_timeout))
        timeout = NUM2UINT(rb_timeout);

    rc = grn_obj_lock(context, database, GRN_ID_NIL, timeout);
    rb_grn_context_check(context, self);
    rb_grn_rc_check(rc, self);

    if (rb_block_given_p()) {
        return rb_ensure(rb_yield, Qnil, rb_grn_database_unlock, self);
    } else {
        return Qnil;
    }
}
开发者ID:genki,项目名称:rroonga,代码行数:47,代码来源:rb-grn-database.c


示例15: rb_grn_value_from_ruby_object

grn_obj *
rb_grn_value_from_ruby_object (VALUE object, grn_ctx *context,
                               grn_obj *value, grn_id type_id, grn_obj *type)
{
    grn_bool string_p, table_type_p;

    string_p = rb_type(object) == T_STRING;
    table_type_p = (GRN_TABLE_HASH_KEY <= type->header.type &&
                    type->header.type <= GRN_TABLE_NO_KEY);
    if (!string_p) {
        return RVAL2GRNBULK_WITH_TYPE(object, context, value, type_id, type);
    }

    if (table_type_p && RSTRING_LEN(object) == 0) {
        if (value) {
            if (value->header.domain != type_id) {
                grn_obj_reinit(context, value, type_id, 0);
            }
        } else {
            value = grn_obj_open(context, GRN_BULK, 0, type_id);
            rb_grn_context_check(context, object);
        }
        GRN_RECORD_SET(context, value, GRN_ID_NIL);
        return value;
    }

    return RVAL2GRNBULK(object, context, value);
}
开发者ID:rutice,项目名称:rroonga,代码行数:28,代码来源:rb-grn-utils.c


示例16: rb_grn_hash_from_ruby_hash_body

static int
rb_grn_hash_from_ruby_hash_body (VALUE rb_key,
                                 VALUE rb_value,
                                 VALUE user_data)
{
    RbGrnHashFromRubyHashData *data = (RbGrnHashFromRubyHashData *)user_data;
    grn_obj *value;
    int added;

    rb_key = rb_grn_convert_to_string(rb_key);

    grn_hash_add(data->context,
                 data->hash,
                 RSTRING_PTR(rb_key),
                 RSTRING_LEN(rb_key),
                 (void **)&value,
                 &added);
    rb_grn_context_check(data->context, data->rb_hash);

    if (added) {
        GRN_VOID_INIT(value);
    }
    RVAL2GRNBULK(rb_value, data->context, value);

    return ST_CONTINUE;
}
开发者ID:kenhys,项目名称:rroonga,代码行数:26,代码来源:rb-grn-expression.c


示例17: rb_grn_array_push

/*
 * Pushes a record to the array. The record should be filled in the
 * given block. The pushed record can be pulled by
 * {Groonga::Array#pull}.
 *
 * @example A program that pushes a job without error handling
 *   queue = Groonga::Array.create(:name => "CrawlURLQueue")
 *   queue.define_column("url", "ShortText")
 *   urls = ["http://groonga.org/", "http://ranguba.org/"]
 *   urls.each do |url|
 *     queue.push do |record|
 *       record.url = url
 *     end
 *   end
 *
 * @example A program that pulls a job without error handling
 *   queue = Groonga::Array.open(:name => "CrawlURLQueue")
 *   loop do
 *     url = nil
 *     queue.pull do |record|
 *       url = record.url
 *       record.delete
 *     end
 *     # Crawl URL
 *   end
 *
 * The record that is passed to the given block may be nil. You need
 * to handle the case. For example, just ignoring it or reports an
 * error.
 *
 * @example A program that pushes a job with error handling
 *   queue = Groonga::Array.create(:name => "CrawlURLQueue")
 *   queue.define_column("url", "ShortText")
 *   urls = ["http://groonga.org/", "http://ranguba.org/"]
 *   urls.each do |url|
 *     queue.push do |record|
 *       record.url = url if record # check record is not nil
 *     end
 *   end
 *
 * If an error is occurred in the given block, the pushed record may
 * not be filled completely. You should handle the case in pull side.
 *
 * @example A program that has an error in push block
 *   queue = Groonga::Array.create(:name => "CrawlURLQueue")
 *   queue.define_column("url", "ShortText")
 *   urls = ["http://groonga.org/", "http://ranguba.org/"]
 *   urls.each do |url|
 *     queue.push do |record|
 *       record.url = uri # Typo! It should be ur*l* not ur*i*
 *       # record.url isn't set
 *     end
 *   end
 *
 * @example A program that pulls a job with error handling
 *   queue = Groonga::Array.open(:name => "CrawlURLQueue")
 *   loop do
 *     url = nil
 *     queue.pull do |record|
 *       url = record.url # record.url is nil!
 *       record.delete
 *     end
 *     next if url.nil? # Ignore an uncompleted added job
 *     # Crawl URL
 *   end
 *
 * @overload push
 *   @yield [record] Filles columns of a pushed record in the given block.
 *   @yieldparam record [Groonga::Record or nil]
 *     A pushed record. It is nil when pushing is failed.
 *   @return [Groonga::Record or nil] A pushed record that is yielded.
 *
 */
static VALUE
rb_grn_array_push (VALUE self)
{
    grn_ctx *context = NULL;
    grn_obj *table;
    YieldRecordCallbackData data;

    if (!rb_block_given_p()) {
        rb_raise(rb_eArgError,
                 "tried to call Groonga::Array#push without a block");
    }

    table = SELF(self, &context);

    data.self = self;
    data.record = Qnil;
    data.status = 0;
    grn_array_push(context, (grn_array *)table, yield_record_callback, &data);
    if (data.status != 0) {
        rb_jump_tag(data.status);
    }
    rb_grn_context_check(context, self);

    return data.record;
}
开发者ID:cosmo0920,项目名称:rroonga,代码行数:98,代码来源:rb-grn-array.c


示例18: rb_grn_variable_size_column_defrag

/*
 * Defrags the column.
 *
 * @overload defrag(options={})
 *   @param options [::Hash] The name and value
 *     pairs. Omitted names are initialized as the default value.
 *   @option options [Integer] :threshold (0) the threshold to
 *     determine whether a segment is defraged. Available
 *     values are -4..22. -4 means all segments are defraged.
 *     22 means no segment is defraged.
 * @return [Integer] the number of defraged segments
 * @since 1.2.6
 */
static VALUE
rb_grn_variable_size_column_defrag (int argc, VALUE *argv, VALUE self)
{
    RbGrnVariableSizeColumn *rb_grn_column;
    grn_ctx *context = NULL;
    grn_obj *column;
    int n_segments;
    VALUE options, rb_threshold;
    int threshold = 0;

    rb_scan_args(argc, argv, "01", &options);
    rb_grn_scan_options(options,
                        "threshold", &rb_threshold,
                        NULL);
    if (!NIL_P(rb_threshold)) {
        threshold = NUM2INT(rb_threshold);
    }

    rb_grn_column = SELF(self);
    rb_grn_object_deconstruct(RB_GRN_OBJECT(rb_grn_column), &column, &context,
                              NULL, NULL,
                              NULL, NULL);
    n_segments = grn_obj_defrag(context, column, threshold);
    rb_grn_context_check(context, self);

    return INT2NUM(n_segments);
}
开发者ID:rutice,项目名称:rroonga,代码行数:40,代码来源:rb-grn-variable-size-column.c


示例19: rb_grn_index_column_array_set


//.........这里部分代码省略.........
 *   ■全文検索方式
 *   転置索引型の全文検索エンジンです。転置索引は圧縮されてファ
 *   イルに格納され、検索時のディスク読み出し量を小さく、かつ
 *   局所的に抑えるように設計されています。用途に応じて以下の
 *   索引タイプを選択できます。
 *   EOC
 *
 *   groonga = articles.add(:title => "groonga", :content => content)
 *
 *   content.split(/\n{2,}/).each_with_index do |sentence, i|
 *     content_index[groonga] = {:value => sentence, :section => i + 1}
 *   end
 *
 *   content_index.search("エンジン").collect do |record|
 *     p record.key["title"] # -> "groonga"
 *   end
 *
 * @overload []=(id, value)
 *   @param [String] value 新しい値
 * @overload []=(id, options)
 *   _options_ を指定することにより、 _value_ を指定したときよりも索引の作
 *   成を制御できる。
 *   @param [::Hash] options The name and value
 *     pairs. Omitted names are initialized as the default value
 *   @option options :section
 *     段落番号を指定する。省略した場合は1を指定したとみなされ
 *     る。
 *     {Groonga::Table#define_index_column} で
 *     @{:with_section => true}@ を指定していなければい
 *     けない。
 *   @option options :old_value
 *     以前の値を指定する。省略した場合は現在の値が用いられる。
 *     通常は指定する必要はない。
 *   @option options :value
 *     新しい値を指定する。 _value_ を指定した場合と _options_ で
 *     @{:value => value}@ を指定した場合は同じ動作とな
 *     る。
 *
 * @deprecated Since 3.0.2. Use {#add}, {#delete} or {#update} instead.
 */
static VALUE
rb_grn_index_column_array_set (VALUE self, VALUE rb_id, VALUE rb_value)
{
    grn_ctx *context = NULL;
    grn_obj *column, *range;
    grn_rc rc;
    grn_id id;
    unsigned int section;
    grn_obj *old_value, *new_value;
    VALUE original_rb_value, rb_section, rb_old_value, rb_new_value;

    original_rb_value = rb_value;

    rb_grn_index_column_deconstruct(SELF(self), &column, &context,
                                    NULL, NULL,
                                    &new_value, &old_value,
                                    NULL, &range,
                                    NULL, NULL);

    id = RVAL2GRNID(rb_id, context, range, self);

    if (!RVAL2CBOOL(rb_obj_is_kind_of(rb_value, rb_cHash))) {
        VALUE hash_value;
        hash_value = rb_hash_new();
        rb_hash_aset(hash_value, RB_GRN_INTERN("value"), rb_value);
        rb_value = hash_value;
    }

    rb_grn_scan_options(rb_value,
                        "section", &rb_section,
                        "old_value", &rb_old_value,
                        "value", &rb_new_value,
                        NULL);

    if (NIL_P(rb_section))
        section = 1;
    else
        section = NUM2UINT(rb_section);

    if (NIL_P(rb_old_value)) {
        old_value = NULL;
    } else {
        GRN_BULK_REWIND(old_value);
        RVAL2GRNBULK(rb_old_value, context, old_value);
    }

    if (NIL_P(rb_new_value)) {
        new_value = NULL;
    } else {
        GRN_BULK_REWIND(new_value);
        RVAL2GRNBULK(rb_new_value, context, new_value);
    }

    rc = grn_column_index_update(context, column,
                                 id, section, old_value, new_value);
    rb_grn_context_check(context, self);
    rb_grn_rc_check(rc, self);

    return original_rb_value;
}
开发者ID:keitahaga,项目名称:rroonga,代码行数:101,代码来源:rb-grn-index-column.c


示例20: rb_grn_column_unlock

/*
 * Document-method: unlock
 *
 * call-seq:
 *   column.unlock(options={})
 *
 * _column_のロックを解除する。
 *
 * 利用可能なオプションは以下の通り。
 *
 * [_:id_]
 *   _:id_で指定したレコードのロックを解除する。(注:
 *   groonga側が未実装のため、現在は無視される)
 */
static VALUE
rb_grn_column_unlock (int argc, VALUE *argv, VALUE self)
{
    grn_id id = GRN_ID_NIL;
    grn_ctx *context;
    grn_obj *column;
    grn_rc rc;
    VALUE options, rb_id;

    rb_scan_args(argc, argv, "01",  &options);

    rb_grn_column_deconstruct(SELF(self), &column, &context,
			     NULL, NULL,
			     NULL, NULL, NULL);

    rb_grn_scan_options(options,
			"id", &rb_id,
			NULL);

    if (!NIL_P(rb_id))
	id = NUM2UINT(rb_id);

    rc = grn_obj_unlock(context, column, id);
    rb_grn_context_check(context, self);
    rb_grn_rc_check(rc, self);

    return Qnil;
}
开发者ID:nobu,项目名称:rroonga,代码行数:42,代码来源:rb-grn-column.c



注:本文中的rb_grn_context_check函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rb_gv_get函数代码示例发布时间:2022-05-30
下一篇:
C++ rb_global_variable函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap