Skip to content

Commit

Permalink
renamed grn_ctx_lookup() into grn_ctx_get(), grn_ctx_get() into grn_c…
Browse files Browse the repository at this point in the history
…tx_at()

* groonga.h (grn_ctx_lookup): renamed into grn_ctx_get.
* groonga.h (grn_ctx_get): renamed into grn_ctx_at.
  • Loading branch information
daijiro committed May 14, 2009
1 parent 922ce35 commit 206e68a
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 101 deletions.
8 changes: 4 additions & 4 deletions examples/index.c
Expand Up @@ -34,7 +34,7 @@ grn_index_create(grn_ctx *ctx, const char *path)
char buffer[PATH_MAX];
strcpy(buffer, path);
strcat(buffer, ".SEN");
if ((key_type = grn_ctx_get(ctx, GRN_DB_SHORTTEXT))) {
if ((key_type = grn_ctx_at(ctx, GRN_DB_SHORTTEXT))) {
if ((keys = grn_table_create(ctx, "<keys>", 6, buffer,
GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_PERSISTENT,
key_type, 0))) {
Expand All @@ -43,7 +43,7 @@ grn_index_create(grn_ctx *ctx, const char *path)
if ((lexicon = grn_table_create(ctx, "<lexicon>", 9, buffer,
GRN_OBJ_TABLE_PAT_KEY|GRN_OBJ_PERSISTENT,
key_type, 0))) {
if ((tokenizer = grn_ctx_get(ctx, GRN_DB_MECAB))) {
if ((tokenizer = grn_ctx_at(ctx, GRN_DB_MECAB))) {
grn_obj_set_info(ctx, lexicon, GRN_INFO_DEFAULT_TOKENIZER, tokenizer);
strcpy(buffer, path);
strcat(buffer, ".SEN.i");
Expand Down Expand Up @@ -75,12 +75,12 @@ grn_index_open(grn_ctx *ctx, const char *path)
char buffer[PATH_MAX];
strcpy(buffer, path);
strcat(buffer, ".SEN");
if ((key_type = grn_ctx_get(ctx, GRN_DB_SHORTTEXT))) {
if ((key_type = grn_ctx_at(ctx, GRN_DB_SHORTTEXT))) {
if ((keys = grn_table_open(ctx, "<keys>", 6, buffer))) {
strcpy(buffer, path);
strcat(buffer, ".SEN.l");
if ((lexicon = grn_table_open(ctx, "<lexicon>", 9, buffer))) {
if ((tokenizer = grn_ctx_get(ctx, GRN_DB_MECAB))) {
if ((tokenizer = grn_ctx_at(ctx, GRN_DB_MECAB))) {
grn_obj_set_info(ctx, lexicon, GRN_INFO_DEFAULT_TOKENIZER, tokenizer);
strcpy(buffer, path);
strcat(buffer, ".SEN.i");
Expand Down
16 changes: 8 additions & 8 deletions examples/kv.c
Expand Up @@ -64,11 +64,11 @@ column_put(void)
{
int i, s = 0;
grn_obj buf;
grn_obj *key_type = grn_ctx_get(&ctx, GRN_DB_SHORTTEXT);
grn_obj *key_type = grn_ctx_at(&ctx, GRN_DB_SHORTTEXT);
grn_obj *table = grn_table_create(&ctx, "<t1>", 4, NULL,
GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_PERSISTENT,
key_type, 0);
grn_obj *value_type = grn_ctx_get(&ctx, GRN_DB_TEXT);
grn_obj *value_type = grn_ctx_at(&ctx, GRN_DB_TEXT);
grn_obj *column = grn_column_create(&ctx, table, "c1", 2, NULL,
GRN_OBJ_PERSISTENT, value_type);
if (!table || !column) { return -1; }
Expand Down Expand Up @@ -105,8 +105,8 @@ column_get(void)
{
int i, s = 0;
grn_obj buf;
grn_obj *table = grn_ctx_lookup(&ctx, "<t1>", 4);
grn_obj *column = grn_ctx_lookup(&ctx, "<t1>.c1", 7);
grn_obj *table = grn_ctx_get(&ctx, "<t1>", 4);
grn_obj *column = grn_ctx_get(&ctx, "<t1>.c1", 7);
if (!table || !column) { return -1; }
GRN_TEXT_INIT(&buf);
for (i = 0; i < nloops; i++) {
Expand Down Expand Up @@ -149,7 +149,7 @@ table_put(void)
{
int i;
grn_obj buf;
grn_obj *key_type = grn_ctx_get(&ctx, GRN_DB_SHORTTEXT);
grn_obj *key_type = grn_ctx_at(&ctx, GRN_DB_SHORTTEXT);
grn_obj *table = grn_table_create(&ctx, "<t1>", 4, NULL,
GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_PERSISTENT,
key_type, value_size);
Expand Down Expand Up @@ -179,7 +179,7 @@ table_put2(void)
{
int i;
grn_obj keybuf, valbuf;
grn_obj *key_type = grn_ctx_get(&ctx, GRN_DB_SHORTTEXT);
grn_obj *key_type = grn_ctx_at(&ctx, GRN_DB_SHORTTEXT);
grn_obj *table = grn_table_create(&ctx, "<t1>", 4, NULL,
GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_PERSISTENT,
key_type, value_size);
Expand Down Expand Up @@ -211,7 +211,7 @@ table_put_allocate(void)
{
int i;
grn_obj *buf;
grn_obj *key_type = grn_ctx_get(&ctx, GRN_DB_SHORTTEXT);
grn_obj *key_type = grn_ctx_at(&ctx, GRN_DB_SHORTTEXT);
grn_obj *table = grn_table_create(&ctx, "<t1>", 4, NULL,
GRN_OBJ_TABLE_HASH_KEY|GRN_OBJ_PERSISTENT,
key_type, value_size);
Expand Down Expand Up @@ -244,7 +244,7 @@ table_get(void)
{
int i;
grn_obj buf;
grn_obj *table = grn_ctx_lookup(&ctx, "<t1>", 4);
grn_obj *table = grn_ctx_get(&ctx, "<t1>", 4);
if (!table) { return -1; }
GRN_TEXT_INIT(&buf);
for (i = 0; i < nloops; i++) {
Expand Down
8 changes: 4 additions & 4 deletions groonga.h
Expand Up @@ -372,17 +372,17 @@ GRN_API grn_rc grn_ctx_use(grn_ctx *ctx, grn_obj *db);
GRN_API grn_obj *grn_ctx_db(grn_ctx *ctx);

/**
* grn_ctx_lookup:
* grn_ctx_get:
* @name: 検索しようとするオブジェクトの名前。
* @name_size: @nameのbyte長。
*
* ctxが使用するdbからnameに対応するオブジェクトを検索して返す。
* nameに一致するオブジェクトが存在しなければNULLを返す。
**/
GRN_API grn_obj *grn_ctx_lookup(grn_ctx *ctx, const char *name, unsigned name_size);
GRN_API grn_obj *grn_ctx_get(grn_ctx *ctx, const char *name, unsigned name_size);

/**
* grn_ctx_get:
* grn_ctx_at:
* @id: 検索しようとするオブジェクトのid。
*
* ctx、またはctxが使用するdbからidに対応するオブジェクトを検索して返す。
Expand All @@ -407,7 +407,7 @@ typedef enum {
GRN_DB_MECAB,
} grn_builtin_type;

GRN_API grn_obj *grn_ctx_get(grn_ctx *ctx, grn_id id);
GRN_API grn_obj *grn_ctx_at(grn_ctx *ctx, grn_id id);

/**
* grn_type_create:
Expand Down
14 changes: 7 additions & 7 deletions lib/ctx.c
Expand Up @@ -1279,7 +1279,7 @@ grn_cell_clear(grn_ctx *ctx, grn_cell *o)
case GRN_TABLE_HASH_KEY :
case GRN_TABLE_PAT_KEY :
case GRN_TABLE_NO_KEY :
grn_obj_close(ctx, grn_ctx_get(ctx, o->u.o.id));
grn_obj_close(ctx, grn_ctx_at(ctx, o->u.o.id));
break;
case GRN_CELL_STR :
if (o->u.b.value) {
Expand Down Expand Up @@ -1512,15 +1512,15 @@ search(grn_ctx *ctx, grn_obj *qe, grn_proc_data *user_data,
grn_obj *res = argc > 3 ? (grn_obj *)argv[3].ptr : NULL;
// grn_obj *op = argc > 4 ? (grn_obj *)argv[4].ptr : NULL;
if (index->header.type == GRN_BULK) {
index = grn_ctx_lookup(ctx, GRN_BULK_HEAD(index), GRN_BULK_VSIZE(index));
index = grn_ctx_get(ctx, GRN_BULK_HEAD(index), GRN_BULK_VSIZE(index));
}
if (!query) { return GRN_INVALID_ARGUMENT; }
if (!index || index->header.type != GRN_COLUMN_INDEX) {
return GRN_INVALID_ARGUMENT;
}
if (!res) {
grn_obj *table;
if (!(table = grn_ctx_get(ctx, ((grn_db_obj *)index)->range))) {
if (!(table = grn_ctx_at(ctx, ((grn_db_obj *)index)->range))) {
return GRN_INVALID_ARGUMENT;
}
res = grn_table_create(ctx, NULL, 0, NULL,
Expand Down Expand Up @@ -1608,7 +1608,7 @@ grn_ctx_qe_init(grn_ctx *ctx)
sizeof(grn_ctx_qe),
GRN_OBJ_KEY_VAR_SIZE|GRN_HASH_TINY);
{
grn_proc *init = (grn_proc *)grn_ctx_lookup(ctx, "<proc:init>", 11);
grn_proc *init = (grn_proc *)grn_ctx_get(ctx, "<proc:init>", 11);
if (init) {
init->funcs[PROC_INIT](ctx, (grn_obj *)ctx->impl->qe, NULL, 0, NULL);
}
Expand Down Expand Up @@ -1697,7 +1697,7 @@ grn_ctx_qe_parse(grn_ctx *ctx, const char *key, int key_size)
char *tokbuf[17 + 1];
int i, n = grn_str_tok(head, GRN_BULK_VSIZE(str), ' ', tokbuf, 16, NULL);
if (n <= 17) {
grn_obj *obj = grn_ctx_lookup(ctx, head, tokbuf[0] - head);
grn_obj *obj = grn_ctx_get(ctx, head, tokbuf[0] - head);
if (obj && obj->header.type == GRN_PROC) {
if ((d->source = GRN_MALLOCN(grn_ctx_qe_source, 1))) {
d->source->func = ((grn_proc *)obj)->funcs[PROC_INIT];
Expand Down Expand Up @@ -1744,7 +1744,7 @@ grn_ctx_qe_get_(grn_ctx *ctx, grn_ctx_qe *qe)
if (qe->source) {
qe->value = qe_exec(ctx, qe->source);
} else {
qe->value = grn_ctx_lookup(ctx, key, key_size);
qe->value = grn_ctx_get(ctx, key, key_size);
}
}
return qe->value;
Expand Down Expand Up @@ -1787,7 +1787,7 @@ grn_ctx_qe_get(grn_ctx *ctx, const char *key, int key_size)
if (grn_ctx_qe_init(ctx)) { return NULL; }
if (!(qe = qe_at(ctx, key, key_size))) {
if (!(qe = grn_ctx_qe_parse(ctx, key, key_size))) {
return grn_ctx_lookup(ctx, key, key_size);
return grn_ctx_get(ctx, key, key_size);
}
}
return grn_ctx_qe_get_(ctx, qe);
Expand Down

0 comments on commit 206e68a

Please sign in to comment.