7.14.27. vector_size
¶
7.14.27.1. 概要¶
バージョン 5.0.3 で追加.
vector_size
はベクターカラムのサイズを返します。
この関数を有効にするには、以下のコマンドで functions/vector
プラグインを登録します:
plugin_register functions/vector
その後、 --command_version 2
オプションと一緒に vector_size
関数を使ってください。vector_size
を使うには --command_vesion 2
を指定しなければならないことに注意してください。
7.14.27.3. 使い方¶
使い方を示すために使うスキーマ定義とサンプルデータは以下の通りです。
サンプルスキーマ:
実行例:
table_create Memos TABLE_HASH_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Memos tags COLUMN_VECTOR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
サンプルデータ:
実行例:
load --table Memos
[
{"_key": "Groonga", "tags": ["Groonga"]},
{"_key": "Rroonga", "tags": ["Groonga", "Ruby"]},
{"_key": "Nothing"}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
vector_size
関数が tag
カラムの値とそのサイズを返す例です。
実行例:
select Memos --output_columns 'tags, vector_size(tags)' --command_version 2
# [
# [
# 0,
# 1337566253.89858,
# 0.000355720520019531
# ],
# [
# [
# [
# 3
# ],
# [
# [
# "tags",
# "ShortText"
# ],
# [
# "vector_size",
# "Object"
# ]
# ],
# [
# [
# "Groonga"
# ],
# 1
# ],
# [
# [
# "Groonga",
# "Ruby"
# ],
# 2
# ],
# [
# [],
# 0
# ]
# ]
# ]
# ]
7.14.27.4. 引数¶
必須引数が一つあり、それは target
です。
7.14.27.4.1. target
¶
select
対象の table
に指定されたテーブルのベクターカラムを指定します。
7.14.27.5. 戻り値¶
vector_size
は対象のベクターカラムのサイズを返します。