ext/groonga/rb-grn-column.c in rroonga-12.0.0 vs ext/groonga/rb-grn-column.c in rroonga-12.0.2

- old
+ new

@@ -1,9 +1,9 @@ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* vim: set sts=4 sw=4 ts=8 noet: */ /* - Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com> + Copyright (C) 2009-2022 Sutou Kouhei <kou@clear-code.com> Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. @@ -712,11 +712,11 @@ return CBOOL2RVAL(grn_obj_is_data_column(context, column)); } /* * @overload with_weight? - * @return [Boolean] @true@ if the column is vector and created with + * @return [Boolean] @true@ if the column is created with * @:with_weight => true@ flag, @false@ otherwise. * @since 4.0.1 */ static VALUE rb_grn_column_with_weight_p(VALUE self) @@ -732,10 +732,30 @@ flags = grn_column_get_flags(context, column); return CBOOL2RVAL(flags & GRN_OBJ_WITH_WEIGHT); } /* + * @overload weight_float32? + * @return [Boolean] @true@ if the column uses 32 bit float for weight. + * @since 12.0.2 + */ +static VALUE +rb_grn_column_weight_float32_p(VALUE self) +{ + grn_obj *column; + grn_ctx *context; + grn_column_flags flags; + + rb_grn_column_deconstruct(SELF(self), &column, &context, + NULL, NULL, + NULL, NULL, NULL); + + flags = grn_column_get_flags(context, column); + return CBOOL2RVAL(flags & GRN_OBJ_WEIGHT_FLOAT32); +} + +/* * Return indexes on `column`. If operator is specified, indexes that * can executes the operator are only returned. Otherwise, all indexes * are returned. * * Index means that index column and section. @@ -865,9 +885,11 @@ rb_define_method(rb_cGrnColumn, "scalar?", rb_grn_column_scalar_p, 0); rb_define_method(rb_cGrnColumn, "data?", rb_grn_column_data_p, 0); rb_define_method(rb_cGrnColumn, "with_weight?", rb_grn_column_with_weight_p, 0); + rb_define_method(rb_cGrnColumn, "weight_float32?", + rb_grn_column_weight_float32_p, 0); rb_define_method(rb_cGrnColumn, "find_indexes", rb_grn_column_find_indexes, -1); rb_define_method(rb_cGrnColumn, "rename", rb_grn_column_rename, 1);