Class: Groonga::Type
- Inherits:
-
GrnObject
- Object
- GrnObject
- Groonga::Type
- Defined in:
- ext/rb-grn-type.c,
ext/rb-grn-type.c
Overview
groongaのテーブルの主キーや、カラムの値の型のためのオブジェ クト。型として使用可能なものはgroongaで予め定義済みの型、ユ ーザが定義する型、またはユーザが定義したテーブル。
Constant Summary collapse
- OBJECT =
任意のテーブルに属する全てのレコード(Object型はv1.2で
サポートされます)。
INT2NUM(GRN_DB_OBJECT)
- BOOLEAN =
bool型。trueとfalse。
INT2NUM(GRN_DB_BOOL)
- BOOL =
bool型。trueとfalse。
INT2NUM(GRN_DB_BOOL)
- INT8 =
8bit符号付き整数。
INT2NUM(GRN_DB_INT8)
- UINT8 =
8bit符号なし整数。
INT2NUM(GRN_DB_UINT8)
- INT16 =
16bit符号付き整数。
INT2NUM(GRN_DB_INT16)
- UINT16 =
16bit符号なし整数。
INT2NUM(GRN_DB_UINT16)
- INT32 =
32bit符号付き整数。
INT2NUM(GRN_DB_INT32)
- UINT32 =
32bit符号なし整数。
INT2NUM(GRN_DB_UINT32)
- INT64 =
64bit符号付き整数。
INT2NUM(GRN_DB_INT64)
- UINT64 =
64bit符号なし整数。
INT2NUM(GRN_DB_UINT64)
- FLOAT =
ieee754形式の64bit浮動小数点数。
INT2NUM(GRN_DB_FLOAT)
- TIME =
1970年1月1日0時0分0秒からの経過マイクロ秒数を64bit符
号付き整数で表現した値。
INT2NUM(GRN_DB_TIME)
- SHORT_TEXT =
4Kbyte以下の文字列。
INT2NUM(GRN_DB_SHORT_TEXT)
- TEXT =
64Kbyte以下の文字列。
INT2NUM(GRN_DB_TEXT)
- LONG_TEXT =
2Gbyte以下の文字列。
INT2NUM(GRN_DB_LONG_TEXT)
- DELIMIT =
INT2NUM(GRN_DB_DELIMIT)
- UNIGRAM =
INT2NUM(GRN_DB_UNIGRAM)
- BIGRAM =
INT2NUM(GRN_DB_BIGRAM)
- TRIGRAM =
INT2NUM(GRN_DB_TRIGRAM)
- MECAB =
INT2NUM(GRN_DB_MECAB)
Instance Method Summary collapse
-
#Groonga::Type.new(name, options = {}) ⇒ Object
constructor
名前がnameの型を作成する。optionsに指定可能な値は以下の通 り。.
Constructor Details
#Groonga::Type.new(name, options = {}) ⇒ Object
名前がnameの型を作成する。optionsに指定可能な値は以下の通 り。
:type
-
:integer(符号付き整数)、:int(:integerの省略 形)、:unsigned_integer(符号なし整 数)、:uint(:unsigned_integerの省略形)、:float(浮動小 数点数)、:variable(可変長文字列)のいずれかを指定する。 省略した場合は:variableを指定したものと扱う。
:variableを指定した場合は必ず
:size
を指定しなければいけない。 :context
-
型の作成時に利用するGroonga::Contextを指定する。省略すると Groonga::Context.defaultを用いる。
:size
-
:option
が:variableの場合は最大長、それ以外の場合は長さを 指定する(単位:byte)。
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'ext/rb-grn-type.c', line 75
static VALUE
rb_grn_type_initialize (int argc, VALUE *argv, VALUE self)
{
grn_ctx *context;
grn_obj *type;
const char *name = NULL;
unsigned name_size, size = 0;
grn_obj_flags flags = 0;
VALUE rb_name, options, rb_context, rb_type, rb_size;
rb_scan_args(argc, argv, "11", &rb_name, &options);
rb_grn_scan_options(options,
"context", &rb_context,
"type", &rb_type,
"size", &rb_size,
NULL);
name = StringValuePtr(rb_name);
name_size = RSTRING_LEN(rb_name);
context = rb_grn_context_ensure(&rb_context);
if (NIL_P(rb_type) ||
rb_grn_equal_option(rb_type, "variable")) {
flags = GRN_OBJ_KEY_VAR_SIZE;
} else if (rb_grn_equal_option(rb_type, "integer") ||
rb_grn_equal_option(rb_type, "int")) {
flags = GRN_OBJ_KEY_INT;
size = sizeof(int);
} else if (rb_grn_equal_option(rb_type, "unsigned_integer") ||
rb_grn_equal_option(rb_type, "uint")) {
flags = GRN_OBJ_KEY_UINT;
size = sizeof(unsigned int);
} else if (rb_grn_equal_option(rb_type, "float")) {
flags = GRN_OBJ_KEY_FLOAT;
size = sizeof(double);
} else {
rb_raise(rb_eArgError,
":type should be one of "
"[:integer, :int, :unsigned_integer, :uint, "
":float, :variable]: %s",
rb_grn_inspect(options));
}
if (NIL_P(rb_size)) {
if (size == 0)
rb_raise(rb_eArgError, "size is missing: %s",
rb_grn_inspect(options));
} else {
size = NUM2UINT(rb_size);
}
type = grn_type_create(context, name, name_size, flags, size);
rb_grn_object_assign(Qnil, self, rb_context, context, type);
rb_grn_context_check(context, rb_ary_new4(argc, argv));
return Qnil;
}
|