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

C++ GRN_TEXT_INIT函数代码示例

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

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



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

示例1: update_data

static void
update_data(grn_id record_id, unsigned int section,
            const gchar *old_name, const gchar *new_name)
{
    grn_obj old_value, new_value;
    const gchar *old_data, *new_data;

    GRN_TEXT_INIT(&old_value, GRN_OBJ_DO_SHALLOW_COPY);
    GRN_TEXT_INIT(&new_value, GRN_OBJ_DO_SHALLOW_COPY);

    if (old_name) {
        old_data = cut_get_fixture_data_string(old_name, NULL);
        GRN_TEXT_SET_REF(&old_value, old_data, strlen(old_data));
    }

    if (new_name) {
        new_data = cut_get_fixture_data_string(new_name, NULL);
        GRN_TEXT_SET_REF(&new_value, new_data, strlen(new_data));
    }

    grn_ii_column_update(context, inverted_index, record_id, section,
                         &old_value, &new_value, NULL);
    grn_obj_close(context, &old_value);
    grn_obj_close(context, &new_value);
}
开发者ID:kazu,项目名称:groonga,代码行数:25,代码来源:test-inverted-index.c


示例2: grn_test_view_collect_string

const GList *
grn_test_view_collect_string(grn_ctx          *context,
                             grn_obj          *view,
                             const gchar      *text_column_name)
{
  GList *records = NULL;
  grn_table_cursor *cursor;
  grn_obj id, value;
  grn_obj *text_column;

  cursor = grn_table_cursor_open(context, view, NULL, 0, NULL, 0,
                                 0, -1, GRN_CURSOR_ASCENDING);
  cut_assert_not_null(cursor);
  GRN_TEXT_INIT(&id, 0);
  GRN_TEXT_INIT(&value, 0);
  text_column = grn_obj_column(context, view,
                               text_column_name, strlen(text_column_name));
  while (grn_table_cursor_next_o(context, cursor, &id) == GRN_SUCCESS) {
    GRN_BULK_REWIND(&value);
    grn_obj_get_value_o(context, text_column, &id, &value);
    records = g_list_append(records, g_strndup(GRN_TEXT_VALUE(&value),
                                               GRN_TEXT_LEN(&value)));
  }
  grn_obj_unlink(context, &id);
  grn_obj_unlink(context, &value);
  grn_obj_unlink(context, text_column);
  gcut_take_list(records, g_free);

  grn_test_assert(grn_table_cursor_close(context, cursor));
  grn_test_assert_context(context);

  return records;
}
开发者ID:ryoqun,项目名称:groonga,代码行数:33,代码来源:grn-test-utils.c


示例3: table_put2

int
table_put2(void)
{
  int i;
  grn_obj keybuf, valbuf;
  grn_obj *key_type = grn_ctx_at(&ctx, GRN_DB_SHORT_TEXT);
  grn_obj *table = grn_table_create(&ctx, "<t1>", 4, NULL,
                                    GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_PERSISTENT,
                                    key_type, value_type);
  if (!table) { return -1; }
  for (i = 0; i < nloops; i++) {
    int key = GENKEY(i);
    GRN_TEXT_INIT(&keybuf, 0);
    grn_text_itoh(&ctx, &keybuf, key, key_size);
    {
      grn_id rid = grn_table_add(&ctx, table, GRN_BULK_HEAD(&keybuf), key_size, NULL);
      if (!rid) {
        fprintf(stderr, "table_lookup failed");
      } else {
        GRN_TEXT_INIT(&valbuf, 0);
        grn_text_itoh(&ctx, &valbuf, key, key_size);
        if (grn_obj_set_value(&ctx, table, rid, &valbuf, GRN_OBJ_SET)) {
          fprintf(stderr, "grn_obj_set_value failed");
        }
        grn_obj_close(&ctx, &valbuf);
      }
    }
    grn_obj_close(&ctx, &keybuf);
  }
  return 0;
}
开发者ID:darashi,项目名称:groonga,代码行数:31,代码来源:kv.c


示例4: table_get

int
table_get(void)
{
  int i;
  grn_obj buf;
  grn_obj *table = grn_ctx_get(&ctx, "<t1>", 4);
  if (!table) { return -1; }
  GRN_TEXT_INIT(&buf, 0);
  for (i = 0; i < nloops; i++) {
    int key = GENKEY(i);
    GRN_BULK_REWIND(&buf);
    grn_text_itoh(&ctx, &buf, key, key_size);
    {
      grn_id rid = grn_table_get(&ctx, table, GRN_BULK_HEAD(&buf), key_size);
      if (!rid) {
        fprintf(stderr, "table_lookup failed");
      } else {
        grn_obj obj, *p;
        GRN_TEXT_INIT(&obj, 0);
        p = grn_obj_get_value(&ctx, table, rid, &obj);
        if (!p) {
          fprintf(stderr, "grn_obj_get_value failed\n");
        } else {
          if (memcmp(GRN_BULK_HEAD(p), GRN_BULK_HEAD(&buf), value_size)) {
            fprintf(stderr, "value unmatch\n");
          }
          grn_obj_close(&ctx, p);
        }
      }
    }
  }
  grn_obj_close(&ctx, &buf);
  return 0;
}
开发者ID:darashi,项目名称:groonga,代码行数:34,代码来源:kv.c


示例5: 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);
}
开发者ID:cosmo0920,项目名称:groonga,代码行数:26,代码来源:load.c


示例6: grn_tokenizer_register

grn_rc
grn_tokenizer_register(grn_ctx *ctx, const char *plugin_name_ptr,
                       unsigned int plugin_name_length,
                       grn_proc_func *init, grn_proc_func *next,
                       grn_proc_func *fin)
{
  grn_expr_var vars[] = {
    { NULL, 0 },
    { NULL, 0 },
    { NULL, 0 }
  };
  GRN_TEXT_INIT(&vars[0].value, 0);
  GRN_TEXT_INIT(&vars[1].value, 0);
  GRN_UINT32_INIT(&vars[2].value, 0);

  {
    /*
      grn_proc_create() registers a plugin to the database which is associated
      with `ctx'. A returned object must not be finalized here.
     */
    grn_obj * const obj = grn_proc_create(ctx, plugin_name_ptr,
                                          plugin_name_length,
                                          GRN_PROC_TOKENIZER,
                                          init, next, fin, 3, vars);
    if (obj == NULL) {
      GRN_PLUGIN_ERROR(ctx, GRN_TOKENIZER_ERROR, "grn_proc_create() failed");
      return ctx->rc;
    }
  }
  return GRN_SUCCESS;
}
开发者ID:AkioKanno,项目名称:groonga,代码行数:31,代码来源:tokenizer.c


示例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);
}
开发者ID:cosmo0920,项目名称:groonga,代码行数:58,代码来源:tsv.c


示例8: 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,
                                                &current_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;
}
开发者ID:digideskio,项目名称:groonga,代码行数:57,代码来源:token_cursor.c


示例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;
}
开发者ID:naoa,项目名称:groonga-tag-synonym,代码行数:53,代码来源:tag_synonym.c


示例10: ngx_http_groonga_handler_create_data

static ngx_int_t
ngx_http_groonga_handler_create_data(ngx_http_request_t *r,
                                     ngx_http_groonga_handler_data_t **data_return)
{
  ngx_int_t rc;

  ngx_http_groonga_loc_conf_t *location_conf;

  ngx_http_cleanup_t *cleanup;
  ngx_http_groonga_handler_data_t *data;

  grn_ctx *context;

  location_conf = ngx_http_get_module_loc_conf(r, ngx_http_groonga_module);

  cleanup = ngx_http_cleanup_add(r, sizeof(ngx_http_groonga_handler_data_t));
  cleanup->handler = ngx_http_groonga_handler_cleanup;
  data = cleanup->data;
  *data_return = data;

  context = &(data->context);
  rc = ngx_http_groonga_context_init(context, location_conf,
                                     r->pool, r->connection->log);
  if (rc != NGX_OK) {
    return rc;
  }

  data->initialized = GRN_TRUE;

  data->raw.processed = GRN_FALSE;
  data->raw.header_sent = GRN_FALSE;
  data->raw.r = r;
  data->raw.rc = NGX_OK;
  data->raw.free_chain = NULL;
  data->raw.busy_chain = NULL;

  GRN_TEXT_INIT(&(data->typed.head), GRN_NO_FLAGS);
  GRN_TEXT_INIT(&(data->typed.body), GRN_NO_FLAGS);
  GRN_TEXT_INIT(&(data->typed.foot), GRN_NO_FLAGS);

  grn_ctx_use(context, grn_ctx_db(&(location_conf->context)));
  rc = ngx_http_groonga_context_check_error(r->connection->log, context);
  if (rc != NGX_OK) {
    return rc;
  }

  grn_ctx_recv_handler_set(context,
                           ngx_http_groonga_context_receive_handler,
                           data);

  return NGX_OK;
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:52,代码来源:ngx_http_groonga_module.c


示例11: mroonga_escape_init

MRN_API my_bool mroonga_escape_init(UDF_INIT *initid, UDF_ARGS *args,
                                    char *message)
{
  EscapeInfo *info = NULL;

  initid->ptr = NULL;
  if (!(1 <= args->arg_count && args->arg_count <= 2)) {
    sprintf(message,
            "mroonga_escape(): Incorrect number of arguments: %u for 1..2",
            args->arg_count);
    goto error;
  }
  if (args->arg_type[0] != STRING_RESULT) {
    strcpy(message,
           "mroonga_escape(): The 1st argument must be query as string");
    goto error;
  }
  if (args->arg_count == 2) {
    if (args->arg_type[1] != STRING_RESULT) {
      strcpy(message,
             "mroonga_escape(): "
             "The 2st argument must be escape target characters as string");
      goto error;
    }
  }

  initid->maybe_null = 1;
  initid->const_item = 0;

  info = (EscapeInfo *)mrn_my_malloc(sizeof(EscapeInfo),
                                     MYF(MY_WME | MY_ZEROFILL));
  if (!info) {
    strcpy(message, "mroonga_escape(): out of memory");
    goto error;
  }

  grn_ctx_init(&(info->ctx), 0);
  GRN_TEXT_INIT(&(info->target_characters), 0);
  GRN_TEXT_INIT(&(info->escaped_query), 0);

  initid->ptr = (char *)info;

  return FALSE;

error:
  if (info) {
    grn_ctx_fin(&(info->ctx));
    my_free(info);
  }
  return TRUE;
}
开发者ID:skyformat99,项目名称:mroonga,代码行数:51,代码来源:mrn_udf_escape.cpp


示例12: grn_command_input_add

grn_obj *
grn_command_input_add(grn_ctx *ctx,
                      grn_command_input *input,
                      const char *name,
                      int name_size,
                      grn_bool *added)
{
  grn_obj *argument = NULL;
  /* TODO: Use grn_bool */
  int internal_added = GRN_FALSE;

  GRN_API_ENTER;

  if (name_size == -1) {
    name_size = strlen(name);
  }
  if (input->arguments) {
    grn_hash_add(ctx, input->arguments, name, name_size, (void **)&argument,
                 &internal_added);
    if (internal_added) {
      GRN_TEXT_INIT(argument, 0);
    }
  }
  if (added) {
    *added = internal_added;
  }

  GRN_API_RETURN(argument);
}
开发者ID:AkioKanno,项目名称:groonga,代码行数:29,代码来源:command.c


示例13: delimited_init

static grn_obj *
delimited_init(grn_ctx *ctx, grn_obj *table, grn_user_data *user_data,
               uint8_t *delimiter, uint32_t delimiter_len)
{
  grn_obj *str;
  int nflags = 0;
  grn_delimited_tokenizer *token;
  grn_obj_flags table_flags;
  if (!(str = grn_ctx_pop(ctx))) {
    ERR(GRN_INVALID_ARGUMENT, "missing argument");
    return NULL;
  }
  if (!(token = GRN_MALLOC(sizeof(grn_delimited_tokenizer)))) { return NULL; }
  user_data->ptr = token;
  token->delimiter = delimiter;
  token->delimiter_len = delimiter_len;
  token->pos = 0;
  grn_table_get_info(ctx, table, &table_flags, &token->encoding, NULL);
  nflags |= (table_flags & GRN_OBJ_KEY_NORMALIZE);
  if (!(token->nstr = grn_str_open_(ctx, GRN_TEXT_VALUE(str), GRN_TEXT_LEN(str),
                                    nflags, token->encoding))) {
    GRN_FREE(token);
    ERR(GRN_TOKENIZER_ERROR, "grn_str_open failed at grn_token_open");
    return NULL;
  }
  token->next = (unsigned char *)token->nstr->norm;
  token->end = token->next + token->nstr->norm_blen;
  token->len = token->nstr->length;
  GRN_TEXT_INIT(&token->curr_, GRN_OBJ_DO_SHALLOW_COPY);
  GRN_UINT32_INIT(&token->stat_, 0);
  return NULL;
}
开发者ID:ryoqun,项目名称:groonga,代码行数:32,代码来源:token.c


示例14: grn_test_table_collect_string

const GList *
grn_test_table_collect_string(grn_ctx          *context,
                              grn_obj          *table,
                              const gchar      *text_column_name)
{
  GList *records = NULL;
  grn_table_cursor *cursor;
  grn_id id;
  grn_obj *text_column;
  grn_obj value;

  cursor = grn_table_cursor_open(context, table, NULL, 0, NULL, 0,
                                 0, -1, GRN_CURSOR_ASCENDING);
  grn_test_assert_context(context);
  text_column = grn_obj_column(context, table,
                               text_column_name, strlen(text_column_name));
  GRN_TEXT_INIT(&value, 0);
  while ((id = grn_table_cursor_next(context, cursor)) != GRN_ID_NIL) {
    GRN_BULK_REWIND(&value);
    grn_obj_get_value(context, text_column, id, &value);
    records = g_list_append(records, g_strndup(GRN_TEXT_VALUE(&value),
                                               GRN_TEXT_LEN(&value)));
  }
  grn_obj_unlink(context, &value);
  grn_obj_unlink(context, text_column);
  gcut_take_list(records, g_free);
  grn_test_assert(grn_table_cursor_close(context, cursor));
  grn_test_assert_context(context);

  return records;
}
开发者ID:ryoqun,项目名称:groonga,代码行数:31,代码来源:grn-test-utils.c


示例15: command_schema_output_plugins

static void
command_schema_output_plugins(grn_ctx *ctx)
{
  grn_obj plugin_names;
  unsigned int i, n;

  GRN_TEXT_INIT(&plugin_names, GRN_OBJ_VECTOR);

  grn_plugin_get_names(ctx, &plugin_names);

  grn_ctx_output_cstr(ctx, "plugins");

  n = grn_vector_size(ctx, &plugin_names);
  grn_ctx_output_map_open(ctx, "plugins", n);
  for (i = 0; i < n; i++) {
    const char *name;
    unsigned int name_size;

    name_size = grn_vector_get_element(ctx, &plugin_names, i, &name, NULL, NULL);
    grn_ctx_output_str(ctx, name, name_size);

    grn_ctx_output_map_open(ctx, "plugin", 1);
    grn_ctx_output_cstr(ctx, "name");
    grn_ctx_output_str(ctx, name, name_size);
    grn_ctx_output_map_close(ctx);
  }
  grn_ctx_output_map_close(ctx);

  GRN_OBJ_FIN(ctx, &plugin_names);
}
开发者ID:XLPE,项目名称:groonga,代码行数:30,代码来源:proc_schema.c


示例16: mrb_grn_expression_allocate_constant

static mrb_value
mrb_grn_expression_allocate_constant(mrb_state *mrb, mrb_value self)
{
  grn_ctx *ctx = (grn_ctx *)mrb->ud;
  grn_obj *expr;
  mrb_value mrb_object;
  grn_obj *grn_object;

  mrb_get_args(mrb, "o", &mrb_object);
  expr = DATA_PTR(self);

  switch (mrb_type(mrb_object)) {
  case MRB_TT_STRING:
    grn_object = grn_expr_alloc_const(ctx, expr);
    if (!grn_object) {
      grn_mrb_ctx_check(mrb);
    }
    GRN_TEXT_INIT(grn_object, 0);
    GRN_TEXT_SET(ctx, grn_object,
                 RSTRING_PTR(mrb_object), RSTRING_LEN(mrb_object));
    break;
  default:
    mrb_raisef(mrb, E_ARGUMENT_ERROR, "unsupported type: %S", mrb_object);
    break;
  }

  return grn_mrb_value_from_grn_obj(mrb, grn_object);
}
开发者ID:AkioKanno,项目名称:groonga,代码行数:28,代码来源:mrb_expr.c


示例17: grn_db_init_builtin_tokenizers

grn_rc
grn_db_init_builtin_tokenizers(grn_ctx *ctx)
{
  grn_obj *obj, results[2];
  GRN_UINT32_INIT(&results[0], 0);
  GRN_TEXT_INIT(&results[1], 0);

  obj = grn_proc_create(ctx, "<token:delimit>", 15, NULL,
                        delimit_init, delimited_next, delimited_fin, 1, 2, results);
  if (!obj || ((grn_db_obj *)obj)->id != GRN_DB_DELIMIT) { return GRN_FILE_CORRUPT; }
  obj = grn_proc_create(ctx, "<token:unigram>", 15, NULL,
                        unigram_init, ngram_next, ngram_fin, 1, 2, results);
  if (!obj || ((grn_db_obj *)obj)->id != GRN_DB_UNIGRAM) { return GRN_FILE_CORRUPT; }
  obj = grn_proc_create(ctx, "<token:bigram>", 14, NULL,
                        bigram_init, ngram_next, ngram_fin, 1, 2, results);
  if (!obj || ((grn_db_obj *)obj)->id != GRN_DB_BIGRAM) { return GRN_FILE_CORRUPT; }
  obj = grn_proc_create(ctx, "<token:trigram>", 15, NULL,
                        trigram_init, ngram_next, ngram_fin, 1, 2, results);
  if (!obj || ((grn_db_obj *)obj)->id != GRN_DB_TRIGRAM) { return GRN_FILE_CORRUPT; }
#ifndef NO_MECAB
  obj = grn_proc_create(ctx, "<token:mecab>", 13, NULL,
                        mecab_init, mecab_next, mecab_fin, 1, 2, results);
#endif /* NO_MECAB */
  if (!obj || ((grn_db_obj *)obj)->id != GRN_DB_MECAB) { return GRN_FILE_CORRUPT; }
  return GRN_SUCCESS;
}
开发者ID:ikdttr,项目名称:groonga,代码行数:26,代码来源:token.c


示例18: pat_get

int
pat_get(const char *path)
{
  int i;
  grn_obj buf;
  grn_pat *pat = grn_pat_open(&ctx, path);
  if (!pat) { return -1; }
  GRN_TEXT_INIT(&buf, 0);
  for (i = 0; i < nloops; i++) {
    int key = GENKEY(i);
    GRN_BULK_REWIND(&buf);
    grn_text_itoh(&ctx, &buf, key, key_size);
    {
      void *value;
      grn_id rid = grn_pat_get(&ctx, pat, GRN_BULK_HEAD(&buf), key_size, &value);
      if (!rid) {
        fprintf(stderr, "table_lookup failed");
      } else {
        if (memcmp(value, GRN_BULK_HEAD(&buf), value_size)) {
          fprintf(stderr, "value unmatch %d: %d != %d\n", i, *((int *)value), key);
        }
      }
    }
  }
  grn_obj_close(&ctx, &buf);
  grn_pat_close(&ctx, pat);
  return 0;
}
开发者ID:darashi,项目名称:groonga,代码行数:28,代码来源:kv.c


示例19: 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;
    }
  }
}
开发者ID:cosmo0920,项目名称:groonga,代码行数:31,代码来源:load.c


示例20: mrb_grn_cache_fetch

static mrb_value
mrb_grn_cache_fetch(mrb_state *mrb, mrb_value self)
{
  grn_ctx *ctx = (grn_ctx *)mrb->ud;
  grn_cache *cache;
  char *key;
  mrb_int key_size;
  grn_rc rc;
  grn_obj cache_value;
  mrb_value mrb_cache_value;

  cache = DATA_PTR(self);
  mrb_get_args(mrb, "s", &key, &key_size);

  GRN_TEXT_INIT(&cache_value, 0);
  rc = grn_cache_fetch(ctx, cache, key, key_size, &cache_value);
  if (rc == GRN_SUCCESS) {
    mrb_cache_value = grn_mrb_value_from_bulk(mrb, &cache_value);
  } else {
    mrb_cache_value = mrb_nil_value();
  }
  GRN_OBJ_FIN(ctx, &cache_value);

  return mrb_cache_value;
}
开发者ID:cosmo0920,项目名称:groonga,代码行数:25,代码来源:mrb_cache.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GRN_TEXT_LEN函数代码示例发布时间:2022-05-30
下一篇:
C++ GRN_OBJ_FIN函数代码示例发布时间: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