Mercurial > hg > Papers > 2014 > nobuyasu-master
comparison paper/chapter3.tex @ 49:7b595f4b341e
modified chapter3.txt
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 31 Jan 2014 11:19:32 +0900 |
parents | 6553b7a3717c |
children | faa708c2958b |
comparison
equal
deleted
inserted
replaced
48:6553b7a3717c | 49:7b595f4b341e |
---|---|
250 | 250 |
251 基本的にこれらの実装は, フィールドを全てプリミティブなものだけにすればよい. | 251 基本的にこれらの実装は, フィールドを全てプリミティブなものだけにすればよい. |
252 MessagePackはListを扱うこともできるため, TreeOperationLogで継承されていたIterableの挙動もListを使うことで | 252 MessagePackはListを扱うこともできるため, TreeOperationLogで継承されていたIterableの挙動もListを使うことで |
253 実装を行うことができた. | 253 実装を行うことができた. |
254 | 254 |
255 | 255 \subsection{ログに対する情報の追加} |
256 このInterfaceをimplementsしつつシリアライズを行えるクラスとしてNetworkTreeOperationLogを実装した. | 256 TreeOperationLogをシリアライズ可能な形にした後, 問題が発生した. |
257 NetworkTreeOperationLogでは次のフィールドを保持する(\ref{src:nettreeoplog}). | 257 それは, TreeOperationLog事態は木の名前を保持していないというものである. |
258 \begin{lstlisting}[frame=lrbt,label=src:nettreeoplog,caption=NetworkTreeOperationLogの実装,numbers=left] | 258 そのため, TreeOperationLogだけを受け取っても, そのログがどの木に対して行われるのか |
259 @Message | 259 わからなかった. |
260 public class NetworkTreeOperationLog implements TreeOperationLog | 260 そこで, TreeOperationLogの情報だけでなく, 木の名前とUUID, それとtimestampの情報も付与 |
261 { | 261 してシリアライズが可能なNetworkTreeOperationLogの実装を行った. |
262 public LinkedList<NetworkTreeOperation> list; | 262 |
263 public int size; | 263 \subsection{NetworkTreeOperationLogの実装} |
264 String uuid; | 264 NetworkTreeOperationLogの実装の一部を以下に示す. |
265 String treeName; | |
266 long timestamp; | |
267 : // 実装が続いていく | |
268 \end{lstlisting} | |
269 | |
270 | |
271 | |
272 | |
273 TreeOperationLogの仕様はInterfaceにより定義される. | |
274 \begin{lstlisting}[frame=lrbt,label=src:treeoperationlog,caption=TreeOperationLogの仕様,numbers=left] | |
275 public interface TreeOperationLog extends Iterable<TreeOperation> | |
276 { | |
277 public TreeOperationLog add(NodePath _p,NodeOperation _op); | |
278 public TreeOperationLog append(TreeOperationLog _log); | |
279 public int length(); | |
280 } | |
281 \end{lstlisting} | |
282 \verb|Iterable<TreeOperationLog>|を継承しているクラスがTreeOperationLogとなる. | |
283 次にTreeOperationの仕様と, NodeOperation, NodePath の仕様について以下に示す | |
284 \begin{lstlisting}[frame=lrbt,label=src:treeop,caption=TreeOperationの仕様,numbers=left] | |
285 public interface TreeOperation | |
286 { | |
287 public NodePath getNodePath(); | |
288 public NodeOperation getNodeOperation(); | |
289 } | |
290 \end{lstlisting} | |
291 | |
292 \begin{lstlisting}[frame=lrbt,label=src:nodeop,caption=NodeOperationの仕様,numbers=left] | |
293 public interface NodeOperation | |
294 { | |
295 public Command getCommand(); | |
296 public <T extends EditableNode<T>> Either<Error,T> invoke(T _target); | |
297 | |
298 public int getPosition(); | |
299 public String getKey(); | |
300 public ByteBuffer getValue(); | |
301 } | |
302 \end{lstlisting} | |
303 | |
304 \begin{lstlisting}[frame=lrbt,label=src:nodepath,caption=Nodepathの仕様,numbers=left] | |
305 public interface NodePath extends Iterable<Integer> | |
306 { | |
307 public NodePath add(int _pos); | |
308 public Pair<Integer,NodePath> pop(); | |
309 public int size(); | |
310 } | |
311 \end{lstlisting} | |
312 | |
313 | |
314 | 265 |
315 | 266 |
316 | 267 |
317 | 268 |
318 | 269 |