annotate midterm.tex @ 7:ab8f0312b171

Build complete but mistake image place
author Kazuma
date Thu, 20 Oct 2016 22:51:34 +0900
parents dd95a76fba0c
children 4c9d4ecb17e6
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}
6
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
2 \usepackage[dvips]{graphicx}
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
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
27 \thispagestyle{fancy}
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
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
31 当研究室ではデータの変更の際に過去の木構造を保存しつつ新しく木構造を作成する非破壊的木構造を用いたデータベースであるJungleを開発している。
5
Kazuma
parents: 3
diff changeset
32 本研究ではJungle DBをC\#で再実装を行い、Unity向けに組み込みを行う。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
33
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
34 Jugnleの木は、子供を複数持つノードからなる。子供は順序付けられており、任意の位置で作成削除することができる。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
35
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
36 Unityは3Dゲームエンジンである。
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
37 ゲーム構造はシーングラフを実装しており、ゲームオブジェクトの親子関係からなり、子どもを複数もつノードからなる。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
38 Jungleはこれと同じ構造を持っているため、相性が良い。
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
39
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
40 % ので、過去の組織のデータを参照する必要が出てくる。よって過去のデータの参照が出来るJungleと相性が良い。
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
41 % これらは、XMLで記述されており、
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
42 % maTrixが保持している人、役職、役割等のデータはお互いに参照している。
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
43 % ポリシーファイルは、組織の中で申請等を行った際に、どの権限によってその申請が許諾されるのかを指定している。
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
44 % 組織のデータ、ポリシーファイル共に木構造のデータであるため、Jungleにそのまま格納できる。
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
45
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
46 \section{Unityでの問題点}
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
47
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
48 Unityではデータの保存の際にMySQL、SQlite3、PlayerPrefsといった第一正規系、第二正規系のDBがよく使われている。
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
49 しかし、図1のように木構造でゲームは構成されているため、RDB向けにノードの関係を変換する必要がある。
5
Kazuma
parents: 3
diff changeset
50 つまり、そのまま格納することができればスケールアウトするデータにも対応でき、データベース設計も簡略化できると考え、C\#に書き直すことにした。
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
51
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
52 PlayerPrefsとは、Unityに特化したバイナリ形式でKey,Valueで保存されるものである。
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
53
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
54 \section{Jungle-Sharpの実装}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
55
5
Kazuma
parents: 3
diff changeset
56 JungleはJavaで書かれているものであったのでUnityで使うにはC\#で実装する必要があった。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
57
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
58 \section{AtomicRefefarenceの実装}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
59 % atomic reference問題
5
Kazuma
parents: 3
diff changeset
60 JavaにはAtomicRefarenceが標準であったがC\#はなかったため、AtomicReferenceのClassを新たに作った。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
61
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
62 {\scriptsize
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
63 \begin{itembox}[l]{図1 AtomicReference.cs}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
64 \begin{verbatim}
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
65 public class AtomicReference <T> where T : class {
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
66 private T value;
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
67
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
68 public AtomicReference(T value) {
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
69 this.value = value;
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
70 }
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
71
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
72 public bool CompareAndSet(T newValue, T prevValue) {
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
73 T oldValue = value;
6
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
74 return (oldValue
dd95a76fba0c add templete
Kazuma
parents: 5
diff changeset
75 != Interlocked.CompareExchange (ref value, newValue, prevValue));
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
76 }
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
77
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
78 public T Get() {
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
79 return value;
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
80 }
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
81 }
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
82 \end{verbatim}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
83 \end{itembox}
5
Kazuma
parents: 3
diff changeset
84 }
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
85
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
86 CompereAndSetメソッドではInterlocked Operationを利用した。
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
87 これによりスレッドセーフな値の変更を行うことが可能になる。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
88
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
89 \section{Listの実装}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
90
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
91 Listを実装する際にIteratorが必要となる。
5
Kazuma
parents: 3
diff changeset
92 C\#にはIEnumeratorがあるのでそれを利用した。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
93
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
94 {\scriptsize
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
95 \begin{itembox}[l]{図2 List.cs}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
96 \begin{verbatim}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
97 public IEnumerator<T> iterator() {
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
98 Node<T> currentNode = head.getNext();
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
99 while (currentNode.getAttribute() != null) {
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
100 yield return (T)currentNode.getAttribute();
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
101 currentNode = currentNode.getNext ();
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
102 }
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
103 }
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
104 \end{verbatim}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
105 \end{itembox}
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
106 }
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
107
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
108 ListのforeachではIteratorを呼び出すため、一つずつ要素を返す必要がある。
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
109 yield returnステートメントを利用することで位置が保持され次に呼ばれた際に続きから値の取り出しが可能になる。
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
110 \newpage
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
111 \section{ベンチマーク}
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
112
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
113 UnityではSqlite3,PlayerPrefsがデータの保存として利用される。
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
114 今回の検証はInsertを1000回行い、push(またはSave)を行うまでの時間を測定する。
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
115
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
116 使用した機材は以下の通りである。
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
117
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
118 \begin{itemize}
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
119 \item OS : Windows 10
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
120 \item CPU : Intel Core i7-4700MQ 2.4GHz
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
121 \item Unity : Unity 5.4.2f1
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
122 \end{itemize}
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
123
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
124 \begin{figure}[h]
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
125 \includegraphics[width=1cm, bb=0 0 160 200]{pic/benchmark.pdf}
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
126 \end{figure}
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
127
3
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
128 Sqlite3では100msを超えてしまったため省略してある。
7b3bab2431d4 add benchmark.pdf
Kazuma
parents: 2
diff changeset
129 図3の結果よりJungleDBの速度を確認することができた。
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
130
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
131 \section{これからの作業}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
132
2
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
133 Jungleは分散型のデータベースを目指しているため、MessagePackの実装を行う。
cde61c2d9cdc add section and add Bench Mark.
Kazuma
parents: 1
diff changeset
134 今後はサーバーとの連携も行う。
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
135 JungleはRDBと異なりデータを自由に格納することができる。
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
136 そこでデータベース設計を確立させる必要がある。
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
137
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
138 \begin{thebibliography}{9}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
139
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
140 \bibitem{1}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
141 玉城将士 非破壊的木構造を用いた分散CMSの設計と実装
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
142 \bibitem{2}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
143 大城信康 分散Database Jungleに関する研究
1
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
144 \bibitem{3}
93d15a2b6745 add section 'Jungle-Sharp implementation' and c# code.
Kazuma
parents: 0
diff changeset
145 金川竜己 非破壊的木構造データベースJungleとその評価
0
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
146 \end{thebibliography}
7008af359a96 firsr commit
Kazuma
parents:
diff changeset
147
7
ab8f0312b171 Build complete but mistake image place
Kazuma
parents: 6
diff changeset
148 \end{document}