-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
column_copy: add support for weight vector #1379
Conversation
@kou Could you review this PR? |
lib/column.c
Outdated
GRN_BULK_REWIND(&validated_value); | ||
grn_obj_get_value(ctx, from_column, id, &value); | ||
grn_obj_get_value(ctx, from_column, id, &validated_value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If value
is valid value, it seems that value
and validated_value
expect into same value.
Therefore, I added a prepared process same as value
on validated_value
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validated_value
has duplicated values because grn_obj_get_value(ctx, &validated_value)
and grn_uvector_add_element_record()
adds the same value twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...
I see. I understand. Thank you for your comment.
lib/column.c
Outdated
grn_obj_get_value(ctx, from_column, id, &value); | ||
GRN_BULK_REWIND(&validated_value); | ||
grn_obj_get_value(ctx, from_column, id, &value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change the order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I thought it would be easier to read if the same processes were grouped together.
Does this work? diff --git a/lib/column.c b/lib/column.c
index 32555a119..0f23f8fe8 100644
--- a/lib/column.c
+++ b/lib/column.c
@@ -262,13 +262,15 @@ grn_column_copy_same_table(grn_ctx *ctx,
if (need_validate) {
grn_obj validated_value;
GRN_RECORD_INIT(&validated_value, to_range_flags, to_range_id);
+ if (to_range_flags & GRN_OBJ_WITH_WEIGHT) {
+ validated_value.header.flags |= GRN_OBJ_WITH_WEIGHT;
+ }
bool is_uvector = grn_obj_is_uvector(ctx, &validated_value);
grn_obj *range = grn_ctx_at(ctx, to_range_id);
GRN_TABLE_EACH_BEGIN(ctx, table, cursor, id) {
GRN_BULK_REWIND(&value);
- GRN_BULK_REWIND(&validated_value);
grn_obj_get_value(ctx, from_column, id, &value);
- grn_obj_get_value(ctx, from_column, id, &validated_value);
+ GRN_BULK_REWIND(&validated_value);
if (is_uvector) {
uint32_t n_elements = grn_uvector_size(ctx, &value);
uint32_t i; |
…s a WITH_WEIGHT flag
Thank you for your suggested code. |
Could you also add a test for only It seems that this is not related to |
Because this problem is not related to WEIGHT_FLOAT32. This is just only related to WITH_WEIGHT.
Thank you for your comment. I see. |
@@ -0,0 +1,19 @@ | |||
table_create Tags TABLE_HASH_KEY ShortText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename this file to weight_float32.test
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I fixed the file name at 7b1ab44.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. weight_float32.test
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh.
I fixed the file name again at 4da11d7.
I fixed the result of
column_copy
is incorrect against Float32 values as below.Problem:
Values of
destination_tags
column incorrect.Expected:
Values of
destination_tags
column same as values ofsource_tags
column as below.