[Groonga-commit] groonga/groonga [master] add a skeleton of grn_dat.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 6月 18日 (土) 09:33:32 JST


Susumu Yata	2011-06-18 00:33:32 +0000 (Sat, 18 Jun 2011)

  New Revision: ec55c89f648829562fbfc3918b49b8c426797f1c

  Log:
    add a skeleton of grn_dat.

  Added files:
    lib/dat.cpp
    lib/dat.h
  Modified files:
    configure.ac
    lib/Makefile.am
    lib/groonga_in.h

  Modified: configure.ac (+1 -0)
===================================================================
--- configure.ac    2011-06-17 14:46:20 +0000 (d07105e)
+++ configure.ac    2011-06-18 00:33:32 +0000 (537848e)
@@ -40,6 +40,7 @@ AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
 AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
 
 AC_C_BIGENDIAN
+AC_PROG_CXX
 AC_PROG_CC
 AM_PROG_CC_C_O
 m4_ifdef([PKG_PROG_PKG_CONFIG],

  Modified: lib/Makefile.am (+2 -2)
===================================================================
--- lib/Makefile.am    2011-06-17 14:46:20 +0000 (cb1d207)
+++ lib/Makefile.am    2011-06-18 00:33:32 +0000 (4f5eaa7)
@@ -5,14 +5,14 @@ AM_CFLAGS = -fno-strict-aliasing $(COVERAGE_CFLAGS) $(GRN_CFLAGS)
 DEFAULT_INCLUDES = -I$(top_builddir) -I$(top_srcdir)/include
 DEFS += -D_REENTRANT -DGROONGA_VERSION=\"$(GROONGA_VERSION)\" $(GRN_DEFS)
 
-libgroonga_la_SOURCES = io.c str.c nfkc.c snip.c query.c store.c com.c ql.c scm.c ctx.c hash.c db.c pat.c ii.c token.c proc.c expr.c util.c plugin.c output.c geo.c
+libgroonga_la_SOURCES = io.c str.c nfkc.c snip.c query.c store.c com.c ql.c scm.c ctx.c hash.c db.c pat.c dat.cpp ii.c token.c proc.c expr.c util.c plugin.c output.c geo.c
 
 libgroonga_la_LDFLAGS =				\
 	-version-info $(LT_VERSION_INFO)	\
 	-no-undefined				\
 	$(WINDOWS_LDFLAGS)
 
-noinst_HEADERS = com.h io.h ql.h nfkc.h groonga_in.h snip.h store.h str.h ctx.h hash.h db.h pat.h ii.h token.h proc.h util.h plugin_in.h output.h geo.h
+noinst_HEADERS = com.h io.h ql.h nfkc.h groonga_in.h snip.h store.h str.h ctx.h hash.h db.h pat.h dat.h ii.h token.h proc.h util.h plugin_in.h output.h geo.h
 
 EXTRA_DIST = ecmascript.c ecmascript.h ecmascript.y
 

  Added: lib/dat.cpp (+137 -0) 100644
===================================================================
--- /dev/null
+++ lib/dat.cpp    2011-06-18 00:33:32 +0000 (5fcbcd1)
@@ -0,0 +1,137 @@
+/* -*- c-basic-offset: 2 -*- */
+/* Copyright(C) 2011 Brazil
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License version 2.1 as published by the Free Software Foundation.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#include "groonga_in.h"
+#include "dat.h"
+#include "util.h"
+
+namespace grn {
+namespace dat {
+
+class Trie {
+ public:
+  static Trie *create(const char *path) {
+    return new Trie;
+  }
+  static Trie *open(const char *path) {
+    return new Trie;
+  }
+
+  uint32_t num_keys() const {
+    return 0;
+  }
+
+ private:
+};
+
+}  // namespace dat
+}  // namespace grn
+
+extern "C" {
+
+static void grn_dat_init(grn_dat *dat) {
+  dat->handle = NULL;
+}
+
+static void grn_dat_end(grn_dat *dat) {
+  delete static_cast<grn::dat::Trie *>(dat->handle);
+  dat->handle = NULL;
+}
+
+grn_dat *grn_dat_create(grn_ctx *ctx, const char *path, unsigned int,
+                        unsigned int, unsigned int) {
+  grn_dat *dat = static_cast<grn_dat *>(GRN_MALLOC(sizeof(grn_dat)));
+  if (dat == NULL) {
+    return NULL;
+  }
+  grn_dat_init(dat);
+  dat->handle = grn::dat::Trie::create(path);
+  if (dat->handle == NULL) {
+    GRN_FREE(dat);
+    return NULL;
+  }
+  return dat;
+}
+
+grn_dat *grn_dat_open(grn_ctx *ctx, const char *path) {
+  grn_dat *dat = static_cast<grn_dat *>(GRN_MALLOC(sizeof(grn_dat)));
+  if (dat == NULL) {
+    return NULL;
+  }
+  grn_dat_init(dat);
+  dat->handle = grn::dat::Trie::open(path);
+  if (dat->handle == NULL) {
+    GRN_FREE(dat);
+    return NULL;
+  }
+  return dat;
+}
+
+grn_rc grn_dat_close(grn_ctx *ctx, grn_dat *dat) {
+  grn_dat_end(dat);
+  GRN_FREE(dat);
+  return GRN_SUCCESS;
+}
+
+grn_rc grn_dat_remove(grn_ctx *ctx, const char *path) {
+  return GRN_SUCCESS;
+}
+
+grn_id grn_dat_get(grn_ctx *ctx, grn_dat *dat, const void *key,
+                   unsigned int key_size, void **value) {
+  return GRN_ID_NIL;
+}
+
+grn_id grn_dat_add(grn_ctx *ctx, grn_dat *dat, const void *key,
+                   unsigned int key_size, void **value, int *added) {
+  return GRN_ID_NIL;
+}
+
+int grn_dat_get_key(grn_ctx *ctx, grn_dat *dat, grn_id id,
+                    void *keybuf, int bufsize) {
+  return 0;
+}
+
+unsigned int grn_dat_size(grn_ctx *ctx, grn_dat *dat) {
+  if (dat == NULL) {
+    return GRN_INVALID_ARGUMENT;
+  }
+  return static_cast<grn::dat::Trie *>(dat->handle)->num_keys();
+}
+
+grn_dat_cursor *grn_dat_cursor_open(grn_ctx *ctx, grn_dat *dat,
+                                    const void *min, unsigned int min_size,
+                                    const void *max, unsigned int max_size,
+                                    int offset, int limit, int flags) {
+  return NULL;
+}
+
+grn_id grn_dat_cursor_next(grn_ctx *ctx, grn_dat_cursor *c) {
+  return GRN_ID_NIL;
+}
+
+void grn_dat_cursor_close(grn_ctx *ctx, grn_dat_cursor *c) {
+}
+
+int grn_dat_cursor_get_key(grn_ctx *ctx, grn_dat_cursor *c, void **key) {
+  return 0;
+}
+
+grn_id grn_dat_curr_id(grn_ctx *ctx, grn_dat *dat) {
+  return 0;
+}
+
+}  // extern "C"

  Added: lib/dat.h (+90 -0) 100644
===================================================================
--- /dev/null
+++ lib/dat.h    2011-06-18 00:33:32 +0000 (2357306)
@@ -0,0 +1,90 @@
+/* -*- c-basic-offset: 2 -*- */
+/* Copyright(C) 2011 Brazil
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License version 2.1 as published by the Free Software Foundation.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#ifndef GRN_DAT_H
+#define GRN_DAT_H
+
+#ifndef GROONGA_IN_H
+#include "groonga_in.h"
+#endif /* GROONGA_IN_H */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *grn_dat_handle;
+
+struct _grn_dat {
+  grn_dat_handle handle;
+//  grn_db_obj obj;
+//  grn_io *io;
+//  struct grn_dat_header *header;
+//  grn_encoding encoding;
+//  uint32_t key_size;
+//  uint32_t value_size;
+//  grn_obj *tokenizer;
+};
+
+struct _grn_dat_cursor {
+//  grn_db_obj obj;
+//  grn_id curr_rec;
+//  grn_dat *pat;
+//  grn_ctx *ctx;
+//  unsigned int size;
+//  unsigned int sp;
+//  grn_id tail;
+//  unsigned int rest;
+//  grn_dat_cursor_entry *ss;
+//  uint8_t curr_key[GRN_TABLE_MAX_KEY_SIZE];
+};
+
+typedef struct _grn_dat grn_dat;
+typedef struct _grn_dat_cursor grn_dat_cursor;
+
+GRN_API grn_dat *grn_dat_create(grn_ctx *ctx, const char *path, unsigned int key_size,
+                                unsigned int value_size, unsigned int flags);
+
+GRN_API grn_dat *grn_dat_open(grn_ctx *ctx, const char *path);
+
+GRN_API grn_rc grn_dat_close(grn_ctx *ctx, grn_dat *dat);
+
+GRN_API grn_rc grn_dat_remove(grn_ctx *ctx, const char *path);
+
+GRN_API grn_id grn_dat_get(grn_ctx *ctx, grn_dat *dat, const void *key,
+                           unsigned int key_size, void **value);
+GRN_API grn_id grn_dat_add(grn_ctx *ctx, grn_dat *dat, const void *key,
+                           unsigned int key_size, void **value, int *added);
+
+GRN_API int grn_dat_get_key(grn_ctx *ctx, grn_dat *dat, grn_id id, void *keybuf, int bufsize);
+
+GRN_API unsigned int grn_dat_size(grn_ctx *ctx, grn_dat *dat);
+
+GRN_API grn_dat_cursor *grn_dat_cursor_open(grn_ctx *ctx, grn_dat *dat,
+                                            const void *min, unsigned int min_size,
+                                            const void *max, unsigned int max_size,
+                                            int offset, int limit, int flags);
+GRN_API grn_id grn_dat_cursor_next(grn_ctx *ctx, grn_dat_cursor *c);
+GRN_API void grn_dat_cursor_close(grn_ctx *ctx, grn_dat_cursor *c);
+
+GRN_API int grn_dat_cursor_get_key(grn_ctx *ctx, grn_dat_cursor *c, void **key);
+
+grn_id grn_dat_curr_id(grn_ctx *ctx, grn_dat *dat);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRN_DAT_H */

  Modified: lib/groonga_in.h (+4 -0)
===================================================================
--- lib/groonga_in.h    2011-06-17 14:46:20 +0000 (1f4a107)
+++ lib/groonga_in.h    2011-06-18 00:33:32 +0000 (356b192)
@@ -40,6 +40,10 @@
 #endif
 #endif /* USE_AIO */
 
+#ifdef __cplusplus
+#define __STDC_LIMIT_MACROS
+#endif
+
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif /* HAVE_STDLIB_H */




Groonga-commit メーリングリストの案内
Back to archive index