diff options
author | adam <adamansky@gmail.com> | 2012-11-16 23:33:00 +0700 |
---|---|---|
committer | adam <adamansky@gmail.com> | 2012-11-16 23:33:00 +0700 |
commit | 3168c195667a644ade91c1122ee52b5be0f45985 (patch) | |
tree | b7d2b9365de9db1959aeaff29c4454348eec60f2 /tcejdb | |
parent | 64af1cebfeb59e0fb1e61eff538580ba295f5774 (diff) | |
download | ejdb-3168c195667a644ade91c1122ee52b5be0f45985.tar.gz ejdb-3168c195667a644ade91c1122ee52b5be0f45985.tar.bz2 ejdb-3168c195667a644ade91c1122ee52b5be0f45985.zip |
#9 minors
Diffstat (limited to 'tcejdb')
-rw-r--r-- | tcejdb/ejdb.c | 18 | ||||
-rw-r--r-- | tcejdb/ejdb_private.h | 1 |
2 files changed, 11 insertions, 8 deletions
diff --git a/tcejdb/ejdb.c b/tcejdb/ejdb.c index 649e5a0..9a04989 100644 --- a/tcejdb/ejdb.c +++ b/tcejdb/ejdb.c @@ -85,8 +85,8 @@ static bool _metasetbson(EJDB *jb, const char *colname, int colnamesz, static bool _metasetbson2(EJCOLL *jcoll, const char *mkey, bson *val, bool merge, bool mergeoverwrt); static bson* _imetaidx(EJCOLL *jcoll, const char *ipath); static void _qrypreprocess(EJCOLL *jcoll, EJQ *ejq, int qflags, EJQF **mqf, TCMAP **ifields); -static TCMAP* _parseqobj(EJDB *jb, bson *qspec); -static int _parse_qobj_impl(EJDB *jb, bson_iterator *it, TCMAP *qmap, TCLIST *pathStack, EJQF *pqf); +static TCMAP* _parseqobj(EJDB *jb, EJQ *q, bson *qspec); +static int _parse_qobj_impl(EJDB *jb, EJQ *q, bson_iterator *it, TCMAP *qmap, TCLIST *pathStack, EJQF *pqf); static int _ejdbsoncmp(const TCLISTDATUM *d1, const TCLISTDATUM *d2, void *opaque); static bool _qrycondcheckstrand(const char *vbuf, const TCLIST *tokens); static bool _qrycondcheckstror(const char *vbuf, const TCLIST *tokens); @@ -422,7 +422,7 @@ EJDB_EXPORT EJQ* ejdbcreatequery(EJDB *jb, bson *qobj, bson *orqobjs, int orqobj EJQ *q; TCCALLOC(q, 1, sizeof (*q)); if (qobj) { - q->qobjmap = _parseqobj(jb, qobj); + q->qobjmap = _parseqobj(jb, q, qobj); if (!q->qobjmap) { goto error; } @@ -1392,6 +1392,7 @@ static void _qrydup(const EJQ *src, EJQ *target, uint32_t qflags) { while ((kbuf = tcmapiternext(src->qobjmap, &ksz)) != NULL) { EJQF qf; _qryfieldup(tcmapiterval(kbuf, &vsz), &qf, qflags); + qf.q = target; tcmapput(target->qobjmap, kbuf, ksz, &qf, sizeof (qf)); } } @@ -2648,7 +2649,7 @@ static char* _fetch_bson_str_array2(EJDB *jb, bson_iterator *it, bson_type *type return tokens; } -static int _parse_qobj_impl(EJDB *jb, bson_iterator *it, TCMAP *qmap, TCLIST *pathStack, EJQF *pqf) { +static int _parse_qobj_impl(EJDB *jb, EJQ *q, bson_iterator *it, TCMAP *qmap, TCLIST *pathStack, EJQF *pqf) { assert(it && qmap && pathStack); int ret = 0; bson_type ftype; @@ -2668,6 +2669,7 @@ static int _parse_qobj_impl(EJDB *jb, bson_iterator *it, TCMAP *qmap, TCLIST *pa EJQF qf; memset(&qf, 0, sizeof (qf)); + qf.q = q; if (!isckey) { //Push key on top of path stack @@ -2751,7 +2753,7 @@ static int _parse_qobj_impl(EJDB *jb, bson_iterator *it, TCMAP *qmap, TCLIST *pa } else { bson_iterator sit; bson_iterator_subiterator(it, &sit); - ret = _parse_qobj_impl(jb, &sit, qmap, pathStack, &qf); + ret = _parse_qobj_impl(jb, q, &sit, qmap, pathStack, &qf); break; } } @@ -2760,7 +2762,7 @@ static int _parse_qobj_impl(EJDB *jb, bson_iterator *it, TCMAP *qmap, TCLIST *pa { bson_iterator sit; bson_iterator_subiterator(it, &sit); - ret = _parse_qobj_impl(jb, &sit, qmap, pathStack, &qf); + ret = _parse_qobj_impl(jb, q, &sit, qmap, pathStack, &qf); break; } case BSON_OID: @@ -2914,14 +2916,14 @@ static int _parse_qobj_impl(EJDB *jb, bson_iterator *it, TCMAP *qmap, TCLIST *pa * Created map instance must be freed `tcmapdel`. * Each element of map must be freed by TODO */ -static TCMAP* _parseqobj(EJDB *jb, bson *qspec) { +static TCMAP* _parseqobj(EJDB *jb, EJQ *q, bson *qspec) { assert(qspec); int rv = 0; TCMAP *res = tcmapnew(); bson_iterator it; bson_iterator_init(&it, qspec); TCLIST *pathStack = tclistnew(); - rv = _parse_qobj_impl(jb, &it, res, pathStack, NULL); + rv = _parse_qobj_impl(jb, q, &it, res, pathStack, NULL); if (rv) { tcmapdel(res); res = NULL; diff --git a/tcejdb/ejdb_private.h b/tcejdb/ejdb_private.h index a50ed87..edd4178 100644 --- a/tcejdb/ejdb_private.h +++ b/tcejdb/ejdb_private.h @@ -79,6 +79,7 @@ struct EJQF { /**> Matching field and status */ const TDBIDX *idx; /**> Column index for this field if exists */ bson *idxmeta; /**> Index metainfo */ EJDB *jb; /**> Reference to the EJDB during query processing */ + EJQ *q; /**> Query object field embedded into */ }; typedef struct EJQF EJQF; |