Changeset 294d6fdf2503283b97bc859af2e7b875a85a6eea
- Timestamp:
- 04/23/08 20:21:34 (9 months ago)
- Author:
- David Balmain <dbalmain@…>
- Parents:
- 8f9e905705f715e2dc4745a098e9a1819271873a
- Children:
- ac6c089c859ffd951ffd9839fd3ec6b1f8703a0b, af195088ac05210716bf17da06c341a7d5469e58
- git-committer:
- David Balmain <dbalmain@gmail.com> / 2008-04-23T20:21:34Z+1000
- Message:
-
Updated Ruby bindings
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r8f9e90
|
r294d6f
|
|
| 5 | 5 | |
| 6 | 6 | |
| 7 | | static const char * NON_UNIQUE_KEY_ERROR_MSG = "Tried to use a key that was not unique"; |
| | 7 | static const char *NON_UNIQUE_KEY_ERROR_MSG = |
| | 8 | "Tried to use a key that was not unique"; |
| 8 | 9 | |
| 9 | 10 | static const char *ID_STRING = "id"; |
-
|
r8f9e90
|
r294d6f
|
|
| 2199 | 2199 | " was %s", buf, (char *)msg); |
| 2200 | 2200 | } |
| | 2201 | while (qp->fields_top->next != NULL) { |
| | 2202 | qp_pop_fields(qp); |
| | 2203 | } |
| 2201 | 2204 | return 0; |
| 2202 | 2205 | } |
| … |
… |
|
| 2859 | 2862 | void qp_destroy(QParser *self) |
| 2860 | 2863 | { |
| 2861 | | hs_destroy(self->tokenized_fields); |
| 2862 | | hs_destroy(self->def_fields); |
| | 2864 | if (self->tokenized_fields != self->all_fields) { |
| | 2865 | hs_destroy(self->tokenized_fields); |
| | 2866 | } |
| | 2867 | if (self->def_fields != self->all_fields) { |
| | 2868 | hs_destroy(self->def_fields); |
| | 2869 | } |
| 2863 | 2870 | hs_destroy(self->all_fields); |
| 2864 | 2871 | |
| … |
… |
|
| 3047 | 3054 | Query *volatile q = NULL; |
| 3048 | 3055 | qp->recovering = true; |
| | 3056 | assert(qp->fields_top->next == NULL); |
| 3049 | 3057 | FLDS(q, get_term_q(qp, field, str)); |
| 3050 | 3058 | return q; |
-
|
r8f9e90
|
r294d6f
|
|
| 462 | 462 | " was %s", buf, (char *)msg); |
| 463 | 463 | } |
| | 464 | while (qp->fields_top->next != NULL) { |
| | 465 | qp_pop_fields(qp); |
| | 466 | } |
| 464 | 467 | return 0; |
| 465 | 468 | } |
| … |
… |
|
| 1122 | 1125 | void qp_destroy(QParser *self) |
| 1123 | 1126 | { |
| 1124 | | hs_destroy(self->tokenized_fields); |
| 1125 | | hs_destroy(self->def_fields); |
| | 1127 | if (self->tokenized_fields != self->all_fields) { |
| | 1128 | hs_destroy(self->tokenized_fields); |
| | 1129 | } |
| | 1130 | if (self->def_fields != self->all_fields) { |
| | 1131 | hs_destroy(self->def_fields); |
| | 1132 | } |
| 1126 | 1133 | hs_destroy(self->all_fields); |
| 1127 | 1134 | |
| … |
… |
|
| 1310 | 1317 | Query *volatile q = NULL; |
| 1311 | 1318 | qp->recovering = true; |
| | 1319 | assert(qp->fields_top->next == NULL); |
| 1312 | 1320 | FLDS(q, get_term_q(qp, field, str)); |
| 1313 | 1321 | return q; |
-
|
r8f9e90
|
r294d6f
|
|
| 75 | 75 | {"()", ""}, |
| 76 | 76 | {"field:()", ""}, |
| | 77 | {"one AND (f1:two OR f2:three) AND four", |
| | 78 | "+one +(f1:two f2:three) +four"}, |
| 77 | 79 | {"xx:\"Hello Newman\" field:()", "\"hello newman\" ()"}, |
| 78 | 80 | {"one (two AND three)", "one (+two +three)"}, |
-
|
r399100
|
r294d6f
|
|
| 53 | 53 | if (rfields == Qnil) return NULL; |
| 54 | 54 | |
| 55 | | fields = hs_new_str(NULL); |
| | 55 | fields = hs_new_ptr(NULL); |
| 56 | 56 | if (TYPE(rfields) == T_ARRAY) { |
| 57 | 57 | int i; |
| … |
… |
|
| 77 | 77 | } |
| 78 | 78 | return fields; |
| | 79 | } |
| | 80 | |
| | 81 | static void |
| | 82 | hs_safe_merge(HashSet *merger, HashSet *mergee) |
| | 83 | { |
| | 84 | HashSetEntry *hse; |
| | 85 | for (hse = mergee->first; hse; hse = hse->next) { |
| | 86 | hs_add(merger, (char *)hse->elem); |
| | 87 | } |
| 79 | 88 | } |
| 80 | 89 | |
| … |
… |
|
| 177 | 186 | } |
| 178 | 187 | if (all_fields == NULL) { |
| 179 | | all_fields = hs_new_str(NULL); |
| | 188 | all_fields = hs_new_ptr(NULL); |
| 180 | 189 | } |
| 181 | 190 | |
| … |
… |
|
| 184 | 193 | } |
| 185 | 194 | |
| 186 | | qp = qp_new(all_fields, def_fields, tkz_fields, analyzer); |
| | 195 | qp = qp_new(analyzer); |
| | 196 | hs_destroy(qp->all_fields); |
| | 197 | hs_destroy(qp->def_fields); |
| | 198 | //hs_destroy(qp->tokenized_fields); |
| | 199 | |
| | 200 | if (def_fields) hs_safe_merge(all_fields, def_fields); |
| | 201 | if (tkz_fields) hs_safe_merge(all_fields, tkz_fields); |
| | 202 | qp->all_fields = all_fields; |
| | 203 | qp->def_fields = def_fields ? def_fields : all_fields; |
| | 204 | qp->tokenized_fields = tkz_fields ? tkz_fields : all_fields; |
| | 205 | qp->fields_top->fields = def_fields; |
| | 206 | |
| 187 | 207 | qp->allow_any_fields = true; |
| 188 | 208 | qp->clean_str = true; |
| … |
… |
|
| 286 | 306 | HashSet *fields = frb_get_fields(rfields); |
| 287 | 307 | |
| 288 | | if (qp->def_fields == qp->all_fields) { |
| 289 | | qp->def_fields = NULL; |
| 290 | | } |
| | 308 | /* if def_fields == all_fields then we need to replace both */ |
| | 309 | if (qp->def_fields == qp->all_fields) qp->def_fields = NULL; |
| | 310 | if (qp->tokenized_fields == qp->all_fields) qp->tokenized_fields = NULL; |
| | 311 | |
| 291 | 312 | if (fields == NULL) { |
| 292 | | fields = hs_new_str(NULL); |
| 293 | | } |
| | 313 | fields = hs_new_ptr(NULL); |
| | 314 | } |
| | 315 | |
| | 316 | /* make sure all the fields in tokenized fields are contained in |
| | 317 | * all_fields */ |
| | 318 | if (qp->tokenized_fields) hs_safe_merge(fields, qp->tokenized_fields); |
| | 319 | |
| | 320 | /* delete old fields set */ |
| | 321 | assert(qp->all_fields->free_elem_i == dummy_free); |
| 294 | 322 | hs_destroy(qp->all_fields); |
| | 323 | |
| | 324 | /* add the new fields set and add to def_fields if necessary */ |
| 295 | 325 | qp->all_fields = fields; |
| 296 | 326 | if (qp->def_fields == NULL) { |
| 297 | 327 | qp->def_fields = fields; |
| 298 | | } |
| | 328 | qp->fields_top->fields = fields; |
| | 329 | } |
| | 330 | if (qp->tokenized_fields == NULL) qp->tokenized_fields = fields; |
| 299 | 331 | |
| 300 | 332 | return self; |
| … |
… |
|
| 338 | 370 | { |
| 339 | 371 | GET_QP; |
| 340 | | if (qp->tokenized_fields) hs_destroy(qp->tokenized_fields); |
| | 372 | if (qp->tokenized_fields != qp->all_fields) { |
| | 373 | hs_destroy(qp->tokenized_fields); |
| | 374 | } |
| 341 | 375 | qp->tokenized_fields = frb_get_fields(rfields); |
| 342 | 376 | return self; |