バージョン 5.0.3 で追加.
vector_size はベクターカラムのサイズを返します。
この関数を有効にするには、以下のコマンドで functions/vector プラグインを登録します:
plugin_register functions/vector
その後、 --command_version 2 オプションと一緒に vector_size 関数を使ってください。vector_size を使うには --command_vesion 2 を指定しなければならないことに注意してください。
使い方を示すために使うスキーマ定義とサンプルデータは以下の通りです。
サンプルスキーマ:
実行例:
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
# ]
# ]
# ]
# ]
必須引数が一つあり、それは target です。
select 対象の table に指定されたテーブルのベクターカラムを指定します。
vector_size は対象のベクターカラムのサイズを返します。