本文整理汇总了C++中GRN_OBJ_FIN函数的典型用法代码示例。如果您正苦于以下问题:C++ GRN_OBJ_FIN函数的具体用法?C++ GRN_OBJ_FIN怎么用?C++ GRN_OBJ_FIN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GRN_OBJ_FIN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_grn_prefix_operator_exec
/*
* Executes a prefix-search operation. Prefix-serach operation checks
* whether `text` starts with `prefix` or not.
*
* @example Executes prefix-search operations with the default context
* Groonga::Operator::PREFIX.exec("Hello Rroonga", "Hello") # => true
* Groonga::Operator::PREFIX.exec("Hello Rroonga", "Rroonga") # => false
*
* @example Executes prefix-search operations with the specified context
* context = Groonga::Context.new
* Groonga::Operator::PREFIX.exec("Hello Rroonga", "Hello",
* :context => context) # => true
* Groonga::Operator::PREFIX.exec("Hello Rroonga", "Rroonga",
* :context => context) # => false
*
* @overload exec(text, prefix, options={})
* @param text [String] The text to be searched.
* @param prefix [String] The prefix to be contained.
* @param options [::Hash] The options.
* @option options [Groonga::Context] (Groonga::Context.default)
* The context to executes the operation.
* @return [Boolean] `true` if `text` starts with `prefix`, `false`
* otherwise.
*/
static VALUE
rb_grn_prefix_operator_exec (int argc, VALUE *argv, VALUE self)
{
grn_bool have_prefix;
VALUE rb_text;
VALUE rb_prefix;
VALUE rb_options;
VALUE rb_context;
grn_ctx *context;
grn_obj text;
grn_obj prefix;
rb_scan_args(argc, argv, "21", &rb_text, &rb_prefix, &rb_options);
rb_grn_scan_options(rb_options,
"context", &rb_context,
NULL);
context = rb_grn_context_ensure(&rb_context);
GRN_VOID_INIT(&text);
GRN_VOID_INIT(&prefix);
RVAL2GRNBULK(rb_text, context, &text);
RVAL2GRNBULK(rb_prefix, context, &prefix);
have_prefix = grn_operator_exec_prefix(context, &text, &prefix);
GRN_OBJ_FIN(context, &text);
GRN_OBJ_FIN(context, &prefix);
return CBOOL2RVAL(have_prefix);
}
示例2: report_set_column_value_failure
static void
report_set_column_value_failure(grn_ctx *ctx,
grn_obj *key,
const char *column_name,
unsigned int column_name_size,
grn_obj *column_value)
{
grn_obj key_inspected, column_value_inspected;
GRN_TEXT_INIT(&key_inspected, 0);
GRN_TEXT_INIT(&column_value_inspected, 0);
grn_inspect_limited(ctx, &key_inspected, key);
grn_inspect_limited(ctx, &column_value_inspected, column_value);
GRN_LOG(ctx, GRN_LOG_ERROR,
"[table][load] failed to set column value: %s: "
"key: <%.*s>, column: <%.*s>, value: <%.*s>",
ctx->errbuf,
(int)GRN_TEXT_LEN(&key_inspected),
GRN_TEXT_VALUE(&key_inspected),
column_name_size,
column_name,
(int)GRN_TEXT_LEN(&column_value_inspected),
GRN_TEXT_VALUE(&column_value_inspected));
GRN_OBJ_FIN(ctx, &key_inspected);
GRN_OBJ_FIN(ctx, &column_value_inspected);
}
示例3: rb_grn_less_operator_exec
/*
* Executes a less operation.
*
* @example Executes less operations with the default context
* Groonga::Operator::LESS.exec(1, 2) # => true
* Groonga::Operator::LESS.exec(2, 1) # => false
*
* @example Executes less operations with the specified context
* context = Groonga::Context.new
* Groonga::Operator::LESS.exec(1, 2,
* :context => context) # => true
* Groonga::Operator::LESS.exec(2, 1,
* :context => context) # => false
*
* @overload exec(x, y, options={})
* @param x [::Object] The left hand side value.
* @param y [::Object] The right hand side value.
* @param options [::Hash] The options.
* @option options [Groonga::Context] (Groonga::Context.default)
* The context to executes the operation.
* @return [Boolean] `true` if `x` is less than `y`, `false`
* otherwise.
*/
static VALUE
rb_grn_less_operator_exec (int argc, VALUE *argv, VALUE self)
{
grn_bool less;
VALUE rb_x;
VALUE rb_y;
VALUE rb_options;
VALUE rb_context;
grn_ctx *context;
grn_obj x;
grn_obj y;
rb_scan_args(argc, argv, "21", &rb_x, &rb_y, &rb_options);
rb_grn_scan_options(rb_options,
"context", &rb_context,
NULL);
context = rb_grn_context_ensure(&rb_context);
GRN_VOID_INIT(&x);
GRN_VOID_INIT(&y);
RVAL2GRNBULK(rb_x, context, &x);
RVAL2GRNBULK(rb_y, context, &y);
less = grn_operator_exec_less(context, &x, &y);
GRN_OBJ_FIN(context, &x);
GRN_OBJ_FIN(context, &y);
return CBOOL2RVAL(less);
}
示例4: GRN_OBJ_FIN
Buffers::~Buffers() {
for (size_t i = 0; i < n_; ++i) {
grn_obj *buffer = (*this)[i];
GRN_OBJ_FIN(ctx_, buffer);
}
GRN_OBJ_FIN(ctx_, &buffers_);
}
示例5: grn_rset_recinfo_update_calc_values
void
grn_rset_recinfo_update_calc_values(grn_ctx *ctx,
grn_rset_recinfo *ri,
grn_obj *table,
grn_obj *value)
{
grn_table_group_flags flags;
byte *values;
grn_obj value_int64;
grn_obj value_float;
flags = DB_OBJ(table)->flags.group;
values = (((byte *)ri->subrecs) +
GRN_RSET_SUBRECS_SIZE(DB_OBJ(table)->subrec_size,
DB_OBJ(table)->max_n_subrecs));
GRN_INT64_INIT(&value_int64, 0);
GRN_FLOAT_INIT(&value_float, 0);
if (flags & (GRN_TABLE_GROUP_CALC_MAX |
GRN_TABLE_GROUP_CALC_MIN |
GRN_TABLE_GROUP_CALC_SUM)) {
grn_obj_cast(ctx, value, &value_int64, GRN_FALSE);
}
if (flags & GRN_TABLE_GROUP_CALC_AVG) {
grn_obj_cast(ctx, value, &value_float, GRN_FALSE);
}
if (flags & GRN_TABLE_GROUP_CALC_MAX) {
int64_t current_max = *((int64_t *)values);
int64_t value_raw = GRN_INT64_VALUE(&value_int64);
if (ri->n_subrecs == 1 || value_raw > current_max) {
*((int64_t *)values) = value_raw;
}
values += GRN_RSET_MAX_SIZE;
}
if (flags & GRN_TABLE_GROUP_CALC_MIN) {
int64_t current_min = *((int64_t *)values);
int64_t value_raw = GRN_INT64_VALUE(&value_int64);
if (ri->n_subrecs == 1 || value_raw < current_min) {
*((int64_t *)values) = value_raw;
}
values += GRN_RSET_MIN_SIZE;
}
if (flags & GRN_TABLE_GROUP_CALC_SUM) {
int64_t value_raw = GRN_INT64_VALUE(&value_int64);
*((int64_t *)values) += value_raw;
values += GRN_RSET_SUM_SIZE;
}
if (flags & GRN_TABLE_GROUP_CALC_AVG) {
double current_average = *((double *)values);
double value_raw = GRN_FLOAT_VALUE(&value_float);
*((double *)values) += (value_raw - current_average) / ri->n_subrecs;
values += GRN_RSET_AVG_SIZE;
}
GRN_OBJ_FIN(ctx, &value_float);
GRN_OBJ_FIN(ctx, &value_int64);
}
示例6: parse_id_value
static grn_id
parse_id_value(grn_ctx *ctx, grn_obj *value)
{
switch (value->header.type) {
case GRN_DB_UINT32 :
return GRN_UINT32_VALUE(value);
case GRN_DB_INT32 :
return GRN_INT32_VALUE(value);
default :
{
grn_id id = GRN_ID_NIL;
grn_obj casted_value;
GRN_UINT32_INIT(&casted_value, 0);
if (grn_obj_cast(ctx, value, &casted_value, GRN_FALSE) != GRN_SUCCESS) {
grn_obj inspected;
GRN_TEXT_INIT(&inspected, 0);
grn_inspect(ctx, &inspected, value);
ERR(GRN_INVALID_ARGUMENT,
"<%s>: failed to cast to <UInt32>: <%.*s>",
GRN_COLUMN_NAME_ID,
(int)GRN_TEXT_LEN(&inspected),
GRN_TEXT_VALUE(&inspected));
GRN_OBJ_FIN(ctx, &inspected);
} else {
id = GRN_UINT32_VALUE(&casted_value);
}
GRN_OBJ_FIN(ctx, &casted_value);
return id;
}
}
}
示例7: load_synonyms
static void
load_synonyms(grn_ctx *ctx)
{
static char path_env[GRN_ENV_BUFFER_SIZE];
const char *path;
grn_file_reader *file_reader;
int number_of_lines;
grn_encoding encoding;
grn_obj line, key, value;
grn_getenv("GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE",
path_env,
GRN_ENV_BUFFER_SIZE);
if (path_env[0]) {
path = path_env;
} else {
path = get_system_synonyms_file();
}
file_reader = grn_file_reader_open(ctx, path);
if (!file_reader) {
GRN_LOG(ctx, GRN_LOG_WARNING,
"[plugin][query-expander][tsv] "
"synonyms file doesn't exist: <%s>",
path);
return;
}
GRN_TEXT_INIT(&line, 0);
GRN_TEXT_INIT(&key, 0);
GRN_TEXT_INIT(&value, 0);
grn_bulk_reserve(ctx, &value, MAX_SYNONYM_BYTES);
number_of_lines = 0;
while (grn_file_reader_read_line(ctx, file_reader, &line) == GRN_SUCCESS) {
const char *line_value = GRN_TEXT_VALUE(&line);
size_t line_length = GRN_TEXT_LEN(&line);
if (line_length > 0 && line_value[line_length - 1] == '\n') {
if (line_length > 1 && line_value[line_length - 2] == '\r') {
line_length -= 2;
} else {
line_length -= 1;
}
}
number_of_lines++;
if (number_of_lines == 1) {
encoding = guess_encoding(ctx, &line_value, &line_length);
}
GRN_BULK_REWIND(&key);
GRN_BULK_REWIND(&value);
parse_synonyms_file_line(ctx, line_value, line_length, &key, &value);
GRN_BULK_REWIND(&line);
}
GRN_OBJ_FIN(ctx, &line);
GRN_OBJ_FIN(ctx, &key);
GRN_OBJ_FIN(ctx, &value);
grn_file_reader_close(ctx, file_reader);
}
示例8: grn_mrb_value_to_raw_data_buffer_fin
void
grn_mrb_value_to_raw_data_buffer_fin(mrb_state *mrb,
grn_mrb_value_to_raw_data_buffer *buffer)
{
grn_ctx *ctx = (grn_ctx *)mrb->ud;
GRN_OBJ_FIN(ctx, &(buffer->from));
GRN_OBJ_FIN(ctx, &(buffer->to));
}
示例9: ngx_http_groonga_handler_cleanup
static void
ngx_http_groonga_handler_cleanup(void *user_data)
{
ngx_http_groonga_handler_data_t *data = user_data;
grn_ctx *context;
context = &(data->context);
GRN_OBJ_FIN(context, &(data->head));
GRN_OBJ_FIN(context, &(data->body));
GRN_OBJ_FIN(context, &(data->foot));
grn_ctx_fin(context);
}
示例10: grn_ctx_impl_mrb_fin
void
grn_ctx_impl_mrb_fin(grn_ctx *ctx)
{
if (ctx->impl->mrb.state) {
mrb_close(ctx->impl->mrb.state);
ctx->impl->mrb.state = NULL;
grn_hash_close(ctx, ctx->impl->mrb.checked_procs);
grn_hash_close(ctx, ctx->impl->mrb.registered_plugins);
GRN_OBJ_FIN(ctx, &(ctx->impl->mrb.buffer.from));
GRN_OBJ_FIN(ctx, &(ctx->impl->mrb.buffer.to));
}
}
示例11: ngx_http_groonga_handler_cleanup
static void
ngx_http_groonga_handler_cleanup(void *user_data)
{
ngx_http_groonga_handler_data_t *data = user_data;
if (!data->initialized) {
return;
}
GRN_OBJ_FIN(context, &(data->typed.head));
GRN_OBJ_FIN(context, &(data->typed.body));
GRN_OBJ_FIN(context, &(data->typed.foot));
}
示例12: proc_column_create
static grn_obj *
proc_column_create(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
{
uint32_t nvars;
grn_obj *buf = args[0];
grn_expr_var *vars;
grn_proc_get_info(ctx, user_data, &vars, &nvars, NULL);
if (nvars == 6) {
grn_obj_flags flags = grn_atoi(GRN_TEXT_VALUE(&vars[2].value),
GRN_BULK_CURR(&vars[2].value), NULL);
grn_obj *column, *table = grn_ctx_get(ctx, GRN_TEXT_VALUE(&vars[0].value),
GRN_TEXT_LEN(&vars[0].value));
grn_obj *type = grn_ctx_get(ctx, GRN_TEXT_VALUE(&vars[3].value),
GRN_TEXT_LEN(&vars[3].value));
if (GRN_TEXT_LEN(&vars[1].value)) {
flags |= GRN_OBJ_PERSISTENT;
}
column = grn_column_create(ctx, table,
GRN_TEXT_VALUE(&vars[1].value),
GRN_TEXT_LEN(&vars[1].value),
NULL, flags, type);
if (column) {
if (GRN_TEXT_LEN(&vars[4].value)) {
grn_obj sources, source_ids, **p, **pe;
GRN_PTR_INIT(&sources, GRN_OBJ_VECTOR, GRN_ID_NIL);
GRN_UINT32_INIT(&source_ids, GRN_OBJ_VECTOR);
grn_obj_columns(ctx, type,
GRN_TEXT_VALUE(&vars[4].value),
GRN_TEXT_LEN(&vars[4].value),
&sources);
p = (grn_obj **)GRN_BULK_HEAD(&sources);
pe = (grn_obj **)GRN_BULK_CURR(&sources);
while (p < pe) {
grn_id source_id = grn_obj_id(ctx, *p++);
if (source_id) {
GRN_UINT32_PUT(ctx, &source_ids, source_id);
}
}
if (GRN_BULK_VSIZE(&source_ids)) {
grn_obj_set_info(ctx, column, GRN_INFO_SOURCE, &source_ids);
}
GRN_OBJ_FIN(ctx, &source_ids);
GRN_OBJ_FIN(ctx, &sources);
}
grn_obj_unlink(ctx, column);
}
GRN_TEXT_PUTS(ctx, buf, ctx->rc ? "false" : "true");
}
return buf;
}
示例13: rb_grn_vector_from_ruby_object
grn_obj *
rb_grn_vector_from_ruby_object (VALUE object, grn_ctx *context, grn_obj *vector)
{
VALUE *values;
grn_obj value;
int i, n;
if (vector)
GRN_OBJ_INIT(vector, GRN_VECTOR, 0, GRN_ID_NIL);
else
vector = grn_obj_open(context, GRN_VECTOR, 0, 0);
if (NIL_P(object))
return vector;
GRN_VOID_INIT(&value);
n = RARRAY_LEN(object);
values = RARRAY_PTR(object);
for (i = 0; i < n; i++) {
grn_obj *_value = &value;
RVAL2GRNOBJ(values[i], context, &_value);
grn_vector_add_element(context, vector,
GRN_BULK_HEAD(&value),
GRN_BULK_VSIZE(&value),
0,
value.header.domain);
}
GRN_OBJ_FIN(context, &value);
return vector;
}
示例14: mroonga_snippet_html_deinit
MRN_API void mroonga_snippet_html_deinit(UDF_INIT *init)
{
MRN_DBUG_ENTER_FUNCTION();
mrn_snippet_html_info *info =
reinterpret_cast<mrn_snippet_html_info *>(init->ptr);
if (!info) {
DBUG_VOID_RETURN;
}
if (info->snippet) {
grn_obj_close(info->ctx, info->snippet);
}
if (info->query_mode.used) {
if (info->query_mode.default_column) {
grn_obj_close(info->ctx, info->query_mode.default_column);
}
if (info->query_mode.table) {
grn_obj_close(info->ctx, info->query_mode.table);
}
}
GRN_OBJ_FIN(info->ctx, &(info->result));
if (!info->use_shared_db) {
grn_obj_close(info->ctx, info->db);
}
mrn_context_pool->release(info->ctx);
my_free(info);
DBUG_VOID_RETURN;
}
示例15: command_schema_output_token_filters
static void
command_schema_output_token_filters(grn_ctx *ctx)
{
grn_obj token_filters;
int i, n;
GRN_PTR_INIT(&token_filters, GRN_OBJ_VECTOR, GRN_DB_OBJECT);
grn_ctx_get_all_token_filters(ctx, &token_filters);
grn_ctx_output_cstr(ctx, "token_filters");
n = GRN_BULK_VSIZE(&token_filters) / sizeof(grn_obj *);
grn_ctx_output_map_open(ctx, "token_filters", n);
for (i = 0; i < n; i++) {
grn_obj *token_filter;
token_filter = GRN_PTR_VALUE_AT(&token_filters, i);
command_schema_output_name(ctx, token_filter);
grn_ctx_output_map_open(ctx, "token_filter", 1);
grn_ctx_output_cstr(ctx, "name");
command_schema_output_name(ctx, token_filter);
grn_ctx_output_map_close(ctx);
}
grn_ctx_output_map_close(ctx);
GRN_OBJ_FIN(ctx, &token_filters);
}