annotate midterm.tex @ 13:03e97e769bb0

fix
author Kazuma
date Fri, 21 Oct 2016 22:32:20 +0900
parents 202092f0f309
children 87907fc91f62
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
1 \documentclass[twocolumn,twoside,9.5pt]{jarticle}
9
600fe9e28aed Change midterm.tex, resize pdf
Kazuma
parents: 8
diff changeset
2 \usepackage[dvipdfmx]{graphicx}
6
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
3 \usepackage{picins}
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
4 \usepackage{ascmac}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
5 \usepackage{fancyhdr}
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
6 \usepackage{here}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
7 %\pagestyle{fancy}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
8 \lhead{\parpic{\includegraphics[height=1zw,keepaspectratio,bb=0 0 251 246]{pic/emblem-bitmap.pdf}}琉球大学主催 工学部情報工学科 中間発表予稿}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
9 \rhead{}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
10 \cfoot{}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
11
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
12 \setlength{\topmargin}{-1in \addtolength{\topmargin}{15mm}}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
13 \setlength{\headheight}{0mm}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
14 \setlength{\headsep}{5mm}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
15 \setlength{\oddsidemargin}{-1in \addtolength{\oddsidemargin}{11mm}}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
16 \setlength{\evensidemargin}{-1in \addtolength{\evensidemargin}{21mm}}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
17 \setlength{\textwidth}{181mm}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
18 \setlength{\textheight}{261mm}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
19 \setlength{\footskip}{0mm}
5
Kazuma
parents: 3
diff changeset
20 \pagestyle{empty}
6
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
21
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
22 \begin{document}
6
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
23 \title{UnityにおけるJungleDBの有用性}
5
Kazuma
parents: 3
diff changeset
24 \author{135768K 武田和馬 {}{} 指導教員 : 河野真治}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
25 \date{}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
26 \maketitle
8
4c9d4ecb17e6 add cas.pdf
Kazuma
parents: 7
diff changeset
27 \thispagestyle{fancy}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
28
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
29 \section{非破壊木構造データベース}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
30
13
Kazuma
parents: 12
diff changeset
31 当研究室ではデータの変更の際に過去の木構造を保存する非破壊木構造データベースであるJungleを開発している\cite{1}。
9
600fe9e28aed Change midterm.tex, resize pdf
Kazuma
parents: 8
diff changeset
32
13
Kazuma
parents: 12
diff changeset
33 本研究ではJungleをUnityを用いたネットワークゲームで使用する方法を提案する。
Kazuma
parents: 12
diff changeset
34 データベースとしてJungle DBをC\#で再実装を行い、Unity向けに組み込みを行う。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
35
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
36 Jugnleの木は、子供を複数持つノードからなる。子供は順序付けられており、任意の位置で作成削除することができる。
13
Kazuma
parents: 12
diff changeset
37 ノードは属性名と属性値の組からなる表を持つ。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
38
13
Kazuma
parents: 12
diff changeset
39 \section{UnityでのDBの取り扱い}
Kazuma
parents: 12
diff changeset
40
Kazuma
parents: 12
diff changeset
41 Unityは3Dゲームエンジンで、ゲームを構成する要素(Object)をC\#で制御する。
Kazuma
parents: 12
diff changeset
42 Objectは一つのゲームのシーン(一画面の状況)の中で木構造を持つ。
Kazuma
parents: 12
diff changeset
43 これをシーングラフと言う。
Kazuma
parents: 12
diff changeset
44 シーングラフをそのままJungleに格納するという手法が考えられる。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
45
13
Kazuma
parents: 12
diff changeset
46 JungleはJavaで書かれていたので、Unityで使うにはJungleをC\#で実装する必要がある。
Kazuma
parents: 12
diff changeset
47 クライアント側はC\#、サーバー側はJavaで動作するJungleを用いる。
Kazuma
parents: 12
diff changeset
48 Jungleの分散機構を用いてネットワークゲームに必要な通信を行う。
Kazuma
parents: 12
diff changeset
49 通信はMessagePackを基本に実装されている。
Kazuma
parents: 12
diff changeset
50 従って、C\#側でもMessagePackを用いてデータのやり取りを行いたい。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
51
13
Kazuma
parents: 12
diff changeset
52 Unityではデータの保存の際にSQlite3、PlayerPrefsといったDBがよく使われている。
8
4c9d4ecb17e6 add cas.pdf
Kazuma
parents: 7
diff changeset
53 PlayerPrefsとは、Unityに特化したバイナリ形式でKey,Valueのみで保存されるものである。
13
Kazuma
parents: 12
diff changeset
54 これらのDBにはObjectを直接格納することはできない。
Kazuma
parents: 12
diff changeset
55 また、セーブ機能に特化していてメモリ上にDBを展開するものではない。
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
56
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
57 \section{Jungle-Sharpの実装}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
58
13
Kazuma
parents: 12
diff changeset
59 %スムーズにできた部分を書く
Kazuma
parents: 12
diff changeset
60 %Jungleがプログラミング言語に依存しないものだというのをかくほうがいい
Kazuma
parents: 12
diff changeset
61 JavaとC\#はよく似た言語であり、移行はそれほど難しくはない。
Kazuma
parents: 12
diff changeset
62 実際Jungleの中心部分である木構造とIndexを構成する赤黒木\cite{}のコードはほぼ変更なく移行できた。
Kazuma
parents: 12
diff changeset
63 C\#ではインナークラスが使えないので明示的なクラスに変換する必要があった。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
64
13
Kazuma
parents: 12
diff changeset
65 異なる部分は一つは木を変更した後、木のルートをAtomicに置き部分である。
Kazuma
parents: 12
diff changeset
66 もう一つは木をたどる時に使うItertorである。
Kazuma
parents: 12
diff changeset
67
Kazuma
parents: 12
diff changeset
68 %\section{AtomicRefefarenceの実装}
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
69 % atomic reference問題
8
4c9d4ecb17e6 add cas.pdf
Kazuma
parents: 7
diff changeset
70 Jungleの木の更新(commit)は、CAS(check and set*図1)を用いて atomic に行われる。競合している書き込みにの中で自分の書き込みが成功した場合に関数 \verb+success()+が成功する。
12
Kazuma
parents: 11
diff changeset
71 JavaにはAtomicRefarenceが標準であるがC\#はなかったため、AtomicReferenceのClassを新たに作った。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
72
13
Kazuma
parents: 12
diff changeset
73 \begin{itembox}[l]{AtomicReplace}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
74 \begin{verbatim}
13
Kazuma
parents: 12
diff changeset
75 // C#
Kazuma
parents: 12
diff changeset
76 public bool CompareAndSet(T newValue, T prevValue) {
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
77 T oldValue = value;
6
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
78 return (oldValue
12
Kazuma
parents: 11
diff changeset
79 != Interlocked.CompareExchange (ref value, newValue, prevValue));
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
80 }
13
Kazuma
parents: 12
diff changeset
81
Kazuma
parents: 12
diff changeset
82 // Java
Kazuma
parents: 12
diff changeset
83
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
84 \end{verbatim}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
85 \end{itembox}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
86
13
Kazuma
parents: 12
diff changeset
87 %\section{Listの実装}
Kazuma
parents: 12
diff changeset
88 木やリストをたどる時にJavaではIteratorを用いる。
Kazuma
parents: 12
diff changeset
89 Iteratorは次の値があるかを返すboolean hasNext()と、Tという型の次の値を取ってくるT next()を持つObjectである。
Kazuma
parents: 12
diff changeset
90 C\#では木やリストをたどりながらyeildで次の値を返す。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
91
12
Kazuma
parents: 11
diff changeset
92 \begin{itembox}[l]{ソースコード2 List.java}
Kazuma
parents: 11
diff changeset
93 \begin{verbatim}
Kazuma
parents: 11
diff changeset
94 public Iterator<T> iterator() {
Kazuma
parents: 11
diff changeset
95 return new Iterator<T>() {
Kazuma
parents: 11
diff changeset
96 Node<T> currentNode = head.getNext();
Kazuma
parents: 11
diff changeset
97
Kazuma
parents: 11
diff changeset
98 @Override
Kazuma
parents: 11
diff changeset
99 public boolean hasNext() {
Kazuma
parents: 11
diff changeset
100 return currentNode.getAttribute()
Kazuma
parents: 11
diff changeset
101 != null;
Kazuma
parents: 11
diff changeset
102 }
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
103
12
Kazuma
parents: 11
diff changeset
104 @Override
Kazuma
parents: 11
diff changeset
105 public T next() {
Kazuma
parents: 11
diff changeset
106 T attribute
Kazuma
parents: 11
diff changeset
107 = currentNode.getAttribute();
Kazuma
parents: 11
diff changeset
108 currentNode
Kazuma
parents: 11
diff changeset
109 = currentNode.getNext();
Kazuma
parents: 11
diff changeset
110 return attribute;
Kazuma
parents: 11
diff changeset
111 }
Kazuma
parents: 11
diff changeset
112 };
Kazuma
parents: 11
diff changeset
113 }
Kazuma
parents: 11
diff changeset
114 \end{verbatim}
Kazuma
parents: 11
diff changeset
115 \end{itembox}
Kazuma
parents: 11
diff changeset
116
Kazuma
parents: 11
diff changeset
117 C\#にはIEnumeratorがあるのでそれを利用した。
Kazuma
parents: 11
diff changeset
118 ListのforeachではIteratorを呼び出すため、一つずつ要素を返す必要がある。
Kazuma
parents: 11
diff changeset
119 yield returnステートメントを利用することで位置が保持され、次に呼ばれた際に続きから値の取り出しが可能になる。
Kazuma
parents: 11
diff changeset
120
Kazuma
parents: 11
diff changeset
121 \begin{itembox}[l]{ソースコード3 List.cs}
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
122 \begin{verbatim}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
123 public IEnumerator<T> iterator() {
12
Kazuma
parents: 11
diff changeset
124 Node<T> currentNode = head.getNext();
Kazuma
parents: 11
diff changeset
125 while (currentNode.getAttribute() != null) {
Kazuma
parents: 11
diff changeset
126 yield return (T)currentNode.getAttribute();
Kazuma
parents: 11
diff changeset
127 currentNode = currentNode.getNext ();
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
128 }
12
Kazuma
parents: 11
diff changeset
129 }
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
130 \end{verbatim}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
131 \end{itembox}
9
600fe9e28aed Change midterm.tex, resize pdf
Kazuma
parents: 8
diff changeset
132
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
133 \section{ベンチマーク}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
134
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
135 UnityではSqlite3,PlayerPrefsがデータの保存として利用される。
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
136 今回の検証はInsertを1000回行い、push(またはSave)を行うまでの時間を測定する。
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
137
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
138 使用した機材は以下の通りである。
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
139
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
140 \begin{itemize}
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
141 \item OS : Windows 10
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
142 \item CPU : Intel Core i7-4700MQ 2.4GHz
12
Kazuma
parents: 11
diff changeset
143 \item Unity : 5.4.2f1
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
144 \end{itemize}
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
145
11
95eca1bbcf2e Change tex
Kazuma
parents: 9
diff changeset
146 %\begin{figure}[htbp]
95eca1bbcf2e Change tex
Kazuma
parents: 9
diff changeset
147 % \includegraphics[width=70mm]{pic/benchmark.pdf}
95eca1bbcf2e Change tex
Kazuma
parents: 9
diff changeset
148 %\end{figure}
12
Kazuma
parents: 11
diff changeset
149 \begin{table}[htbp]
Kazuma
parents: 11
diff changeset
150 \caption{速度測定}
Kazuma
parents: 11
diff changeset
151 \label{table:data_type}
Kazuma
parents: 11
diff changeset
152 \begin{tabular}{lcrr} \hline
Kazuma
parents: 11
diff changeset
153 データベース & 速度(ms) \\ \hline \hline
Kazuma
parents: 11
diff changeset
154 Jungle & 100 \\
Kazuma
parents: 11
diff changeset
155 Sqlite3 & 100 \\
Kazuma
parents: 11
diff changeset
156 PlayerPrefs & 100 \\
11
95eca1bbcf2e Change tex
Kazuma
parents: 9
diff changeset
157 \end{tabular}
95eca1bbcf2e Change tex
Kazuma
parents: 9
diff changeset
158 \end{table}
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
159
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
160
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
161 \section{これからの作業}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
162
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
163 Jungleは分散型のデータベースを目指しているため、MessagePackの実装を行う。
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
164 今後はサーバーとの連携も行う。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
165 JungleはRDBと異なりデータを自由に格納することができる。
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
166 そこでデータベース設計を確立させる必要がある。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
167
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
168 \begin{thebibliography}{9}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
169
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
170 \bibitem{1}
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
171 金川竜己 非破壊的木構造データベースJungleとその評価
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
172 \end{thebibliography}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
173
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
174 \end{document}