forked from jubatus/jubatus.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.html
More file actions
237 lines (213 loc) · 10.4 KB
/
plugin.html
File metadata and controls
237 lines (213 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Plugin Develpment — Jubatus 0.1.0 documentation</title>
<link rel="stylesheet" href="_static/jubatus.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var GuideSentence = 'keyword';
function ShowFormGuide(obj) {
if( obj.value == '' ) {
obj.value = GuideSentence;
obj.style.color = '#cccccc';
}else{
obj.style.color = '#333333';
}
}
function HideFormGuide(obj) {
obj.style.color = '#827046';
if( obj.value == GuideSentence ) {
obj.value='';
}
}
</script>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.1.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="top" title="Jubatus 0.1.0 documentation" href="index.html" />
<link rel="up" title="References" href="references.html" />
<link rel="prev" title="Data Conversion" href="fv_convert.html" />
<!--
_________ ___
\____ _| | / ___I_I___
| | | | \__^ ^__/ ____
| | | | ___ ___ __ | | / __/
| | |-| |-|| |/ \ / \| | | | |^| |^|| (__
| | | | | || ^ || ^ | | | | | | | \__ \
| | | \_/ || O || O | | |_| \_/ | ___) |
| | \__/|_||_|\___/ \___/|_| |__/ \__/|_| \___/
| /
/ /
|/
-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26408953-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="fv_convert.html" title="Data Conversion"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Jubatus 0.1.0 documentation</a> »</li>
<li><a href="references.html" accesskey="U">References</a> »</li>
</ul>
</div>
<a href="index.html">
<div class="title"></div>
</a>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Plugin Develpment</a><ul>
<li><a class="reference internal" href="#plugin-for-data-conversion">plugin for data conversion</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="fv_convert.html"
title="previous chapter">Data Conversion</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/plugin.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" size="18" class="keyword" value="keyword" onFocus="HideFormGuide(this);" onBlur="ShowFormGuide(this);" />
<input type="submit" value="Go" class="searchBtn" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 4,
interval: 30000,
width: 220,
height: 300,
theme: {
shell: {
background: '#333333',
color: '#ffffff'
},
tweets: {
background: '#000000',
color: '#ffffff',
links: '#4aed05'
}
},
features: {
scrollbar: false,
loop: false,
live: false,
behavior: 'all'
}
}).render().setUser('JubatusOfficial').start();
</script>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="plugin-develpment">
<h1>Plugin Develpment<a class="headerlink" href="#plugin-develpment" title="Permalink to this headline">¶</a></h1>
<p id="plugin">Jubatusはユーザーがプラグインを開発することで、様々な拡張ができるようになっている。
特に、データ変換エンジンではユーザーが任意の変換ロジックを組み込めるように、各モジュール用のプラグインを作ることができる。
プラグインはC++を利用して作成する。
このページでは、プラグイン開発の方法を説明する。</p>
<div class="section" id="plugin-for-data-conversion">
<h2>plugin for data conversion<a class="headerlink" href="#plugin-for-data-conversion" title="Permalink to this headline">¶</a></h2>
<p>大まかなプラグインの開発方法は以下のとおりである。
まず、/usr/local/include/jubatus/plugin.hppをインクルードするところから始まる。
次に、プラグインの雛形となるクラスを継承し、任意の特徴抽出モジュール、フィルターモジュールを作成する。
最後に、これを外から見えるように、extern “C”で囲った領域に、インスタンス生成の関数を作成する。
この関数の中で、先ほど作成した自前クラスをnewで生成し、そのポインタを返すようにする。
最後に作った関数の名前が、プラグインを利用するときに指定する”function”引数の中身である。</p>
<p>例としてstring_types用のプラグインの作り方を示す。
この場合、ひな形はjubatus::word_splitterクラスである。
word_splitterクラスは文字列を受け取って、文字列を分割したあとの分割点を返すsplitというメンバ関数のみからなる。
以下に例を示す。</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <jubatus/plugin.hpp></span>
<span class="cp">#include <map></span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span>
<span class="k">class</span> <span class="nc">my_splitter</span> <span class="o">:</span> <span class="k">public</span> <span class="n">jubatus</span><span class="o">::</span><span class="n">word_splitter</span> <span class="p">{</span>
<span class="k">public</span><span class="o">:</span>
<span class="kt">void</span> <span class="n">split</span><span class="p">(</span><span class="k">const</span> <span class="n">string</span><span class="o">&</span> <span class="n">string</span><span class="p">,</span>
<span class="n">vector</span><span class="o"><</span><span class="n">pair</span><span class="o"><</span><span class="n">size_t</span><span class="p">,</span> <span class="n">size_t</span><span class="o">></span> <span class="o">>&</span> <span class="n">ret_boundaries</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// do somehting</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="k">extern</span> <span class="s">"C"</span> <span class="p">{</span>
<span class="n">my_splitter</span><span class="o">*</span> <span class="n">create</span><span class="p">(</span><span class="k">const</span> <span class="n">map</span><span class="o"><</span><span class="n">string</span><span class="p">,</span> <span class="n">string</span><span class="o">>&</span> <span class="n">params</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">new</span> <span class="n">my_splitter</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>上記のファイルをコンパイルし、libjubaconverter.soとリンクすると.soファイルが完成する。
できた.soファイルは、プラグインとして利用できる。
プラグインとして利用する方法は、 <a class="reference internal" href="fv_convert.html#conversion"><em>Data Conversion</em></a> <a class="reference internal" href="fv_convert.html#conversion-plugin"><em>plugin</em></a> を参照のこと。</p>
<p>その他の特徴抽出器やフィルターのプラグインも、同様の方法で作成することができる。
より具体的なソースに関しては、src/server/fv_converter中のtest_*.cppを参照して、同様の方法でプラグインを作成できる。
それぞれが各モジュールプラグインのサンプルになっている。</p>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="fv_convert.html" title="Data Conversion"
>previous</a> |</li>
<li><a href="index.html">Jubatus 0.1.0 documentation</a> »</li>
<li><a href="references.html" >References</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2011, PFI&NTT.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.
</div>
</body>
</html>