More Related Content
PDF
PDF
PPT
PDF
PDF
Groonga Meetup 2014/04/29 PDF
PDF
Best Bugs 2017 in the SmartNews iOS app PPTX
More from firewood
PPTX
PPTX
PPTX
PPT
PPT
PPT
PPT
PPT
Recently uploaded
PDF
Machine Tests Benchmark Suite. Explain github.com/alexziskind1/machine_tests #2 PDF
エンジニアが選ぶべきAIエディタ & Antigravity 活用例@ウェビナー「触ってみてどうだった?Google Antigravity 既存IDEと... PDF
Machine Tests Benchmark Suite. Explain github.com/alexziskind1/machine_tests #1 PDF
20251210_MultiDevinForEnterprise on Devin 1st Anniv Meetup PPTX
楽々ナレッジベース「楽ナレ」3種比較 - Dify / AWS S3 Vector / Google File Search Tool PDF
流行りに乗っかるClaris FileMaker 〜AI関連機能の紹介〜 by 合同会社イボルブ 三日で書くGroonga関数
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
とりあえず版 関数 proc.c
staticgrn_obj *func_distinct(grn_ctx *ctx, int nargs, grn_obj
**args, grn_user_data *user_data) {
int result = 0;
grn_obj *obj;
if (nargs == 1) {
grn_obj *item_key = args[0];
result = _distinct(GRN_TEXT_VALUE(item_key),
GRN_TEXT_LEN(item_key));
if ((obj = GRN_PROC_ALLOC(GRN_DB_UINT32, 0))) {
GRN_UINT32_SET(ctx, obj, result);
}
}
return obj;
}
- 11.
とりあえず版 中身 distinct.cc
#include<string>
#include <set>
typedef std::set<std::string> Map;
static Map _map; // 格納済キーの保存庫
extern "C" int _distinct(const char *name, size_t length) {
std::string _key(name, length); // std::string に変換
Map::iterator it = _map.find(_key); // キーを探す
if (it != _map.end()) return 0; // 格納済なら 0 を返す
_map.insert(key); // 格納する
return 1;
}
- 12.
適当にビルドしてみる
lib/ にdistinct.cc を追加して make
よくわからないエラー
../lib/.libs/libgroonga.so: undefined
reference to `__cxa_begin_catch‘
g++ 経由でリンクしないと駄目
- 13.
正式なやり方
configure.ac にAC_PROG_CXX を追加
lib/Makefile.am の
libgroonga_la_SOURCES に distinct.cc
を追加
autoreconf で configure を再生成
- 14.
- 15.
- 16.
デモ
商品テーブル item
ShortText 型 description
3 件
在庫テーブル stock
item 型 i
Time 型 date
Int32 型 price
9 件
- 17.
- 18.
distinct あり
select--table stock --filter
"distinct(i._key)" --output_columns
i._key,price
→ i._key が重複しない
- 19.