grn_ctx is the most important object. grn_ctx keeps the current infomation such as:
grn_ctx provides platform features such as:
Most APIs receive grn_ctx as the first argument.
You can't use the same grn_ctx from two or more threads. You need to create a grn_ctx for a thread. You can use two or more grn_ctx in a thread but it is not needed for usual use-case.
TODO...
TODO...
ctxを初期化します。
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
ctxの管理するメモリを解放し、使用を終了します。
If ctx is initialized by grn_ctx_open() not grn_ctx_init(), you need to use grn_ctx_close() instead of grn_ctx_fin().
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
初期化された grn_ctx オブジェクトを返します。
grn_ctx_init() で初期化された grn_ctx オブジェクトは構造体の実体をAPIの呼び元で確保するのに対して、 grn_ctx_open() ではGroongaライブラリの内部で、実体を確保します。 どちらで初期化された grn_ctx も、 grn_ctx_fin() で解放できます。 grn_ctx_open() で確保した grn_ctx 構造体に関しては、grn_ctx_fin() で解放した後に、その grn_ctx で作成した grn_obj を grn_obj_close() によって解放しても問題ありません。
Parameters: |
|
---|---|
Returns: | 初期化された grn_ctx オブジェクトを返します。 |
It calls grn_ctx_fin() and frees allocated memory for ctx by grn_ctx_open().
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
ctxを破棄するときに呼ばれる関数を設定します。
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
command_versionを返します。
command_versionを変更します。
Parameters: |
|
---|
ctxが操作対象とするdbを指定します。NULLを指定した場合は、dbを操作しない状態(init直後の状態)になります。
Don't use it with grn_ctx that has GRN_CTX_PER_DB flag.
Parameters: |
|
---|
ctxが使用するdbからnameに対応するオブジェクトを検索して返す。nameに一致するオブジェクトが存在しなければNULLを返す。
Parameters: |
|
---|
ctx、またはctxが使用するdbからidに対応するオブジェクトを検索して返す。idに一致するオブジェクトが存在しなければNULLを返す。
Parameters: |
|
---|
It pushes all tables in the database of ctx into tables_buffer. tables_buffer should be initialized as GRN_PVECTOR. You can use GRN_PTR_INIT() with GRN_OBJ_VECTOR flags to initialize tables_buffer.
Here is an example:
grn_rc rc;
grn_obj tables;
int i;
int n_tables;
GRN_PTR_INIT(&tables, GRN_OBJ_VECTOR, GRN_ID_NIL);
rc = grn_ctx_get_all_tables(ctx, &tables);
if (rc != GRN_SUCCESS) {
GRN_OBJ_FIN(ctx, &tables);
/* Handle error. */
return;
}
n_tables = GRN_BULK_VSIZE(&tables) / sizeof(grn_obj *);
for (i = 0; i < n_tables; i++) {
grn_obj *table = GRN_PTR_VALUE_AT(&tables, i);
/* Use table. */
}
/* Free resources. */
for (i = 0; i < n_tables; i++) {
grn_obj *table = GRN_PTR_VALUE_AT(&tables, i);
grn_obj_unlink(ctx, table);
}
GRN_OBJ_FIN(ctx, &tables);
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
Gets the current output type of the context.
Normally, this function isn't needed.
Parameters: |
|
---|---|
Returns: | The output type of the context. |
Sets the new output type to the context. It is used by executing a command by grn_expr_exec(). If you use grn_ctx_send(), the new output type isn't used. grn_ctx_send() sets output type from command line internally.
Normally, this function isn't needed.
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |