Groonga
Loading...
Searching...
No Matches
table.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _grn_table_sort_key
 
struct  _grn_table_group_result
 

Macros

#define GRN_TABLE_MAX_KEY_SIZE   (0x1000)
 
#define GRN_TABLE_OPEN_OR_CREATE(ctx, name, name_size, path, flags, key_type, value_type, table)
 
#define GRN_CURSOR_ASCENDING   (0x00 << 0)
 
#define GRN_CURSOR_DESCENDING   (0x01 << 0)
 
#define GRN_CURSOR_GE   (0x00 << 1)
 
#define GRN_CURSOR_GT   (0x01 << 1)
 
#define GRN_CURSOR_LE   (0x00 << 2)
 
#define GRN_CURSOR_LT   (0x01 << 2)
 
#define GRN_CURSOR_BY_KEY   (0x00 << 3)
 
#define GRN_CURSOR_BY_ID   (0x01 << 3)
 
#define GRN_CURSOR_PREFIX   (0x01 << 4)
 
#define GRN_CURSOR_SIZE_BY_BIT   (0x01 << 5)
 
#define GRN_CURSOR_RK   (0x01 << 6)
 
#define GRN_TABLE_EACH(ctx, table, head, tail, id, key, key_size, value, block)
 
#define GRN_TABLE_EACH_BEGIN(ctx, table, cursor, id)
 
#define GRN_TABLE_EACH_BEGIN_FLAGS(ctx, table, cursor, id, flags)
 
#define GRN_TABLE_EACH_BEGIN_MIN(ctx, table, cursor, id, min, min_size, flags)
 
#define GRN_TABLE_EACH_END(ctx, cursor)
 
#define GRN_TABLE_SORT_ASC   (0x00 << 0)
 Sort in ascending order.
 
#define GRN_TABLE_SORT_DESC   (0x01 << 0)
 Sort in descending order.
 
#define GRN_TABLE_GROUP_CALC_COUNT   (0x01 << 3)
 
#define GRN_TABLE_GROUP_CALC_MAX   (0x01 << 4)
 
#define GRN_TABLE_GROUP_CALC_MIN   (0x01 << 5)
 
#define GRN_TABLE_GROUP_CALC_SUM   (0x01 << 6)
 
#define GRN_TABLE_GROUP_CALC_AVG   GRN_TABLE_GROUP_CALC_MEAN
 
#define GRN_TABLE_GROUP_CALC_MEAN   (0x01 << 7)
 
#define GRN_TABLE_GROUP_CALC_AGGREGATOR   (0x01 << 8)
 
#define GRN_TABLE_GROUP_LIMIT   (0x01 << 9)
 
#define GRN_TABLE_GROUP_KEY_VECTOR_EXPANSION_POWER_SET   (0x01 << 10)
 

Typedefs

typedef grn_rc(* grn_table_cursor_foreach_func) (grn_ctx *ctx, grn_table_cursor *cursor, grn_id id, void *user_data)
 
typedef struct _grn_table_sort_key grn_table_sort_key
 
typedef unsigned char grn_table_sort_flags
 
typedef struct _grn_table_group_result grn_table_group_result
 
typedef uint32_t grn_table_group_flags
 
typedef struct _grn_table_group_aggregator grn_table_group_aggregator
 
typedef struct _grn_table_selector grn_table_selector
 

Functions

GRN_API grn_objgrn_table_create (grn_ctx *ctx, const char *name, unsigned int name_size, const char *path, grn_table_flags flags, grn_obj *key_type, grn_obj *value_type)
 Define a new table in the DB used by ctx.
 
GRN_API grn_objgrn_table_create_similar (grn_ctx *ctx, const char *name, uint32_t name_size, const char *path, grn_obj *base_table)
 
GRN_API grn_id grn_table_add (grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_size, int *added)
 Add a new record with key to the table and return its ID. If key already exists in the table, returns the ID of the record. For tables with GRN_OBJ_TABLE_NO_KEY, key and key_size are ignored.
 
GRN_API grn_id grn_table_get (grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_size)
 It finds a record that has key parameter and returns ID of the found record. If table parameter is a database, it finds an object (table, column and so on) that has key parameter and returns ID of the found object.
 
GRN_API grn_id grn_table_at (grn_ctx *ctx, grn_obj *table, grn_id id)
 Search the table for a record of ID and return the specified ID if it exists, or GRN_ID_NIL if it does not.
 
GRN_API grn_id grn_table_lcp_search (grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_size)
 Execute longest common prefix (LCP) search and return ID found.
 
GRN_API int grn_table_get_key (grn_ctx *ctx, grn_obj *table, grn_id id, void *keybuf, int buf_size)
 Get the key assigned to the ID. If the size of the key found is larger than buf_size, it is not stored in keybuf.
 
GRN_API grn_rc grn_table_delete (grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_size)
 Delete the record matching the key in the table.
 
GRN_API grn_rc grn_table_delete_by_id (grn_ctx *ctx, grn_obj *table, grn_id id)
 Delete the record matching the ID in the table.
 
GRN_API grn_rc grn_table_update_by_id (grn_ctx *ctx, grn_obj *table, grn_id id, const void *dest_key, unsigned int dest_key_size)
 Update the key of the record matching ID in the table. This operation supports only GRN_TABLE_DAT_KEY.
 
GRN_API grn_rc grn_table_update (grn_ctx *ctx, grn_obj *table, const void *src_key, unsigned int src_key_size, const void *dest_key, unsigned int dest_key_size)
 Change the key of the record matching the src_key of the table. Specify the new key and its byte length in dest_key and dest_key_size. This operation is allowed only for table of type GRN_TABLE_DAT_KEY.
 
GRN_API grn_rc grn_table_truncate (grn_ctx *ctx, grn_obj *table)
 Delete all records in table.
 
GRN_API grn_table_cursorgrn_table_cursor_open (grn_ctx *ctx, grn_obj *table, const void *min, unsigned int min_size, const void *max, unsigned int max_size, int offset, int limit, int flags)
 Creates and returns a cursor to retrieve the records registered in the table in order.
 
GRN_API grn_rc grn_table_cursor_close (grn_ctx *ctx, grn_table_cursor *tc)
 Free the cursor created by grn_table_cursor_open()
 
GRN_API grn_id grn_table_cursor_next (grn_ctx *ctx, grn_table_cursor *tc)
 Move the cursur forward to the next and return its record ID. Return GRN_ID_NIL when the end is reached.
 
GRN_API int grn_table_cursor_get_key (grn_ctx *ctx, grn_table_cursor *tc, void **key)
 Sets the key of the current record in cursor to key parameter and returns its length.
 
GRN_API int grn_table_cursor_get_value (grn_ctx *ctx, grn_table_cursor *tc, void **value)
 Sets the value of the current record in cursor to value parameter and returns its length.
 
GRN_API uint32_t grn_table_cursor_get_key_value (grn_ctx *ctx, grn_table_cursor *tc, void **key, uint32_t *key_size, void **value)
 
GRN_API grn_rc grn_table_cursor_set_value (grn_ctx *ctx, grn_table_cursor *tc, const void *value, int flags)
 Set value to the current record according to flags
 
GRN_API grn_rc grn_table_cursor_delete (grn_ctx *ctx, grn_table_cursor *tc)
 Delete the current record for cursor.
 
GRN_API size_t grn_table_cursor_get_max_n_records (grn_ctx *ctx, grn_table_cursor *cursor)
 
GRN_API grn_objgrn_table_cursor_table (grn_ctx *ctx, grn_table_cursor *tc)
 Return the table of cursor.
 
GRN_API grn_objgrn_index_cursor_open (grn_ctx *ctx, grn_table_cursor *tc, grn_obj *index, grn_id rid_min, grn_id rid_max, int flags)
 Create a cursor that returns postings in GRN_OBJ_COLUMN_INDEX.
 
GRN_API grn_objgrn_index_cursor_get_index_column (grn_ctx *ctx, grn_obj *index_cursor)
 
GRN_API grn_rc grn_index_cursor_set_term_id (grn_ctx *ctx, grn_obj *index_cursor, grn_id term_id)
 
GRN_API grn_rc grn_index_cursor_set_section_id (grn_ctx *ctx, grn_obj *index_cursor, uint32_t section_id)
 
GRN_API uint32_t grn_index_cursor_get_section_id (grn_ctx *ctx, grn_obj *index_cursor)
 
GRN_API grn_rc grn_index_cursor_set_scale (grn_ctx *ctx, grn_obj *index_cursor, float scale)
 
GRN_API grn_rc grn_index_cursor_set_scales (grn_ctx *ctx, grn_obj *index_cursor, float *scales, size_t n_scales)
 
GRN_API grn_rc grn_index_cursor_set_start_position (grn_ctx *ctx, grn_obj *index_cursor, uint32_t position)
 
GRN_API grn_rc grn_index_cursor_reset_start_position (grn_ctx *ctx, grn_obj *index_cursor)
 
GRN_API uint32_t grn_index_cursor_get_start_position (grn_ctx *ctx, grn_obj *index_cursor)
 
GRN_API grn_postinggrn_index_cursor_next (grn_ctx *ctx, grn_obj *index_cursor, grn_id *term_id)
 Retrieve the current posting information and move the cursor to the the next.
 
GRN_API grn_rc grn_table_cursor_foreach (grn_ctx *ctx, grn_table_cursor *cursor, grn_table_cursor_foreach_func func, void *user_data)
 
GRN_API int grn_table_sort (grn_ctx *ctx, grn_obj *table, int offset, int limit, grn_obj *result, grn_table_sort_key *keys, int n_keys)
 Sort the records in table and store the results in result
 
GRN_API grn_table_group_aggregatorgrn_table_group_aggregator_open (grn_ctx *ctx)
 
GRN_API grn_rc grn_table_group_aggregator_close (grn_ctx *ctx, grn_table_group_aggregator *aggregator)
 
GRN_API grn_rc grn_table_group_aggregator_set_output_column_name (grn_ctx *ctx, grn_table_group_aggregator *aggregator, const char *name, int32_t name_len)
 
GRN_API const char * grn_table_group_aggregator_get_output_column_name (grn_ctx *ctx, grn_table_group_aggregator *aggregator, uint32_t *len)
 
GRN_API grn_rc grn_table_group_aggregator_set_output_column_type (grn_ctx *ctx, grn_table_group_aggregator *aggregator, grn_obj *type)
 
GRN_API grn_objgrn_table_group_aggregator_get_output_column_type (grn_ctx *ctx, grn_table_group_aggregator *aggregator)
 
GRN_API grn_rc grn_table_group_aggregator_set_output_column_flags (grn_ctx *ctx, grn_table_group_aggregator *aggregator, grn_column_flags flags)
 
GRN_API grn_column_flags grn_table_group_aggregator_get_output_column_flags (grn_ctx *ctx, grn_table_group_aggregator *aggregator)
 
GRN_API grn_rc grn_table_group_aggregator_set_expression (grn_ctx *ctx, grn_table_group_aggregator *aggregator, const char *expression, int32_t expression_len)
 
GRN_API const char * grn_table_group_aggregator_get_expression (grn_ctx *ctx, grn_table_group_aggregator *aggregator, uint32_t *expression_len)
 
GRN_API grn_rc grn_table_group (grn_ctx *ctx, grn_obj *table, grn_table_sort_key *keys, int n_keys, grn_table_group_result *results, int n_results)
 Group the records in the table.
 
GRN_API grn_table_sort_keygrn_table_group_keys_parse (grn_ctx *ctx, grn_obj *table, const char *raw_sort_keys, int32_t raw_sort_keys_size, uint32_t *n_keys)
 
GRN_API grn_rc grn_table_setoperation (grn_ctx *ctx, grn_obj *table1, grn_obj *table2, grn_obj *res, grn_operator op)
 Execute the set operation of table1 and table2 according to the specification of op and store the result into res.
 
GRN_API grn_rc grn_table_difference (grn_ctx *ctx, grn_obj *table1, grn_obj *table2, grn_obj *res1, grn_obj *res2)
 Delete duplicated records in table1 and table2.
 
GRN_API int grn_table_columns (grn_ctx *ctx, grn_obj *table, const char *name, unsigned int name_size, grn_obj *res)
 Store the column IDs of the table starting with name in res.
 
GRN_API unsigned int grn_table_size (grn_ctx *ctx, grn_obj *table)
 Return the number of records registered in the table.
 
GRN_API grn_rc grn_table_rename (grn_ctx *ctx, grn_obj *table, const char *name, unsigned int name_size)
 Rename table to name. All columns of the table are renamed at the same time. The table must be a persistent object.
 
GRN_API grn_objgrn_table_select (grn_ctx *ctx, grn_obj *table, grn_obj *expr, grn_obj *result_set, grn_operator op)
 
GRN_API grn_table_sort_keygrn_table_sort_key_from_str (grn_ctx *ctx, const char *str, unsigned int str_size, grn_obj *table, uint32_t *nkeys)
 
GRN_API grn_table_sort_keygrn_table_sort_keys_parse (grn_ctx *ctx, grn_obj *table, const char *raw_sort_keys, int32_t raw_sort_keys_size, uint32_t *n_keys)
 
GRN_API grn_rc grn_table_sort_key_close (grn_ctx *ctx, grn_table_sort_key *keys, uint32_t nkeys)
 
GRN_API bool grn_table_is_grouped (grn_ctx *ctx, grn_obj *table)
 
GRN_API unsigned int grn_table_max_n_subrecs (grn_ctx *ctx, grn_obj *table)
 
GRN_API grn_objgrn_table_create_for_group (grn_ctx *ctx, const char *name, unsigned int name_size, const char *path, grn_obj *group_key, grn_obj *value_type, uint32_t max_n_subrecs)
 
GRN_API unsigned int grn_table_get_subrecs (grn_ctx *ctx, grn_obj *table, grn_id id, grn_id *subrecbuf, int *scorebuf, int buf_size)
 
GRN_API grn_objgrn_table_tokenize (grn_ctx *ctx, grn_obj *table, const char *str, unsigned int str_len, grn_obj *buf, bool addp)
 
GRN_API grn_rc grn_table_apply_expr (grn_ctx *ctx, grn_obj *table, grn_obj *output_column, grn_obj *expr)
 
GRN_API grn_id grn_table_find_reference_object (grn_ctx *ctx, grn_obj *table)
 
GRN_API grn_rc grn_table_copy (grn_ctx *ctx, grn_obj *from, grn_obj *to)
 
GRN_API grn_rc grn_table_get_duplicated_keys (grn_ctx *ctx, grn_obj *table, grn_obj **duplicated_keys)
 
GRN_API bool grn_table_have_duplicated_keys (grn_ctx *ctx, grn_obj *table)
 
GRN_API bool grn_table_have_tokenizer (grn_ctx *ctx, grn_obj *table)
 
GRN_API bool grn_table_have_extractor (grn_ctx *ctx, grn_obj *table)
 Return whether the given table have one or more extractors or not.
 
GRN_API grn_objgrn_table_extract (grn_ctx *ctx, grn_obj *table, grn_obj *value)
 Extract data from the given value by extractors associated with the given table.
 
GRN_API grn_table_selectorgrn_table_selector_open (grn_ctx *ctx, grn_obj *table, grn_obj *expr, grn_operator op)
 
GRN_API grn_rc grn_table_selector_close (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_id grn_table_selector_get_min_id (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_min_id (grn_ctx *ctx, grn_table_selector *table_selector, grn_id min_id)
 
GRN_API bool grn_table_selector_get_use_sequential_scan (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_use_sequential_scan (grn_ctx *ctx, grn_table_selector *table_selector, bool use)
 
GRN_API float grn_table_selector_get_weight_factor (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_weight_factor (grn_ctx *ctx, grn_table_selector *table_selector, float factor)
 
GRN_API double grn_table_selector_get_enough_filtered_ratio (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_enough_filtered_ratio (grn_ctx *ctx, grn_table_selector *table_selector, double ratio)
 
GRN_API int64_t grn_table_selector_get_max_n_enough_filtered_records (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_max_n_enough_filtered_records (grn_ctx *ctx, grn_table_selector *table_selector, int64_t n)
 
GRN_API bool grn_table_selector_get_ensure_using_select_result (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_ensure_using_select_result (grn_ctx *ctx, grn_table_selector *table_selector, bool use)
 
GRN_API uint32_t grn_table_selector_get_fuzzy_max_distance (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_fuzzy_max_distance (grn_ctx *ctx, grn_table_selector *table_selector, uint32_t distance)
 
GRN_API uint32_t grn_table_selector_get_fuzzy_max_expansions (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_fuzzy_max_expansions (grn_ctx *ctx, grn_table_selector *table_selector, uint32_t expansions)
 
GRN_API uint32_t grn_table_selector_get_fuzzy_prefix_length (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_fuzzy_prefix_length (grn_ctx *ctx, grn_table_selector *table_selector, uint32_t length)
 
GRN_API float grn_table_selector_get_fuzzy_max_distance_ratio (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_fuzzy_max_distance_ratio (grn_ctx *ctx, grn_table_selector *table_selector, float ratio)
 
GRN_API bool grn_table_selector_get_fuzzy_with_transposition (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_fuzzy_with_transposition (grn_ctx *ctx, grn_table_selector *table_selector, bool with)
 
GRN_API bool grn_table_selector_get_fuzzy_tokenize (grn_ctx *ctx, grn_table_selector *table_selector)
 
GRN_API grn_rc grn_table_selector_set_fuzzy_tokenize (grn_ctx *ctx, grn_table_selector *table_selector, bool tokenize)
 
GRN_API grn_objgrn_table_selector_select (grn_ctx *ctx, grn_table_selector *table_selector, grn_obj *result_set)
 

Macro Definition Documentation

◆ GRN_CURSOR_ASCENDING

#define GRN_CURSOR_ASCENDING   (0x00 << 0)

◆ GRN_CURSOR_BY_ID

#define GRN_CURSOR_BY_ID   (0x01 << 3)

◆ GRN_CURSOR_BY_KEY

#define GRN_CURSOR_BY_KEY   (0x00 << 3)

◆ GRN_CURSOR_DESCENDING

#define GRN_CURSOR_DESCENDING   (0x01 << 0)

◆ GRN_CURSOR_GE

#define GRN_CURSOR_GE   (0x00 << 1)

◆ GRN_CURSOR_GT

#define GRN_CURSOR_GT   (0x01 << 1)

◆ GRN_CURSOR_LE

#define GRN_CURSOR_LE   (0x00 << 2)

◆ GRN_CURSOR_LT

#define GRN_CURSOR_LT   (0x01 << 2)

◆ GRN_CURSOR_PREFIX

#define GRN_CURSOR_PREFIX   (0x01 << 4)

◆ GRN_CURSOR_RK

#define GRN_CURSOR_RK   (0x01 << 6)

◆ GRN_CURSOR_SIZE_BY_BIT

#define GRN_CURSOR_SIZE_BY_BIT   (0x01 << 5)

◆ GRN_TABLE_EACH

#define GRN_TABLE_EACH (   ctx,
  table,
  head,
  tail,
  id,
  key,
  key_size,
  value,
  block 
)

◆ GRN_TABLE_EACH_BEGIN

#define GRN_TABLE_EACH_BEGIN (   ctx,
  table,
  cursor,
  id 
)
Value:
do { \
if ((table) && grn_table_size(ctx, (table)) > 0) { \
grn_table_cursor *cursor; \
cursor = grn_table_cursor_open((ctx), \
(table), \
NULL, \
0, \
NULL, \
0, \
0, \
-1, \
if (cursor) { \
grn_id id; \
while ((id = grn_table_cursor_next((ctx), cursor))) {
uint32_t grn_id
Definition groonga.h:44
Definition groonga.h:919
GRN_API grn_id grn_table_cursor_next(grn_ctx *ctx, grn_table_cursor *tc)
Move the cursur forward to the next and return its record ID. Return GRN_ID_NIL when the end is reach...
GRN_API grn_table_cursor * grn_table_cursor_open(grn_ctx *ctx, grn_obj *table, const void *min, unsigned int min_size, const void *max, unsigned int max_size, int offset, int limit, int flags)
Creates and returns a cursor to retrieve the records registered in the table in order.
#define GRN_CURSOR_ASCENDING
Definition table.h:273
GRN_API unsigned int grn_table_size(grn_ctx *ctx, grn_obj *table)
Return the number of records registered in the table.

◆ GRN_TABLE_EACH_BEGIN_FLAGS

#define GRN_TABLE_EACH_BEGIN_FLAGS (   ctx,
  table,
  cursor,
  id,
  flags 
)
Value:
do { \
if ((table) && grn_table_size(ctx, (table)) > 0) { \
grn_table_cursor *cursor; \
cursor = grn_table_cursor_open((ctx), \
(table), \
NULL, \
0, \
NULL, \
0, \
0, \
-1, \
(flags)); \
if (cursor) { \
grn_id id; \
while ((id = grn_table_cursor_next((ctx), cursor))) {

◆ GRN_TABLE_EACH_BEGIN_MIN

#define GRN_TABLE_EACH_BEGIN_MIN (   ctx,
  table,
  cursor,
  id,
  min,
  min_size,
  flags 
)
Value:
do { \
if ((table) && grn_table_size(ctx, (table)) > 0) { \
grn_table_cursor *cursor; \
cursor = grn_table_cursor_open((ctx), \
(table), \
(min), \
(min_size), \
NULL, \
0, \
0, \
-1, \
(flags)); \
if (cursor) { \
grn_id id; \
while ((id = grn_table_cursor_next((ctx), cursor))) {

◆ GRN_TABLE_EACH_END

#define GRN_TABLE_EACH_END (   ctx,
  cursor 
)
Value:
} \
grn_table_cursor_close((ctx), cursor); \
} \
} \
} \
while (0)

◆ GRN_TABLE_GROUP_CALC_AGGREGATOR

#define GRN_TABLE_GROUP_CALC_AGGREGATOR   (0x01 << 8)

◆ GRN_TABLE_GROUP_CALC_AVG

#define GRN_TABLE_GROUP_CALC_AVG   GRN_TABLE_GROUP_CALC_MEAN

◆ GRN_TABLE_GROUP_CALC_COUNT

#define GRN_TABLE_GROUP_CALC_COUNT   (0x01 << 3)

◆ GRN_TABLE_GROUP_CALC_MAX

#define GRN_TABLE_GROUP_CALC_MAX   (0x01 << 4)

◆ GRN_TABLE_GROUP_CALC_MEAN

#define GRN_TABLE_GROUP_CALC_MEAN   (0x01 << 7)

◆ GRN_TABLE_GROUP_CALC_MIN

#define GRN_TABLE_GROUP_CALC_MIN   (0x01 << 5)

◆ GRN_TABLE_GROUP_CALC_SUM

#define GRN_TABLE_GROUP_CALC_SUM   (0x01 << 6)

◆ GRN_TABLE_GROUP_KEY_VECTOR_EXPANSION_POWER_SET

#define GRN_TABLE_GROUP_KEY_VECTOR_EXPANSION_POWER_SET   (0x01 << 10)

◆ GRN_TABLE_GROUP_LIMIT

#define GRN_TABLE_GROUP_LIMIT   (0x01 << 9)

◆ GRN_TABLE_MAX_KEY_SIZE

#define GRN_TABLE_MAX_KEY_SIZE   (0x1000)

◆ GRN_TABLE_OPEN_OR_CREATE

#define GRN_TABLE_OPEN_OR_CREATE (   ctx,
  name,
  name_size,
  path,
  flags,
  key_type,
  value_type,
  table 
)
Value:
(((table) = grn_ctx_get((ctx), (name), (name_size))) || \
((table) = grn_table_create((ctx), \
(name), \
(name_size), \
(path), \
(flags), \
(key_type), \
(value_type))))
GRN_API grn_obj * grn_ctx_get(grn_ctx *ctx, const char *name, int name_size)
Retrieve the object corresponding to the specified name from the database that the context is using.
GRN_API grn_obj * grn_table_create(grn_ctx *ctx, const char *name, unsigned int name_size, const char *path, grn_table_flags flags, grn_obj *key_type, grn_obj *value_type)
Define a new table in the DB used by ctx.

◆ GRN_TABLE_SORT_ASC

#define GRN_TABLE_SORT_ASC   (0x00 << 0)

Sort in ascending order.

◆ GRN_TABLE_SORT_DESC

#define GRN_TABLE_SORT_DESC   (0x01 << 0)

Sort in descending order.

Typedef Documentation

◆ grn_table_cursor_foreach_func

typedef grn_rc(* grn_table_cursor_foreach_func) (grn_ctx *ctx, grn_table_cursor *cursor, grn_id id, void *user_data)

◆ grn_table_group_aggregator

typedef struct _grn_table_group_aggregator grn_table_group_aggregator

◆ grn_table_group_flags

typedef uint32_t grn_table_group_flags

◆ grn_table_group_result

◆ grn_table_selector

typedef struct _grn_table_selector grn_table_selector

◆ grn_table_sort_flags

typedef unsigned char grn_table_sort_flags

◆ grn_table_sort_key

Function Documentation

◆ grn_index_cursor_get_index_column()

GRN_API grn_obj * grn_index_cursor_get_index_column ( grn_ctx ctx,
grn_obj index_cursor 
)

◆ grn_index_cursor_get_section_id()

GRN_API uint32_t grn_index_cursor_get_section_id ( grn_ctx ctx,
grn_obj index_cursor 
)

◆ grn_index_cursor_get_start_position()

GRN_API uint32_t grn_index_cursor_get_start_position ( grn_ctx ctx,
grn_obj index_cursor 
)

◆ grn_index_cursor_next()

GRN_API grn_posting * grn_index_cursor_next ( grn_ctx ctx,
grn_obj index_cursor,
grn_id term_id 
)

Retrieve the current posting information and move the cursor to the the next.

Parameters
ctxThe context object.
index_cursorTarget cursor.
term_idThe buffer to store the ID of the current target record of cursor. If NULL is specified, it will not be stored.
Returns
grn_posting if the next posting is found, NULL otherwise. You don't need to free the returned grn_posting.

◆ grn_index_cursor_open()

GRN_API grn_obj * grn_index_cursor_open ( grn_ctx ctx,
grn_table_cursor tc,
grn_obj index,
grn_id  rid_min,
grn_id  rid_max,
int  flags 
)

Create a cursor that returns postings in GRN_OBJ_COLUMN_INDEX.

If you specify a valid grn_table_cursor as tc, the created cursor returns all postings for records that are retrieved by tc.

If you specify NULL as tc, the create cursor returns all postings only for the specified term ID. You must set the term ID by grn_index_cursor_set_term_id.

You can specify rid_min and rid_max to limit the postings to be retrieved.

Parameters
ctxThe context object
tcThe table cursor.
indexThe index column (Object in GRN_OBJ_COLUMN_INDEX).
rid_minMinimum record ID of posting.
rid_maxMaximum record ID of posting.
flags0 or GRN_OBJ_WITH_POSITION.
Returns
The index cursor on success, NULL on error. You must free the return index cursor with grn_obj_close.

◆ grn_index_cursor_reset_start_position()

GRN_API grn_rc grn_index_cursor_reset_start_position ( grn_ctx ctx,
grn_obj index_cursor 
)

◆ grn_index_cursor_set_scale()

GRN_API grn_rc grn_index_cursor_set_scale ( grn_ctx ctx,
grn_obj index_cursor,
float  scale 
)

◆ grn_index_cursor_set_scales()

GRN_API grn_rc grn_index_cursor_set_scales ( grn_ctx ctx,
grn_obj index_cursor,
float *  scales,
size_t  n_scales 
)

◆ grn_index_cursor_set_section_id()

GRN_API grn_rc grn_index_cursor_set_section_id ( grn_ctx ctx,
grn_obj index_cursor,
uint32_t  section_id 
)

◆ grn_index_cursor_set_start_position()

GRN_API grn_rc grn_index_cursor_set_start_position ( grn_ctx ctx,
grn_obj index_cursor,
uint32_t  position 
)

◆ grn_index_cursor_set_term_id()

GRN_API grn_rc grn_index_cursor_set_term_id ( grn_ctx ctx,
grn_obj index_cursor,
grn_id  term_id 
)

◆ grn_table_add()

GRN_API grn_id grn_table_add ( grn_ctx ctx,
grn_obj table,
const void *  key,
unsigned int  key_size,
int *  added 
)

Add a new record with key to the table and return its ID. If key already exists in the table, returns the ID of the record. For tables with GRN_OBJ_TABLE_NO_KEY, key and key_size are ignored.

Parameters
ctxThe context object
tableTarget table
keySearch key
key_sizeLength of key
addedIf a non NULL value is specified, 1 is set when a new record is added, and 0 is set when it is an existing record
Returns
Record ID on success, GRN_ID_NIL on error
Todo:
int *added -> bool *added

◆ grn_table_apply_expr()

GRN_API grn_rc grn_table_apply_expr ( grn_ctx ctx,
grn_obj table,
grn_obj output_column,
grn_obj expr 
)

◆ grn_table_at()

GRN_API grn_id grn_table_at ( grn_ctx ctx,
grn_obj table,
grn_id  id 
)

Search the table for a record of ID and return the specified ID if it exists, or GRN_ID_NIL if it does not.

Attention
It is costly to perform. Do not call them frequently
Parameters
ctxThe context object
tableThe table or database
idThe ID to be found
Returns
Specified ID on success, GRN_ID_NIL on not found or error

◆ grn_table_columns()

GRN_API int grn_table_columns ( grn_ctx ctx,
grn_obj table,
const char *  name,
unsigned int  name_size,
grn_obj res 
)

Store the column IDs of the table starting with name in res.

Parameters
ctxThe context object.
tableThe table.
nameThe column name prefix.
name_sizeSize of name in bytes. If 0, you get all column IDs.
resThe GRN_TABLE_HASH_KEY table to store results.
Returns
The number of IDs.

◆ grn_table_copy()

GRN_API grn_rc grn_table_copy ( grn_ctx ctx,
grn_obj from,
grn_obj to 
)

◆ grn_table_create()

GRN_API grn_obj * grn_table_create ( grn_ctx ctx,
const char *  name,
unsigned int  name_size,
const char *  path,
grn_table_flags  flags,
grn_obj key_type,
grn_obj value_type 
)

Define a new table in the DB used by ctx.

Parameters
ctxThe context object
nameName of the table to create. If NULL, it is an unnamed table. When creating a named table for a persistent db, GRN_OBJ_PERSISTENT must be specified in flags
name_sizeLength of name
pathFile path of the table to create. Enabled only if GRN_OBJ_PERSISTENT is specified in flags. If NULL, the file path is automatically assigned.
flags
  • GRN_OBJ_TABLE_NO_KEY: Array table
  • GRN_OBJ_TABLE_HASH_KEY: Hash table
  • GRN_OBJ_TABLE_PAT_KEY: Patricia trie
  • GRN_OBJ_KEY_WITH_SIS: All suffixes in the key string are automatically registered
  • GRN_OBJ_PERSISTENT: Persistent table
  • GRN_OBJ_KEY_NORMALIZE: Normalized string is the key
key_typeBuilt-in type or table. If table B is created with table A as key_type, B will always be a subset of A. Disabled if GRN_OBJ_TABLE_NO_KEY is specified.
value_typeType of the value for key. A table can have only one value for key, in addition to column
Returns
A newly created table on success, NULL on error

◆ grn_table_create_for_group()

GRN_API grn_obj * grn_table_create_for_group ( grn_ctx ctx,
const char *  name,
unsigned int  name_size,
const char *  path,
grn_obj group_key,
grn_obj value_type,
uint32_t  max_n_subrecs 
)

◆ grn_table_create_similar()

GRN_API grn_obj * grn_table_create_similar ( grn_ctx ctx,
const char *  name,
uint32_t  name_size,
const char *  path,
grn_obj base_table 
)

◆ grn_table_cursor_close()

GRN_API grn_rc grn_table_cursor_close ( grn_ctx ctx,
grn_table_cursor tc 
)

Free the cursor created by grn_table_cursor_open()

Parameters
ctxThe context object
tcTarget cursor
Returns
GRN_SUCCESS on success, GRN_INVALID_ARGUMENT if tc is invalid

◆ grn_table_cursor_delete()

GRN_API grn_rc grn_table_cursor_delete ( grn_ctx ctx,
grn_table_cursor tc 
)

Delete the current record for cursor.

Parameters
ctxThe context object
tcTarget cursor
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_INVALID_ARGUMENT is returned if the current record for cursor does not exist.

◆ grn_table_cursor_foreach()

GRN_API grn_rc grn_table_cursor_foreach ( grn_ctx ctx,
grn_table_cursor cursor,
grn_table_cursor_foreach_func  func,
void *  user_data 
)

◆ grn_table_cursor_get_key()

GRN_API int grn_table_cursor_get_key ( grn_ctx ctx,
grn_table_cursor tc,
void **  key 
)

Sets the key of the current record in cursor to key parameter and returns its length.

Parameters
ctxThe context object
tcTarget cursor
keyA pointer to the key of the current record is set
Returns
Length of key

◆ grn_table_cursor_get_key_value()

GRN_API uint32_t grn_table_cursor_get_key_value ( grn_ctx ctx,
grn_table_cursor tc,
void **  key,
uint32_t *  key_size,
void **  value 
)

◆ grn_table_cursor_get_max_n_records()

GRN_API size_t grn_table_cursor_get_max_n_records ( grn_ctx ctx,
grn_table_cursor cursor 
)

◆ grn_table_cursor_get_value()

GRN_API int grn_table_cursor_get_value ( grn_ctx ctx,
grn_table_cursor tc,
void **  value 
)

Sets the value of the current record in cursor to value parameter and returns its length.

Parameters
ctxThe context object
tcTarget cursor
valueA pointer to the value of the current record is set
Returns
Length of value

◆ grn_table_cursor_next()

GRN_API grn_id grn_table_cursor_next ( grn_ctx ctx,
grn_table_cursor tc 
)

Move the cursur forward to the next and return its record ID. Return GRN_ID_NIL when the end is reached.

Parameters
ctxThe context object
tcTarget cursor
Returns
Record ID on there is a next, GRN_ID_NIL on no next or on error

◆ grn_table_cursor_open()

GRN_API grn_table_cursor * grn_table_cursor_open ( grn_ctx ctx,
grn_obj table,
const void *  min,
unsigned int  min_size,
const void *  max,
unsigned int  max_size,
int  offset,
int  limit,
int  flags 
)

Creates and returns a cursor to retrieve the records registered in the table in order.

Parameters
ctxThe context object
tableTarget table
minMinimum limit of key (NULL means no minimum limit). See below for GRN_CURSOR_PREFIX
min_sizeSize of min. See below for GRN_CURSOR_PREFIX
maxMaximum limit of key (NULL means no maximum limit). See below for GRN_CURSOR_PREFIX
max_sizeSize of max. GRN_CURSOR_PREFIX may be ignored
offsetExtracts records from the range of records that meet the condition, starting with the offset-th (offset is zero-based). When GRN_CURSOR_PREFIX is specified, negative numbers cannot be specified
limitOnly limit records in the range that meet the condition are extracted. -1 means all. When GRN_CURSOR_PREFIX is specified, negative numbers cannot be specified
flags
  • GRN_CURSOR_ASCENDING: Retrieve records in ascending order
    • If GRN_CURSOR_PREFIX is specified and a record with a near key is retrieved, or a common prefix search is used, it will be ignored
  • GRN_CURSOR_DESCENDING: Retrieve records in descending order
    • If GRN_CURSOR_PREFIX is specified and a record with a near key is retrieved, or a common prefix search is used, it will be ignored
  • GRN_CURSOR_GT: a key that matches min is not included in the cursor range
    • If min is NULL, or if GRN_CURSOR_PREFIX is specified and a record with a near key is retrieved, or a common prefix search is used, it will be ignored
  • GRN_CURSOR_LT: a key that matches max is not included in the cursor range
    • If max is NULL, or if GRN_CURSOR_PREFIX is specified, it will be ignored
  • GRN_CURSOR_BY_ID: Retrieves records in ID order
    • If GRN_CURSOR_PREFIX is specified, it will be ignored
  • GRN_CURSOR_BY_KEY: Retrieves records in key order
    • It can be used with table that specify GRN_OBJ_TABLE_PAT_KEY
    • For table with GRN_OBJ_TABLE_HASH_KEY or GRN_OBJ_TABLE_NO_KEY, it will be ignored
  • GRN_CURSOR_PREFIX: A cursor is created to retrieve the following records for the table with GRN_OBJ_TABLE_PAT_KEY
    • If max is NULL, retrieve the record for which key is a prefix match to min. max_size is ignored
    • If max and max_size are specified and the table key is of type ShortText, then a max and common prefix search is executed and records with a common prefix greater than or equal to min_size bytes are retrieved. min is ignored
    • If max and max_size are specified and the key of the table is a fixed-length type, records are retrieved sequentially from nodes that are near each other on the max and PAT tree.
      • But, records are not retrieved for nodes in the PAT tree of key for bits less than min_size bytes and corresponding to nodes on a different branch than max. Being near a position on the PAT tree is not the same as being near a key value. In this case, max must be as wide as or greater than the key size of the target table. min is ignored
  • GRN_CURSOR_BY_ID, GRN_CURSOR_BY_KEY and GRN_CURSOR_PREFIX cannot be specified at the same time.
  • In a table created with GRN_OBJ_TABLE_PAT_KEY, if GRN_CURSOR_PREFIX and GRN_CURSOR_RK are specified, retrieves records where key is a prefix matching a string of lower case alphabetic characters converted to half-width kana characters according to JIS X 4063:2000 (this standard is abolished).
    • Supports only GRN_ENC_UTF8
    • GRN_CURSOR_ASCENDING and GRN_CURSOR_DESCENDING are invalid. Records cannot be retrieved in ascending or descending order of key value
Returns
A newly opened table cursor on success, NULL on error

◆ grn_table_cursor_set_value()

GRN_API grn_rc grn_table_cursor_set_value ( grn_ctx ctx,
grn_table_cursor tc,
const void *  value,
int  flags 
)

Set value to the current record according to flags

Parameters
ctxThe context object
tcTable cursor
valueValue to set
flagsAvailable values:
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_INVALID_ARGUMENT is returned if the current record for cursor does not exist.

◆ grn_table_cursor_table()

GRN_API grn_obj * grn_table_cursor_table ( grn_ctx ctx,
grn_table_cursor tc 
)

Return the table of cursor.

Parameters
ctxThe context object
tcTarget cursor
Returns
The table of cursor on success, NULL on error

◆ grn_table_delete()

GRN_API grn_rc grn_table_delete ( grn_ctx ctx,
grn_obj table,
const void *  key,
unsigned int  key_size 
)

Delete the record matching the key in the table.

Parameters
ctxThe context object
tableThe table
keyKey of record to be deleted
key_sizeSize of key in bytes
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_INVALID_ARGUMENT is returned if the record does not exist.

◆ grn_table_delete_by_id()

GRN_API grn_rc grn_table_delete_by_id ( grn_ctx ctx,
grn_obj table,
grn_id  id 
)

Delete the record matching the ID in the table.

Parameters
ctxThe context object
tableThe table
idID of record to be deleted
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_INVALID_ARGUMENT is returned if the record does not exist.

◆ grn_table_difference()

GRN_API grn_rc grn_table_difference ( grn_ctx ctx,
grn_obj table1,
grn_obj table2,
grn_obj res1,
grn_obj res2 
)

Delete duplicated records in table1 and table2.

Parameters
ctxThe context object.
table1The table.
table2The table.
res1Specify table1.
res2Specify table2.
Returns
GRN_SUCCESS on success, GRN_INVALID_ARGUMENT on table1 != res1 || table2 != res2.

◆ grn_table_extract()

GRN_API grn_obj * grn_table_extract ( grn_ctx ctx,
grn_obj table,
grn_obj value 
)

Extract data from the given value by extractors associated with the given table.

If the given table doesn't have any extractors, this returns the given value as-is.

If all extractors don't extract anything, this returns the given value as-is.

Parameters
ctxThe context object.
tableThe table that has extractors.
valueThe value to extract.
Returns
An extracted data or value as-is on success, NULL on error.

If the return value isn't same as value, you must free it by grn_obj_close when it's no longer needed.

Check ctx->rc for the specific error code (e.g., GRN_NO_MEMORY_AVAILABLE, GRN_INVALID_ARGUMENT). Additional details might be available in ctx->errbuf.

Since
16.0.6

◆ grn_table_find_reference_object()

GRN_API grn_id grn_table_find_reference_object ( grn_ctx ctx,
grn_obj table 
)

◆ grn_table_get()

GRN_API grn_id grn_table_get ( grn_ctx ctx,
grn_obj table,
const void *  key,
unsigned int  key_size 
)

It finds a record that has key parameter and returns ID of the found record. If table parameter is a database, it finds an object (table, column and so on) that has key parameter and returns ID of the found object.

Parameters
ctxThe context object
tableThe table or database
keyThe record or object key to be found
key_sizeLength of key
Returns
ID of the found object on success, GRN_ID_NIL on not found or error

◆ grn_table_get_duplicated_keys()

GRN_API grn_rc grn_table_get_duplicated_keys ( grn_ctx ctx,
grn_obj table,
grn_obj **  duplicated_keys 
)

◆ grn_table_get_key()

GRN_API int grn_table_get_key ( grn_ctx ctx,
grn_obj table,
grn_id  id,
void *  keybuf,
int  buf_size 
)

Get the key assigned to the ID. If the size of the key found is larger than buf_size, it is not stored in keybuf.

Parameters
ctxThe context object.
tableThe table.
idThe ID to be found.
keybufBuffer to store the record key.
buf_sizeSize of keybuf in bytes.
Returns
Key size of the record on success, 0 on not existed.

◆ grn_table_get_subrecs()

GRN_API unsigned int grn_table_get_subrecs ( grn_ctx ctx,
grn_obj table,
grn_id  id,
grn_id subrecbuf,
int *  scorebuf,
int  buf_size 
)

◆ grn_table_group()

GRN_API grn_rc grn_table_group ( grn_ctx ctx,
grn_obj table,
grn_table_sort_key keys,
int  n_keys,
grn_table_group_result results,
int  n_results 
)

Group the records in the table.

Parameters
ctxThe context object.
tableThe table.
keysArray of keys for grouping.
n_keysNumber of elements in keys array.
resultsArray to store the results of grouping.
n_resultsNumber of elements in results array.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_INVALID_ARGUMENT is returned if table is NULL.

◆ grn_table_group_aggregator_close()

GRN_API grn_rc grn_table_group_aggregator_close ( grn_ctx ctx,
grn_table_group_aggregator aggregator 
)

◆ grn_table_group_aggregator_get_expression()

GRN_API const char * grn_table_group_aggregator_get_expression ( grn_ctx ctx,
grn_table_group_aggregator aggregator,
uint32_t *  expression_len 
)

◆ grn_table_group_aggregator_get_output_column_flags()

GRN_API grn_column_flags grn_table_group_aggregator_get_output_column_flags ( grn_ctx ctx,
grn_table_group_aggregator aggregator 
)

◆ grn_table_group_aggregator_get_output_column_name()

GRN_API const char * grn_table_group_aggregator_get_output_column_name ( grn_ctx ctx,
grn_table_group_aggregator aggregator,
uint32_t *  len 
)

◆ grn_table_group_aggregator_get_output_column_type()

GRN_API grn_obj * grn_table_group_aggregator_get_output_column_type ( grn_ctx ctx,
grn_table_group_aggregator aggregator 
)

◆ grn_table_group_aggregator_open()

GRN_API grn_table_group_aggregator * grn_table_group_aggregator_open ( grn_ctx ctx)

◆ grn_table_group_aggregator_set_expression()

GRN_API grn_rc grn_table_group_aggregator_set_expression ( grn_ctx ctx,
grn_table_group_aggregator aggregator,
const char *  expression,
int32_t  expression_len 
)

◆ grn_table_group_aggregator_set_output_column_flags()

GRN_API grn_rc grn_table_group_aggregator_set_output_column_flags ( grn_ctx ctx,
grn_table_group_aggregator aggregator,
grn_column_flags  flags 
)

◆ grn_table_group_aggregator_set_output_column_name()

GRN_API grn_rc grn_table_group_aggregator_set_output_column_name ( grn_ctx ctx,
grn_table_group_aggregator aggregator,
const char *  name,
int32_t  name_len 
)

◆ grn_table_group_aggregator_set_output_column_type()

GRN_API grn_rc grn_table_group_aggregator_set_output_column_type ( grn_ctx ctx,
grn_table_group_aggregator aggregator,
grn_obj type 
)

◆ grn_table_group_keys_parse()

GRN_API grn_table_sort_key * grn_table_group_keys_parse ( grn_ctx ctx,
grn_obj table,
const char *  raw_sort_keys,
int32_t  raw_sort_keys_size,
uint32_t *  n_keys 
)

◆ grn_table_have_duplicated_keys()

GRN_API bool grn_table_have_duplicated_keys ( grn_ctx ctx,
grn_obj table 
)

◆ grn_table_have_extractor()

GRN_API bool grn_table_have_extractor ( grn_ctx ctx,
grn_obj table 
)

Return whether the given table have one or more extractors or not.

Parameters
ctxThe context object.
tableThe table to check.
Returns
true if table has one or more extractors, false otherwise.
Since
16.0.6

◆ grn_table_have_tokenizer()

GRN_API bool grn_table_have_tokenizer ( grn_ctx ctx,
grn_obj table 
)

◆ grn_table_is_grouped()

GRN_API bool grn_table_is_grouped ( grn_ctx ctx,
grn_obj table 
)

◆ grn_table_lcp_search()

GRN_API grn_id grn_table_lcp_search ( grn_ctx ctx,
grn_obj table,
const void *  key,
unsigned int  key_size 
)

Execute longest common prefix (LCP) search and return ID found.

Execute longest common prefix search if the table is GRN_TABLE_PAT_KEY or GRN_TABLE_DAT_KEY. If the table is GRN_TABLE_HASH_KEY, search by exact match.

Parameters
ctxThe context object.
tableThe table.
keySearch key.
key_sizeLength of key.
Returns
ID on success, GRN_ID_NIL on not found or error.

◆ grn_table_max_n_subrecs()

GRN_API unsigned int grn_table_max_n_subrecs ( grn_ctx ctx,
grn_obj table 
)

◆ grn_table_rename()

GRN_API grn_rc grn_table_rename ( grn_ctx ctx,
grn_obj table,
const char *  name,
unsigned int  name_size 
)

Rename table to name. All columns of the table are renamed at the same time. The table must be a persistent object.

Parameters
ctxThe context object
tableTarget table
nameNew name
name_sizeSize of name in bytes
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error

◆ grn_table_select()

GRN_API grn_obj * grn_table_select ( grn_ctx ctx,
grn_obj table,
grn_obj expr,
grn_obj result_set,
grn_operator  op 
)

◆ grn_table_selector_close()

GRN_API grn_rc grn_table_selector_close ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_enough_filtered_ratio()

GRN_API double grn_table_selector_get_enough_filtered_ratio ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_ensure_using_select_result()

GRN_API bool grn_table_selector_get_ensure_using_select_result ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_fuzzy_max_distance()

GRN_API uint32_t grn_table_selector_get_fuzzy_max_distance ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_fuzzy_max_distance_ratio()

GRN_API float grn_table_selector_get_fuzzy_max_distance_ratio ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_fuzzy_max_expansions()

GRN_API uint32_t grn_table_selector_get_fuzzy_max_expansions ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_fuzzy_prefix_length()

GRN_API uint32_t grn_table_selector_get_fuzzy_prefix_length ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_fuzzy_tokenize()

GRN_API bool grn_table_selector_get_fuzzy_tokenize ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_fuzzy_with_transposition()

GRN_API bool grn_table_selector_get_fuzzy_with_transposition ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_max_n_enough_filtered_records()

GRN_API int64_t grn_table_selector_get_max_n_enough_filtered_records ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_min_id()

GRN_API grn_id grn_table_selector_get_min_id ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_use_sequential_scan()

GRN_API bool grn_table_selector_get_use_sequential_scan ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_get_weight_factor()

GRN_API float grn_table_selector_get_weight_factor ( grn_ctx ctx,
grn_table_selector table_selector 
)

◆ grn_table_selector_open()

GRN_API grn_table_selector * grn_table_selector_open ( grn_ctx ctx,
grn_obj table,
grn_obj expr,
grn_operator  op 
)

◆ grn_table_selector_select()

GRN_API grn_obj * grn_table_selector_select ( grn_ctx ctx,
grn_table_selector table_selector,
grn_obj result_set 
)

◆ grn_table_selector_set_enough_filtered_ratio()

GRN_API grn_rc grn_table_selector_set_enough_filtered_ratio ( grn_ctx ctx,
grn_table_selector table_selector,
double  ratio 
)

◆ grn_table_selector_set_ensure_using_select_result()

GRN_API grn_rc grn_table_selector_set_ensure_using_select_result ( grn_ctx ctx,
grn_table_selector table_selector,
bool  use 
)

◆ grn_table_selector_set_fuzzy_max_distance()

GRN_API grn_rc grn_table_selector_set_fuzzy_max_distance ( grn_ctx ctx,
grn_table_selector table_selector,
uint32_t  distance 
)

◆ grn_table_selector_set_fuzzy_max_distance_ratio()

GRN_API grn_rc grn_table_selector_set_fuzzy_max_distance_ratio ( grn_ctx ctx,
grn_table_selector table_selector,
float  ratio 
)

◆ grn_table_selector_set_fuzzy_max_expansions()

GRN_API grn_rc grn_table_selector_set_fuzzy_max_expansions ( grn_ctx ctx,
grn_table_selector table_selector,
uint32_t  expansions 
)

◆ grn_table_selector_set_fuzzy_prefix_length()

GRN_API grn_rc grn_table_selector_set_fuzzy_prefix_length ( grn_ctx ctx,
grn_table_selector table_selector,
uint32_t  length 
)

◆ grn_table_selector_set_fuzzy_tokenize()

GRN_API grn_rc grn_table_selector_set_fuzzy_tokenize ( grn_ctx ctx,
grn_table_selector table_selector,
bool  tokenize 
)

◆ grn_table_selector_set_fuzzy_with_transposition()

GRN_API grn_rc grn_table_selector_set_fuzzy_with_transposition ( grn_ctx ctx,
grn_table_selector table_selector,
bool  with 
)

◆ grn_table_selector_set_max_n_enough_filtered_records()

GRN_API grn_rc grn_table_selector_set_max_n_enough_filtered_records ( grn_ctx ctx,
grn_table_selector table_selector,
int64_t  n 
)

◆ grn_table_selector_set_min_id()

GRN_API grn_rc grn_table_selector_set_min_id ( grn_ctx ctx,
grn_table_selector table_selector,
grn_id  min_id 
)

◆ grn_table_selector_set_use_sequential_scan()

GRN_API grn_rc grn_table_selector_set_use_sequential_scan ( grn_ctx ctx,
grn_table_selector table_selector,
bool  use 
)

◆ grn_table_selector_set_weight_factor()

GRN_API grn_rc grn_table_selector_set_weight_factor ( grn_ctx ctx,
grn_table_selector table_selector,
float  factor 
)

◆ grn_table_setoperation()

GRN_API grn_rc grn_table_setoperation ( grn_ctx ctx,
grn_obj table1,
grn_obj table2,
grn_obj res,
grn_operator  op 
)

Execute the set operation of table1 and table2 according to the specification of op and store the result into res.

Attention
The table specified in res will be destructed.
Parameters
ctxThe context object.
table1The table.
table2The table.
resSpecify table1 or table2.
opType of operation.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_INVALID_ARGUMENT is returned if table1 is NULL.

◆ grn_table_size()

GRN_API unsigned int grn_table_size ( grn_ctx ctx,
grn_obj table 
)

Return the number of records registered in the table.

Parameters
ctxThe context object
tableThe table or database
Returns
The number of records

◆ grn_table_sort()

GRN_API int grn_table_sort ( grn_ctx ctx,
grn_obj table,
int  offset,
int  limit,
grn_obj result,
grn_table_sort_key keys,
int  n_keys 
)

Sort the records in table and store the results in result

Parameters
ctxThe context object
tableTarget table
offsetStarting offset of the sorted record. The records are stored in order from the offset (zero-based).
limitMaximum number of records to be stored in result
resultTable to store results
keysArray of sort keys
  • keys.key: You can specify either column of table, accessor of table, or proc
  • keys.flags: You can specify the next
  • keys.offset: Member for internal use
n_keysNumber of elements in keys array
Returns
Number of sorted records

◆ grn_table_sort_key_close()

GRN_API grn_rc grn_table_sort_key_close ( grn_ctx ctx,
grn_table_sort_key keys,
uint32_t  nkeys 
)

◆ grn_table_sort_key_from_str()

GRN_API grn_table_sort_key * grn_table_sort_key_from_str ( grn_ctx ctx,
const char *  str,
unsigned int  str_size,
grn_obj table,
uint32_t *  nkeys 
)

◆ grn_table_sort_keys_parse()

GRN_API grn_table_sort_key * grn_table_sort_keys_parse ( grn_ctx ctx,
grn_obj table,
const char *  raw_sort_keys,
int32_t  raw_sort_keys_size,
uint32_t *  n_keys 
)

◆ grn_table_tokenize()

GRN_API grn_obj * grn_table_tokenize ( grn_ctx ctx,
grn_obj table,
const char *  str,
unsigned int  str_len,
grn_obj buf,
bool  addp 
)

◆ grn_table_truncate()

GRN_API grn_rc grn_table_truncate ( grn_ctx ctx,
grn_obj table 
)

Delete all records in table.

Attention
Do not use in multi-threading. Because it might access data that has already been deleted and crash when it does.
You need to reopen the target table and its columns in another process when you use this in multi-processing. This removes related files and creates new files. If you keep using the target table and its columns in another process, the target table and its columns in another process will touch removed data. It will cause a crash or something wrong.
Parameters
ctxThe context object
tableThe table
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error.

◆ grn_table_update()

GRN_API grn_rc grn_table_update ( grn_ctx ctx,
grn_obj table,
const void *  src_key,
unsigned int  src_key_size,
const void *  dest_key,
unsigned int  dest_key_size 
)

Change the key of the record matching the src_key of the table. Specify the new key and its byte length in dest_key and dest_key_size. This operation is allowed only for table of type GRN_TABLE_DAT_KEY.

Parameters
ctxThe context object
tableTarget table
src_keyKey of record to be updated
src_key_sizeLength of src_key (byte)
dest_keyNew key
dest_key_sizeLength of dest_key_size (byte)
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_OPERATION_NOT_PERMITTED is returned if not GRN_TABLE_DAT_KEY.

◆ grn_table_update_by_id()

GRN_API grn_rc grn_table_update_by_id ( grn_ctx ctx,
grn_obj table,
grn_id  id,
const void *  dest_key,
unsigned int  dest_key_size 
)

Update the key of the record matching ID in the table. This operation supports only GRN_TABLE_DAT_KEY.

Parameters
ctxThe context object.
tableThe GRN_TABLE_DAT_KEY table.
idID of record to be updated.
dest_keyNew key.
dest_key_sizeSize of dest_key in bytes.
Returns
GRN_SUCCESS on success, the appropriate grn_rc on error. For example, GRN_OPERATION_NOT_PERMITTED is returned if the table other than GRN_TABLE_DAT_KEY is specified.