From 99e50561254095e0815c8cb25d7f0924d11043df Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 24 May 2013 00:24:49 +0700 Subject: [PATCH] fixed #64 --- tcejdb/configure | 18 +++++++++--------- tcejdb/configure.ac | 2 +- tcejdb/ejdb.c | 20 ++++++++++++++++++++ tcejdb/tchdb.h | 4 ++-- tcejdb/tcutil.h | 2 +- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/tcejdb/configure b/tcejdb/configure index b8c02f9..f97a205 100755 --- a/tcejdb/configure +++ b/tcejdb/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tcejdb 1.1.4. +# Generated by GNU Autoconf 2.69 for tcejdb 1.1.5. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='tcejdb' PACKAGE_TARNAME='tcejdb' -PACKAGE_VERSION='1.1.4' -PACKAGE_STRING='tcejdb 1.1.4' +PACKAGE_VERSION='1.1.5' +PACKAGE_STRING='tcejdb 1.1.5' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1268,7 +1268,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tcejdb 1.1.4 to adapt to many kinds of systems. +\`configure' configures tcejdb 1.1.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1333,7 +1333,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of tcejdb 1.1.4:";; + short | recursive ) echo "Configuration of tcejdb 1.1.5:";; esac cat <<\_ACEOF @@ -1439,7 +1439,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tcejdb configure 1.1.4 +tcejdb configure 1.1.5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1737,7 +1737,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tcejdb $as_me 1.1.4, which was +It was created by tcejdb $as_me 1.1.5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -5273,7 +5273,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tcejdb $as_me 1.1.4, which was +This file was extended by tcejdb $as_me 1.1.5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5326,7 +5326,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tcejdb config.status 1.1.4 +tcejdb config.status 1.1.5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/tcejdb/configure.ac b/tcejdb/configure.ac index 7503ee7..0ef5169 100644 --- a/tcejdb/configure.ac +++ b/tcejdb/configure.ac @@ -10,7 +10,7 @@ test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS" test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS" # Package name -AC_INIT(tcejdb, 1.1.4) +AC_INIT(tcejdb, 1.1.5) AC_CANONICAL_HOST # Package information diff --git a/tcejdb/ejdb.c b/tcejdb/ejdb.c index ceaa10a..c36ef76 100644 --- a/tcejdb/ejdb.c +++ b/tcejdb/ejdb.c @@ -66,6 +66,10 @@ typedef struct { bool icase; //ignore case normalization } _BSONIPATHROWLDR; + +/* Maximum number of objects keeped to update deffered indexes */ +#define JBMAXDEFFEREDIDXNUM 512 + /* context of deffered index updates. See `_updatebsonidx()` */ typedef struct { bson_oid_t oid; @@ -4187,6 +4191,22 @@ static bool _updatebsonidx(EJCOLL *jcoll, const bson_oid_t *oid, const bson *bs, if (dctx.imap || dctx.rmap) { TCLISTPUSH(dlist, &dctx, sizeof (dctx)); } + //flush deffered indexes if number pending objects greater JBMAXDEFFEREDIDXNUM + if (TCLISTNUM(dlist) >= JBMAXDEFFEREDIDXNUM) { + for (int i = 0; i < TCLISTNUM(dlist); ++i) { + _DEFFEREDIDXCTX *di = TCLISTVALPTR(dlist, i); + assert(di); + if (di->rmap) { + tctdbidxout2(jcoll->tdb, &(di->oid), sizeof (di->oid), di->rmap); + tcmapdel(di->rmap); + } + if (di->imap) { + tctdbidxput2(jcoll->tdb, &(di->oid), sizeof (di->oid), di->imap); + tcmapdel(di->imap); + } + } + TCLISTTRUNC(dlist, 0); + } } else { //apply index changes immediately if (rimap && !tctdbidxout2(jcoll->tdb, oid, sizeof (*oid), rimap)) rv = false; if (imap && !tctdbidxput2(jcoll->tdb, oid, sizeof (*oid), imap)) rv = false; diff --git a/tcejdb/tchdb.h b/tcejdb/tchdb.h index 7b4e96d..4e30d6c 100644 --- a/tcejdb/tchdb.h +++ b/tcejdb/tchdb.h @@ -417,7 +417,7 @@ EJDB_EXPORT int tchdbvsiz2(TCHDB *hdb, const char *kstr); If successful, the return value is true, else, it is false. The iterator is used in order to access the key of every record stored in a database. */ EJDB_EXPORT bool tchdbiterinit(TCHDB *hdb); -EJDB_EXPORT bool tchdbiterinit4(TCHDB *hdb, uint64_t *iter); +bool tchdbiterinit4(TCHDB *hdb, uint64_t *iter); /* Get the next key of the iterator of a hash database object. @@ -457,7 +457,7 @@ EJDB_EXPORT char *tchdbiternext2(TCHDB *hdb); If successful, the return value is true, else, it is false. False is returned when no record is to be get out of the iterator. */ EJDB_EXPORT bool tchdbiternext3(TCHDB *hdb, TCXSTR *kxstr, TCXSTR *vxstr); -EJDB_EXPORT bool tchdbiternext4(TCHDB *hdb, uint64_t *iter, TCXSTR *kxstr, TCXSTR *vxstr); +bool tchdbiternext4(TCHDB *hdb, uint64_t *iter, TCXSTR *kxstr, TCXSTR *vxstr); /* Get forward matching keys in a hash database object. diff --git a/tcejdb/tcutil.h b/tcejdb/tcutil.h index b97ce11..09b7da8 100644 --- a/tcejdb/tcutil.h +++ b/tcejdb/tcutil.h @@ -3725,7 +3725,7 @@ typedef unsigned char TCBITMAP; /* type of a bit map object */ #include -#define _TC_VERSION "1.1.4" +#define _TC_VERSION "1.1.5" #define _TC_LIBVER 911 #define _TC_FORMATVER "1.0" -- 2.7.4