Kouhei Sutou
null+****@clear*****
Fri Oct 19 00:31:54 JST 2012
Kouhei Sutou 2012-10-19 00:31:54 +0900 (Fri, 19 Oct 2012) New Revision: 20368c13634c3f16a1ee867f4425a4c07fb99ed3 https://github.com/groonga/groonga/commit/20368c13634c3f16a1ee867f4425a4c07fb99ed3 Merged d02a005: Merge pull request #35 from groonga/get-value-support-vector Log: Support vector by GRN_OP_GET_VALUE We need to set not only header.domain but also header.flags for vector. Modified files: lib/db.c lib/db.h lib/expr.c Modified: lib/db.c (+21 -0) =================================================================== --- lib/db.c 2012-10-19 00:30:48 +0900 (36b703f) +++ lib/db.c 2012-10-19 00:31:54 +0900 (d931e1d) @@ -7358,6 +7358,27 @@ grn_obj_reinit(grn_ctx *ctx, grn_obj *obj, grn_id domain, unsigned char flags) return ctx->rc; } +grn_rc +grn_obj_reinit_for(grn_ctx *ctx, grn_obj *obj, grn_obj *domain_obj) +{ + grn_id domain = GRN_ID_NIL; + grn_obj_flags flags = 0; + + if (!GRN_DB_OBJP(domain_obj) && domain_obj->header.type != GRN_ACCESSOR) { + grn_obj inspected; + GRN_TEXT_INIT(&inspected, 0); + limited_size_inspect(ctx, &inspected, domain_obj); + ERR(GRN_INVALID_ARGUMENT, + "[reinit] invalid domain object: <%.*s>", + (int)GRN_TEXT_LEN(&inspected), GRN_TEXT_VALUE(&inspected)); + GRN_OBJ_FIN(ctx, &inspected); + return ctx->rc; + } + + grn_obj_get_range_info(ctx, domain_obj, &domain, &flags); + return grn_obj_reinit(ctx, obj, domain, flags); +} + const char * grn_obj_path(grn_ctx *ctx, grn_obj *obj) { Modified: lib/db.h (+2 -0) =================================================================== --- lib/db.h 2012-10-19 00:30:48 +0900 (091a5a3) +++ lib/db.h 2012-10-19 00:31:54 +0900 (bb04df3) @@ -422,6 +422,8 @@ grn_id grn_obj_register(grn_ctx *ctx, grn_obj *db, const char *name, unsigned in int grn_obj_is_persistent(grn_ctx *ctx, grn_obj *obj); void grn_obj_spec_save(grn_ctx *ctx, grn_db_obj *obj); +grn_rc grn_obj_reinit_for(grn_ctx *ctx, grn_obj *obj, grn_obj *domain_obj); + #define GRN_UINT32_POP(obj,value) do {\ if (GRN_BULK_VSIZE(obj) >= sizeof(uint32_t)) {\ GRN_BULK_INCR_LEN((obj), -(sizeof(uint32_t)));\ Modified: lib/expr.c (+6 -2) =================================================================== --- lib/expr.c 2012-10-19 00:30:48 +0900 (0d7d96a) +++ lib/expr.c 2012-10-19 00:31:54 +0900 (e21e901) @@ -2687,6 +2687,7 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs) col = grn_obj_column(ctx, table, GRN_BULK_HEAD(col), GRN_BULK_VSIZE(col)); if (col) { GRN_PTR_PUT(ctx, &e->objs, col); } } + grn_obj_reinit_for(ctx, res, col); if (col) { value = grn_obj_get_value_(ctx, col, GRN_RECORD_VALUE(rec), &size); } else { @@ -2696,9 +2697,12 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs) if (size == GRN_OBJ_GET_VALUE_IMD) { GRN_RECORD_SET(ctx, res, (uintptr_t)value); } else { - grn_bulk_write_from(ctx, res, value, 0, size); + if (res->header.type == GRN_VECTOR) { + grn_vector_decode(ctx, res, value, size); + } else { + grn_bulk_write_from(ctx, res, value, 0, size); + } } - res->header.domain = grn_obj_get_range(ctx, col); code++; } while (code < ce && code->op == GRN_OP_GET_VALUE); } -------------- next part -------------- HTML����������������������������...Download