本文整理汇总了C++中GRN_TEXT_VALUE函数的典型用法代码示例。如果您正苦于以下问题:C++ GRN_TEXT_VALUE函数的具体用法?C++ GRN_TEXT_VALUE怎么用?C++ GRN_TEXT_VALUE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GRN_TEXT_VALUE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: command_echo
static grn_obj *
command_echo(grn_ctx *ctx, GNUC_UNUSED int nargs, GNUC_UNUSED grn_obj **args,
grn_user_data *user_data)
{
grn_obj *var;
char *input = NULL;
unsigned int input_len = 0;
var = grn_plugin_proc_get_var(ctx, user_data, "input", -1);
GRN_PLUGIN_LOG(ctx, GRN_LOG_NOTICE, "[echo] input = %.*s",
(int)GRN_TEXT_LEN(var), GRN_TEXT_VALUE(var));
if(GRN_TEXT_LEN(var) != 0) {
input = GRN_TEXT_VALUE(var);
input_len = GRN_TEXT_LEN(var);
}
grn_ctx_output_array_open(ctx, "RESULT", 2);
grn_ctx_output_cstr(ctx, input);
grn_ctx_output_int64(ctx, input_len);
grn_ctx_output_array_close(ctx);
return NULL;
}
示例3: command_ruby_eval
static grn_obj *
command_ruby_eval(grn_ctx *ctx, int nargs, grn_obj **args,
grn_user_data *user_data)
{
grn_obj *script;
mrb_value result;
script = VAR(0);
switch (script->header.domain) {
case GRN_DB_SHORT_TEXT :
case GRN_DB_TEXT :
case GRN_DB_LONG_TEXT :
break;
default :
{
grn_obj inspected;
GRN_TEXT_INIT(&inspected, 0);
grn_inspect(ctx, &inspected, script);
ERR(GRN_INVALID_ARGUMENT, "script must be a string: <%.*s>",
(int)GRN_TEXT_LEN(&inspected), GRN_TEXT_VALUE(&inspected));
GRN_OBJ_FIN(ctx, &inspected);
return NULL;
}
break;
}
result = grn_mrb_eval(ctx, GRN_TEXT_VALUE(script), GRN_TEXT_LEN(script));
output_result(ctx, result);
return NULL;
}
示例4: proc_table_create
static grn_obj *
proc_table_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 *table;
grn_obj_flags flags = grn_atoi(GRN_TEXT_VALUE(&vars[1].value),
GRN_BULK_CURR(&vars[1].value), NULL);
if (GRN_TEXT_LEN(&vars[0].value)) {
flags |= GRN_OBJ_PERSISTENT;
}
table = grn_table_create(ctx,
GRN_TEXT_VALUE(&vars[0].value),
GRN_TEXT_LEN(&vars[0].value),
NULL, flags,
grn_ctx_get(ctx, GRN_TEXT_VALUE(&vars[2].value),
GRN_TEXT_LEN(&vars[2].value)),
grn_ctx_get(ctx, GRN_TEXT_VALUE(&vars[3].value),
GRN_TEXT_LEN(&vars[3].value)));
if (table) {
grn_obj_set_info(ctx, table,
GRN_INFO_DEFAULT_TOKENIZER,
grn_ctx_get(ctx, GRN_TEXT_VALUE(&vars[4].value),
GRN_TEXT_LEN(&vars[4].value)));
grn_obj_unlink(ctx, table);
}
GRN_TEXT_PUTS(ctx, buf, ctx->rc ? "false" : "true");
}
return buf;
}
示例5: snippet_exec
static grn_obj *
snippet_exec(grn_ctx *ctx, grn_obj *snip, grn_obj *text,
grn_user_data *user_data,
const char *prefix, int prefix_length,
const char *suffix, int suffix_length)
{
grn_rc rc;
unsigned int i, n_results, max_tagged_length;
grn_obj snippet_buffer;
grn_obj *snippets;
if (GRN_TEXT_LEN(text) == 0) {
return NULL;
}
rc = grn_snip_exec(ctx, snip,
GRN_TEXT_VALUE(text), GRN_TEXT_LEN(text),
&n_results, &max_tagged_length);
if (rc != GRN_SUCCESS) {
return NULL;
}
if (n_results == 0) {
return grn_plugin_proc_alloc(ctx, user_data, GRN_DB_VOID, 0);
}
snippets = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_SHORT_TEXT, GRN_OBJ_VECTOR);
if (!snippets) {
return NULL;
}
GRN_TEXT_INIT(&snippet_buffer, 0);
grn_bulk_space(ctx, &snippet_buffer,
prefix_length + max_tagged_length + suffix_length);
for (i = 0; i < n_results; i++) {
unsigned int snippet_length;
GRN_BULK_REWIND(&snippet_buffer);
if (prefix_length) {
GRN_TEXT_PUT(ctx, &snippet_buffer, prefix, prefix_length);
}
rc = grn_snip_get_result(ctx, snip, i,
GRN_TEXT_VALUE(&snippet_buffer) + prefix_length,
&snippet_length);
if (rc == GRN_SUCCESS) {
grn_strncat(GRN_TEXT_VALUE(&snippet_buffer),
GRN_BULK_WSIZE(&snippet_buffer),
suffix,
suffix_length);
grn_vector_add_element(ctx, snippets,
GRN_TEXT_VALUE(&snippet_buffer),
prefix_length + snippet_length + suffix_length,
0, GRN_DB_SHORT_TEXT);
}
}
GRN_OBJ_FIN(ctx, &snippet_buffer);
return snippets;
}
示例6: parse_synonyms_file_line
static void
parse_synonyms_file_line(grn_ctx *ctx, const char *line, size_t line_length,
grn_obj *key, grn_obj *value)
{
size_t i = 0;
if (is_comment_mark(line[i])) {
return;
}
while (i < line_length) {
char character = line[i];
i++;
if (character == '\t') {
break;
}
GRN_TEXT_PUTC(ctx, key, character);
}
if (i == line_length) {
return;
}
GRN_TEXT_PUTS(ctx, value, "((");
while (i < line_length) {
char character = line[i];
i++;
if (character == '\t') {
GRN_TEXT_PUTS(ctx, value, ") OR (");
} else {
GRN_TEXT_PUTC(ctx, value, character);
}
}
GRN_TEXT_PUTS(ctx, value, "))");
{
grn_id id;
void *value_location = NULL;
id = grn_hash_add(ctx, synonyms, GRN_TEXT_VALUE(key), GRN_TEXT_LEN(key),
&value_location, NULL);
if (id == GRN_ID_NIL) {
GRN_PLUGIN_LOG(ctx, GRN_LOG_WARNING,
"[plugin][query-expander][tsv] "
"failed to register key: <%.*s>",
(int)GRN_TEXT_LEN(key), GRN_TEXT_VALUE(key));
return;
}
if (GRN_TEXT_LEN(value) <= MAX_SYNONYM_BYTES - 1) {
GRN_TEXT_PUTC(ctx, value, '\0');
} else {
grn_bulk_truncate(ctx, value, MAX_SYNONYM_BYTES - 1);
GRN_TEXT_PUTC(ctx, value, '\0');
}
grn_memcpy(value_location, GRN_TEXT_VALUE(value), GRN_TEXT_LEN(value));
}
}
示例7: grn_token_cursor_next_apply_token_filters
static int
grn_token_cursor_next_apply_token_filters(grn_ctx *ctx,
grn_token_cursor *token_cursor,
grn_obj *current_token_data,
grn_obj *status)
{
grn_obj *token_filters = token_cursor->token_filter.objects;
unsigned int i, n_token_filters;
grn_token current_token;
grn_token next_token;
if (token_filters) {
n_token_filters = GRN_BULK_VSIZE(token_filters) / sizeof(grn_obj *);
} else {
n_token_filters = 0;
}
GRN_TEXT_INIT(&(current_token.data), GRN_OBJ_DO_SHALLOW_COPY);
GRN_TEXT_SET(ctx, &(current_token.data),
GRN_TEXT_VALUE(current_token_data),
GRN_TEXT_LEN(current_token_data));
current_token.status = GRN_INT32_VALUE(status);
GRN_TEXT_INIT(&(next_token.data), GRN_OBJ_DO_SHALLOW_COPY);
GRN_TEXT_SET(ctx, &(next_token.data),
GRN_TEXT_VALUE(&(current_token.data)),
GRN_TEXT_LEN(&(current_token.data)));
next_token.status = current_token.status;
for (i = 0; i < n_token_filters; i++) {
grn_obj *token_filter_object = GRN_PTR_VALUE_AT(token_filters, i);
grn_proc *token_filter = (grn_proc *)token_filter_object;
void *data = token_cursor->token_filter.data[i];
#define SKIP_FLAGS\
(GRN_TOKEN_SKIP |\
GRN_TOKEN_SKIP_WITH_POSITION)
if (current_token.status & SKIP_FLAGS) {
break;
}
#undef SKIP_FLAGS
token_filter->callbacks.token_filter.filter(ctx,
¤t_token,
&next_token,
data);
GRN_TEXT_SET(ctx, &(current_token.data),
GRN_TEXT_VALUE(&(next_token.data)),
GRN_TEXT_LEN(&(next_token.data)));
current_token.status = next_token.status;
}
token_cursor->curr =
(const unsigned char *)GRN_TEXT_VALUE(&(current_token.data));
token_cursor->curr_size = GRN_TEXT_LEN(&(current_token.data));
return current_token.status;
}
示例8: rb_grn_bulk_to_ruby_object_by_range_id
static VALUE
rb_grn_bulk_to_ruby_object_by_range_id (grn_ctx *context, grn_obj *bulk,
grn_id range_id,
VALUE related_object, VALUE *rb_value)
{
grn_bool success = GRN_TRUE;
switch (range_id) {
case GRN_DB_VOID:
*rb_value = rb_str_new(GRN_TEXT_VALUE(bulk), GRN_TEXT_LEN(bulk));
break;
case GRN_DB_BOOL:
*rb_value = GRN_BOOL_VALUE(bulk) ? Qtrue : Qfalse;
break;
case GRN_DB_INT32:
*rb_value = INT2NUM(GRN_INT32_VALUE(bulk));
break;
case GRN_DB_UINT32:
*rb_value = UINT2NUM(GRN_UINT32_VALUE(bulk));
break;
case GRN_DB_INT64:
*rb_value = LL2NUM(GRN_INT64_VALUE(bulk));
break;
case GRN_DB_UINT64:
*rb_value = ULL2NUM(GRN_UINT64_VALUE(bulk));
break;
case GRN_DB_FLOAT:
*rb_value = rb_float_new(GRN_FLOAT_VALUE(bulk));
break;
case GRN_DB_TIME:
{
int64_t time_value, sec, usec;
time_value = GRN_TIME_VALUE(bulk);
GRN_TIME_UNPACK(time_value, sec, usec);
*rb_value = rb_funcall(rb_cTime, rb_intern("at"), 2,
LL2NUM(sec), LL2NUM(usec));
}
break;
case GRN_DB_SHORT_TEXT:
case GRN_DB_TEXT:
case GRN_DB_LONG_TEXT:
*rb_value = rb_grn_context_rb_string_new(context,
GRN_TEXT_VALUE(bulk),
GRN_TEXT_LEN(bulk));
break;
default:
success = GRN_FALSE;
break;
}
return success;
}
示例9: command_tag_synonym_delete
static grn_obj *
command_tag_synonym_delete(grn_ctx *ctx, GNUC_UNUSED int nargs, GNUC_UNUSED grn_obj **args,
grn_user_data *user_data)
{
grn_obj *var, *table, *column;
unsigned int nhooks = 0;
char *table_name = NULL;
unsigned int table_len = 0;
char *column_name = NULL;
unsigned int column_len = 0;
var = grn_plugin_proc_get_var(ctx, user_data, "table", -1);
if (GRN_TEXT_LEN(var) != 0) {
table_name = GRN_TEXT_VALUE(var);
table_len = GRN_TEXT_LEN(var);
}
var = grn_plugin_proc_get_var(ctx, user_data, "column", -1);
if (GRN_TEXT_LEN(var) != 0) {
column_name = GRN_TEXT_VALUE(var);
column_len = GRN_TEXT_LEN(var);
}
table = grn_ctx_get(ctx, table_name, table_len);
column = grn_obj_column(ctx, table, column_name, column_len);
nhooks = grn_obj_get_nhooks(ctx, column, GRN_HOOK_SET);
if (nhooks) {
grn_obj *hook;
unsigned int i;
grn_obj data;
grn_obj buf;
GRN_TEXT_INIT(&buf, 0);
GRN_TEXT_INIT(&data, 0);
for (i=0; i < nhooks; i++) {
GRN_BULK_REWIND(&buf);
GRN_BULK_REWIND(&data);
hook = grn_obj_get_hook(ctx, column, GRN_HOOK_SET, i, &data);
grn_inspect_name(ctx, &buf, hook);
if (GRN_TEXT_LEN(&buf) == strlen("tag_synonym") &&
strncmp(GRN_TEXT_VALUE(&buf), "tag_synonym", GRN_TEXT_LEN(&buf)) == 0) {
grn_obj_delete_hook(ctx, column, GRN_HOOK_SET, i);
break;
}
}
grn_obj_unlink(ctx, &data);
grn_obj_unlink(ctx, &buf);
}
nhooks = grn_obj_get_nhooks(ctx, column, GRN_HOOK_SET);
//grn_ctx_output_array_open(ctx, "RESULT", 1);
grn_ctx_output_int32(ctx, nhooks);
//grn_ctx_output_array_close(ctx);
return NULL;
}
示例10: exec_text_operator_text_text
static grn_bool
exec_text_operator_text_text(grn_ctx *ctx,
grn_operator op,
grn_obj *target,
grn_obj *query)
{
return exec_text_operator_raw_text_raw_text(ctx,
op,
GRN_TEXT_VALUE(target),
GRN_TEXT_LEN(target),
GRN_TEXT_VALUE(query),
GRN_TEXT_LEN(query));
}
示例11: stem_filter
static void
stem_filter(grn_ctx *ctx,
grn_token *current_token,
grn_token *next_token,
void *user_data)
{
grn_stem_token_filter *token_filter = user_data;
grn_obj *data;
if (GRN_CTX_GET_ENCODING(ctx) != GRN_ENC_UTF8) {
return;
}
data = grn_token_get_data(ctx, current_token);
if (token_filter->stemmer) {
sb_stemmer_delete(token_filter->stemmer);
}
{
/* TODO: Detect algorithm from the current token. */
const char *algorithm = "english";
const char *encoding = "UTF_8";
token_filter->stemmer = sb_stemmer_new(algorithm, encoding);
if (!token_filter->stemmer) {
GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT,
"[token-filter][stem] "
"failed to create stemmer: "
"algorithm=<%s>, encoding=<%s>",
algorithm, encoding);
return;
}
}
{
const sb_symbol *stemmed;
stemmed = sb_stemmer_stem(token_filter->stemmer,
GRN_TEXT_VALUE(data), GRN_TEXT_LEN(data));
if (stemmed) {
grn_token_set_data(ctx, next_token,
stemmed,
sb_stemmer_length(token_filter->stemmer));
} else {
GRN_PLUGIN_ERROR(ctx, GRN_NO_MEMORY_AVAILABLE,
"[token-filter][stem] "
"failed to allocate memory for stemmed word: <%.*s>",
(int)GRN_TEXT_LEN(data), GRN_TEXT_VALUE(data));
return;
}
}
}
示例12: func_snippet_tritonn
static grn_obj *
func_snippet_tritonn(grn_ctx *ctx, int nargs, grn_obj **args,
grn_user_data *user_data)
{
grn_obj *snippets = NULL;
if (nargs > 10) {
grn_obj *text = args[0];
grn_obj *snip = NULL;
unsigned int width = GRN_UINT64_VALUE(args[1]);
unsigned int max_n_results = GRN_UINT64_VALUE(args[2]);
grn_snip_mapping *mapping = NULL;
int flags = GRN_SNIP_COPY_TAG;
if(GRN_UINT64_VALUE(args[4])){
flags |= GRN_SNIP_SKIP_LEADING_SPACES;
}
if(GRN_UINT64_VALUE(args[5])){
mapping = GRN_SNIP_MAPPING_HTML_ESCAPE;
}
snip = grn_snip_open(ctx, flags, width, max_n_results, "", 0, "", 0, mapping);
if (snip) {
grn_rc rc;
unsigned int i;
if(GRN_TEXT_LEN(args[3])){
grn_obj * normalizer;
normalizer = grn_ctx_get(ctx, GRN_TEXT_VALUE(args[3]), GRN_TEXT_LEN(args[3]));
grn_snip_set_normalizer(ctx, snip, normalizer);
}
for(i = 8; i < (unsigned int)nargs; i += 3){
rc = grn_snip_add_cond(ctx, snip,
GRN_TEXT_VALUE(args[i]), GRN_TEXT_LEN(args[i]),
GRN_TEXT_VALUE(args[i + 1]), GRN_TEXT_LEN(args[i + 1]),
GRN_TEXT_VALUE(args[i + 2]), GRN_TEXT_LEN(args[i + 2]));
}
snippets = snippet_exec(ctx, snip, text, user_data, args);
grn_obj_close(ctx, snip);
}
}
if(!snippets){
snippets = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_VOID, 0);
}
return snippets;
}
示例13: 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;
}
示例14: proc_define_selector
static grn_obj *
proc_define_selector(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
{
uint32_t nvars;
grn_expr_var *vars;
grn_obj *outbuf = args[0];
grn_proc_get_info(ctx, user_data, &vars, &nvars, NULL);
if (grn_proc_create(ctx,
GRN_TEXT_VALUE(&vars[0].value),
GRN_TEXT_LEN(&vars[0].value),
NULL, proc_select, NULL, NULL, nvars - 1, vars + 1)) {
GRN_TEXT_PUT(ctx, outbuf, GRN_TEXT_VALUE(&vars[0].value), GRN_TEXT_LEN(&vars[0].value));
}
return outbuf;
}
示例15: rb_grn_view_record_new
VALUE
rb_grn_view_record_new (VALUE view, grn_obj *id)
{
return rb_grn_view_record_new_raw(view,
rb_str_new(GRN_TEXT_VALUE(id),
GRN_TEXT_LEN(id)));
}