Navigation Menu

Skip to content

Commit

Permalink
Mark GRN_CTX_USE_QL and GRN_CTX_BATCH_MODE are deprecated
Browse files Browse the repository at this point in the history
Because Groonga removed the internal Scheme interpreter long time ago.
  • Loading branch information
kou committed Jun 16, 2014
1 parent f4452fc commit 25628f1
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions include/groonga.h
Expand Up @@ -215,8 +215,8 @@ struct _grn_ctx {

#define GRN_CTX_USER_DATA(ctx) (&((ctx)->user_data))

#define GRN_CTX_USE_QL (0x03)
#define GRN_CTX_BATCH_MODE (0x04)
#define GRN_CTX_USE_QL (0x03) /* Deprecated. Don't use it. */
#define GRN_CTX_BATCH_MODE (0x04) /* Deprecated. Don't use it. */
#define GRN_CTX_PER_DB (0x08)

GRN_API grn_rc grn_ctx_init(grn_ctx *ctx, int flags);
Expand Down
6 changes: 0 additions & 6 deletions lib/ctx.c
Expand Up @@ -497,7 +497,6 @@ grn_ctx_impl_init(grn_ctx *ctx)
ctx->impl->n_entries = 0;
ctx->impl->cur = NULL;
ctx->impl->str_end = NULL;
ctx->impl->batchmode = 0;
ctx->impl->inbuf = NULL;
ctx->impl->com = NULL;
ctx->impl->outbuf = grn_obj_open(ctx, GRN_BULK, 0, 0);
Expand Down Expand Up @@ -590,11 +589,6 @@ grn_ctx_init(grn_ctx *ctx, int flags)
ctx->seqno2 = 0;
ctx->subno = 0;
ctx->impl = NULL;
if (flags & GRN_CTX_USE_QL) {
grn_ctx_impl_init(ctx);
if (ERRP(ctx, GRN_ERROR)) { return ctx->rc; }
if (flags & GRN_CTX_BATCH_MODE) { ctx->impl->batchmode = 1; }
}
ctx->user_data.ptr = NULL;
CRITICAL_SECTION_ENTER(grn_glock);
ctx->next = grn_gctx.next;
Expand Down
3 changes: 1 addition & 2 deletions lib/ctx_impl.h
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2009-2013 Brazil
Copyright(C) 2009-2014 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -155,7 +155,6 @@ struct _grn_ctx_impl {
grn_proc_func *finalizer;

/* ql portion */
uint8_t batchmode;
uint8_t op;
int tok;
char *cur;
Expand Down
40 changes: 18 additions & 22 deletions src/groonga.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2009-2013 Brazil
Copyright(C) 2009-2014 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -83,7 +83,6 @@ static int port = DEFAULT_GQTP_PORT;
static int batchmode;
static int number_of_lines = 0;
static int newdb;
static int useql;
static grn_bool is_daemon_mode = GRN_FALSE;
static int (*do_client)(int argc, char **argv);
static int (*do_server)(char *path);
Expand Down Expand Up @@ -304,7 +303,7 @@ do_alone(int argc, char **argv)
char *path = NULL;
grn_obj *db;
grn_ctx ctx_, *ctx = &ctx_;
grn_ctx_init(ctx, (useql ? GRN_CTX_USE_QL : 0)|(batchmode ? GRN_CTX_BATCH_MODE : 0));
grn_ctx_init(ctx, 0);
if (argc > 0 && argv) { path = *argv++; argc--; }
db = (newdb || !path) ? grn_db_create(ctx, path, NULL) : grn_db_open(ctx, path);
if (db) {
Expand Down Expand Up @@ -381,7 +380,7 @@ g_client(int argc, char **argv)
grn_ctx ctx_, *ctx = &ctx_;
const char *hostname = DEFAULT_DEST;
if (argc > 0 && argv) { hostname = *argv++; argc--; }
grn_ctx_init(ctx, (batchmode ? GRN_CTX_BATCH_MODE : 0));
grn_ctx_init(ctx, 0);
if (!grn_ctx_connect(ctx, hostname, port, 0)) {
if (!argc) {
grn_obj text;
Expand Down Expand Up @@ -1853,7 +1852,7 @@ g_handler(grn_ctx *ctx, grn_obj *msg)
int added;
edge = grn_edges_add(ctx, &((grn_msg *)msg)->edge_id, &added);
if (added) {
grn_ctx_init(&edge->ctx, (useql ? GRN_CTX_USE_QL : 0));
grn_ctx_init(&edge->ctx, 0);
GRN_COM_QUEUE_INIT(&edge->recv_new);
GRN_COM_QUEUE_INIT(&edge->send_old);
grn_ctx_use(&edge->ctx, (grn_obj *)com->ev->opaque);
Expand Down Expand Up @@ -1903,7 +1902,6 @@ enum {
};

#define MODE_MASK 0x007f
#define MODE_USE_QL 0x0080
#define MODE_NEW_DB 0x0100

static uint32_t
Expand Down Expand Up @@ -2411,7 +2409,6 @@ main(int argc, char **argv)
{'s', NULL, NULL, mode_server, GETOPT_OP_UPDATE},
{'l', "log-level", NULL, 0, GETOPT_OP_NONE},
{'i', "server-id", NULL, 0, GETOPT_OP_NONE},
{'q', NULL, NULL, MODE_USE_QL, GETOPT_OP_ON},
{'n', NULL, NULL, MODE_NEW_DB, GETOPT_OP_ON},
{'\0', "protocol", NULL, 0, GETOPT_OP_NONE},
{'\0', "version", NULL, mode_version, GETOPT_OP_UPDATE},
Expand All @@ -2436,20 +2433,20 @@ main(int argc, char **argv)
opts[2].arg = &max_num_threads_arg;
opts[7].arg = &log_level_arg;
opts[8].arg = &hostname_arg;
opts[11].arg = &protocol_arg;
opts[13].arg = &log_path_arg;
opts[14].arg = &query_log_path_arg;
opts[15].arg = &pid_file_path;
opts[16].arg = &config_path;
opts[18].arg = &cache_limit_arg;
opts[19].arg = &input_path;
opts[20].arg = &document_root_arg;
opts[21].arg = &default_command_version_arg;
opts[22].arg = &default_match_escalation_threshold_arg;
opts[23].arg = &bind_address_arg;
opts[24].arg = &input_fd_arg;
opts[25].arg = &output_fd_arg;
opts[26].arg = &working_directory_arg;
opts[10].arg = &protocol_arg;
opts[12].arg = &log_path_arg;
opts[13].arg = &query_log_path_arg;
opts[14].arg = &pid_file_path;
opts[15].arg = &config_path;
opts[17].arg = &cache_limit_arg;
opts[18].arg = &input_path;
opts[19].arg = &document_root_arg;
opts[20].arg = &default_command_version_arg;
opts[21].arg = &default_match_escalation_threshold_arg;
opts[22].arg = &bind_address_arg;
opts[23].arg = &input_fd_arg;
opts[24].arg = &output_fd_arg;
opts[25].arg = &working_directory_arg;

reset_ready_notify_pipe();

Expand Down Expand Up @@ -2791,7 +2788,6 @@ main(int argc, char **argv)
}

newdb = (mode & MODE_NEW_DB);
useql = (mode & MODE_USE_QL);
switch (mode & MODE_MASK) {
case mode_alone :
exit_code = do_alone(argc - i, argv + i);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/core/test-context.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2008-2010 Kouhei Sutou <kou@clear-code.com>
Copyright (C) 2008-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -40,7 +40,7 @@ cut_setup(void)
{
context = NULL;
database = NULL;
default_flags = GRN_CTX_USE_QL;
default_flags = 0;
memory = NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/core/test-inverted-index.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2008-2012 Kouhei Sutou <kou@clear-code.com>
Copyright (C) 2008-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -96,7 +96,7 @@ cut_setup(void)
path = g_build_filename(tmp_directory, "inverted-index", NULL);

context = g_new0(grn_ctx, 1);
grn_test_assert(grn_ctx_init(context, GRN_CTX_USE_QL));
grn_test_assert(grn_ctx_init(context, 0));
GRN_CTX_SET_ENCODING(context, GRN_ENC_UTF8);

db = grn_db_create(context, NULL, NULL);
Expand Down
5 changes: 1 addition & 4 deletions test/unit/core/test-patricia-trie.c
Expand Up @@ -49,7 +49,6 @@ void test_at(gconstpointer data);

static GArray *ids;
static GList *expected_keys, *actual_keys;
static grn_obj *database;

void
cut_setup(void)
Expand All @@ -59,7 +58,6 @@ cut_setup(void)
ids = NULL;
expected_keys = NULL;
actual_keys = NULL;
database = NULL;
}

static void
Expand All @@ -78,8 +76,6 @@ cut_teardown(void)
gcut_list_string_free(expected_keys);
if (actual_keys)
gcut_list_string_free(actual_keys);
if (database)
grn_obj_close(context, database);
teardown_trie_common();
}

Expand Down Expand Up @@ -827,6 +823,7 @@ test_at(gconstpointer data)

cut_assert_open_context();

grn_obj_close(context, database);
database = grn_db_create(context,
cut_build_path(grn_test_get_tmp_dir(),
"patricia-trie.db",
Expand Down
28 changes: 21 additions & 7 deletions test/unit/core/test-patricia-trie.h
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2008-2009 Kouhei Sutou <kou@cozmixng.org>
Copyright (C) 2008-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -30,6 +30,7 @@ static grn_logger_info *logger;
static GList *expected_messages;

static grn_ctx *context;
static grn_obj *database;
static grn_pat *trie;
static grn_pat_cursor *cursor;
static grn_id id;
Expand Down Expand Up @@ -65,6 +66,7 @@ setup_trie_common(const gchar *default_path_component)
expected_messages = NULL;

context = NULL;
database = NULL;
trie = NULL;
cursor = NULL;
id = GRN_ID_NIL;
Expand All @@ -88,7 +90,7 @@ setup_trie_common(const gchar *default_path_component)
default_cursor_limit = -1;
default_cursor_flags = 0;

default_context_flags = GRN_CTX_USE_QL;
default_context_flags = 0;

cut_remove_path(base_dir, NULL);
g_mkdir_with_parents(base_dir, 0755);
Expand Down Expand Up @@ -121,12 +123,22 @@ trie_free(void)
}
}

static void
database_free(void)
{
if (context && database) {
grn_obj_close(context, database);
database = NULL;
}
}

static void
context_free(void)
{
if (context) {
cursor_free();
trie_free();
database_free();
grn_ctx_fin(context);
context = NULL;
}
Expand Down Expand Up @@ -167,11 +179,13 @@ teardown_trie_common(void)
GRN_CTX_SET_ENCODING(context, default_encoding); \
} while (0)

#define cut_assert_open_context() do \
{ \
context_free(); \
open_context(); \
cut_assert(context); \
#define cut_assert_open_context() do \
{ \
context_free(); \
open_context(); \
cut_assert(context); \
database = grn_db_create(context, NULL, NULL); \
cut_assert(database); \
} while (0)

#define create_trie() do \
Expand Down
4 changes: 2 additions & 2 deletions test/unit/core/test-performance.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2008-2009 Kouhei Sutou <kou@cozmixng.org>
Copyright (C) 2008-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -184,7 +184,7 @@ run_test(const gchar **test_case_names, const grn_test_data *data)
const gchar *type_name, *table_name;
gchar *path;

grn_test_assert(grn_ctx_init(context, GRN_CTX_USE_QL));
grn_test_assert(grn_ctx_init(context, 0));

GRN_CTX_SET_ENCODING(context, GRN_ENC_UTF8);

Expand Down
4 changes: 2 additions & 2 deletions test/unit/core/test-public-context.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2008-2009 Kouhei Sutou <kou@cozmixng.org>
Copyright (C) 2008-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -42,7 +42,7 @@ cut_setup(void)
base_dir = grn_test_get_tmp_dir();
default_path = g_build_filename(base_dir, "db", NULL);
default_encoding = GRN_ENC_DEFAULT;
default_context_flags = GRN_CTX_USE_QL;
default_context_flags = 0;

cut_remove_path(base_dir, NULL);
g_mkdir_with_parents(base_dir, 0755);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/core/test-stress.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2008-2009 Kouhei Sutou <kou@cozmixng.org>
Copyright (C) 2008-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -182,7 +182,7 @@ test_hash(gconstpointer test_data)
gchar *path;
const gchar *test_case_names[] = {"test_stress_hash", NULL};

grn_test_assert(grn_ctx_init(context, GRN_CTX_USE_QL));
grn_test_assert(grn_ctx_init(context, 0));

path = g_build_filename(base_dir, "hash", NULL);
g_setenv(GRN_TEST_ENV_HASH_PATH, path, TRUE);
Expand Down Expand Up @@ -214,7 +214,7 @@ test_patricia_trie(gconstpointer test_data)
gchar *path;
const gchar *test_case_names[] = {"test_stress_patricia_trie", NULL};

grn_test_assert(grn_ctx_init(context, GRN_CTX_USE_QL));
grn_test_assert(grn_ctx_init(context, 0));

path = g_build_filename(base_dir, "patricia-trie", NULL);
g_setenv(GRN_TEST_ENV_PATRICIA_TRIE_PATH, path, TRUE);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/core/test-tokenizer.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -34,7 +34,7 @@ static grn_obj *db;
void
setup (void)
{
grn_ctx_init(&context, GRN_CTX_USE_QL);
grn_ctx_init(&context, 0);
db = grn_db_create(&context, NULL, NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/fixtures/performance/test-read-write.c
Expand Up @@ -123,7 +123,7 @@ test_read_write(gconstpointer *data)
if (process_number_string)
process_number = atoi(process_number_string);

rc = grn_ctx_init(&contexts[i], GRN_CTX_USE_QL);
rc = grn_ctx_init(&contexts[i], 0);
grn_test_assert(rc, cut_set_message("context: %d (%d)", i, process_number));
context = &contexts[i];

Expand Down

0 comments on commit 25628f1

Please sign in to comment.