annotate midterm_old.tex @ 8:4c9d4ecb17e6

add cas.pdf
author Kazuma
date Fri, 21 Oct 2016 16:57:49 +0900
parents dd95a76fba0c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
1 \documentclass[twocolumn,twoside,9.5pt]{jarticle}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
2 \usepackage[dvipdfmx]{graphicx}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
3 \usepackage{ascmac}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
4 \usepackage{fancyhdr}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
5 %\pagestyle{fancy}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
6 \lhead{\parpic{\includegraphics[height=1zw,keepaspectratio,bb=0 0 251 246]{pic/emblem-bitmap.pdf}}琉球大学主催 工学部情報工学科 中間発表予稿}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
7 \rhead{}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
8 \cfoot{}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
9
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
10 \setlength{\topmargin}{-1in \addtolength{\topmargin}{15mm}}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
11 \setlength{\headheight}{0mm}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
12 \setlength{\headsep}{5mm}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
13 \setlength{\oddsidemargin}{-1in \addtolength{\oddsidemargin}{11mm}}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
14 \setlength{\evensidemargin}{-1in \addtolength{\evensidemargin}{21mm}}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
15 \setlength{\textwidth}{181mm}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
16 \setlength{\textheight}{261mm}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
17 \setlength{\footskip}{0mm}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
18 \pagestyle{empty}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
19 \input{dummy.tex}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
20 \begin{document}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
21 \title{Database Jungleに関する研究}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
22 \author{135768K 武田和馬 {}{} 指導教員 : 河野真治}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
23 \date{}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
24 \maketitle
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
25 \thispagestyle{fancy}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
26
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
27 \section{非破壊木構造データベース}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
28
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
29 当研究室ではデータの変更の際に過去の木構造を保存しつつ新しく木構造を作成する非破壊的木構造を用いたデータベースであるJungleを開発している。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
30 本研究ではJungle DBをC\#で再実装を行い、Unity向けに組み込みを行う。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
31
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
32 Jugnleの木は、子供を複数持つノードからなる。子供は順序付けられており、任意の位置で作成削除することができる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
33
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
34 Unityは3Dゲームエンジンである。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
35 ゲーム構造はシーングラフを実装しており、ゲームオブジェクトの親子関係からなり、子どもを複数もつノードからなる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
36 Jungleはこれと同じ構造を持っているため、相性が良い。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
37
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
38 % ので、過去の組織のデータを参照する必要が出てくる。よって過去のデータの参照が出来るJungleと相性が良い。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
39 % これらは、XMLで記述されており、
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
40 % maTrixが保持している人、役職、役割等のデータはお互いに参照している。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
41 % ポリシーファイルは、組織の中で申請等を行った際に、どの権限によってその申請が許諾されるのかを指定している。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
42 % 組織のデータ、ポリシーファイル共に木構造のデータであるため、Jungleにそのまま格納できる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
43
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
44 \section{Unityでの問題点}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
45
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
46 Unityではデータの保存の際にMySQL、SQlite3、PlayerPrefsといった第一正規系、第二正規系のDBがよく使われている。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
47 しかし、図1のように木構造でゲームは構成されているため、RDB向けにノードの関係を変換する必要がある。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
48 つまり、そのまま格納することができればスケールアウトするデータにも対応でき、データベース設計も簡略化できると考え、C\#に書き直すことにした。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
49
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
50 PlayerPrefsとは、Unityに特化したバイナリ形式でKey,Valueで保存されるものである。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
51
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
52 \section{Jungle-Sharpの実装}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
53
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
54 JungleはJavaで書かれているものであったのでUnityで使うにはC\#で実装する必要があった。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
55
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
56 \section{AtomicRefefarenceの実装}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
57 % atomic reference問題
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
58 JavaにはAtomicRefarenceが標準であったがC\#はなかったため、AtomicReferenceのClassを新たに作った。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
59
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
60 {\scriptsize
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
61 \begin{itembox}[l]{図1 AtomicReference.cs}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
62 \begin{verbatim}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
63 public class AtomicReference <T> where T : class {
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
64 private T value;
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
65
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
66 public AtomicReference(T value) {
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
67 this.value = value;
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
68 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
69
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
70 public bool CompareAndSet(T newValue, T prevValue) {
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
71 T oldValue = value;
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
72 return (oldValue
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
73 != Interlocked.CompareExchange (ref value, newValue, prevValue));
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
74 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
75
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
76 public T Get() {
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
77 return value;
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
78 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
79 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
80 \end{verbatim}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
81 \end{itembox}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
82 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
83
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
84 CompereAndSetメソッドではInterlocked Operationを利用した。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
85 これによりスレッドセーフな値の変更を行うことが可能になる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
86
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
87 \section{Listの実装}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
88
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
89 Listを実装する際にIteratorが必要となる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
90 C\#にはIEnumeratorがあるのでそれを利用した。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
91
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
92 {\scriptsize
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
93 \begin{itembox}[l]{図2 List.cs}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
94 \begin{verbatim}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
95 public IEnumerator<T> iterator() {
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
96 Node<T> currentNode = head.getNext();
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
97 while (currentNode.getAttribute() != null) {
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
98 yield return (T)currentNode.getAttribute();
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
99 currentNode = currentNode.getNext ();
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
100 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
101 }
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
102 \end{verbatim}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
103 \end{itembox}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
104 }\\
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
105
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
106 ListのforeachではIteratorを呼び出すため、一つずつ要素を返す必要がある。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
107 yield returnステートメントを利用することで位置が保持され次に呼ばれた際に続きから値の取り出しが可能になる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
108
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
109 \section{ベンチマーク}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
110
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
111 UnityではSqlite3,PlayerPrefsがデータの保存として利用される。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
112 今回の検証はInsertを1000回行い、push(またはSave)を行うまでの時間を測定する。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
113
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
114 使用した機材は以下の通りである。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
115 \begin{itemize}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
116 \item OS : Windows 10
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
117 \item CPU : Intel Core i7-4700MQ 2.4GHz
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
118 \item Unity : Unity 5.4.2f1
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
119 \end{itemize}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
120
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
121 \begin{figure}[h]
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
122 \includegraphics[width=70mm]{pic/benchmark.pdf}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
123 \end{figure}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
124
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
125 Sqlite3では100msを超えてしまったため省略してある。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
126 図3の結果よりJungleDBの速度を確認することができた。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
127
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
128
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
129 \section{これからの作業}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
130
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
131 Jungleは分散型のデータベースを目指しているため、MessagePackの実装を行う。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
132 今後はサーバーとの連携も行う。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
133 JungleはRDBと異なりデータを自由に格納することができる。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
134 そこでデータベース設計を確立させる必要がある。
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
135
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
136 \begin{thebibliography}{9}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
137
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
138 \bibitem{1}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
139 玉城将士 非破壊的木構造を用いた分散CMSの設計と実装
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
140 \bibitem{2}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
141 大城信康 分散Database Jungleに関する研究
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
142 \bibitem{3}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
143 金川竜己 非破壊的木構造データベースJungleとその評価
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
144 \end{thebibliography}
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
145
dd95a76fba0c add templete
Kazuma
parents:
diff changeset
146 \end{document}