最近一个新的任务 要做一个RTree索引 速度查了一些东东 当然最经典的还是Guttman的那篇paper~讲解的很详细 :) 明天开始研究算法吧 时间比较紧 :(
下面是对Guttman paper的部分翻译 不一定准确 :) 偶英文比较烂 :)
<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
空间数据经常是多维的,并不能用一些点来简单的表示。例如地图里面的街道、村庄等。对空间数据的一个典型操作是查找某个区域的所有目标(例如查找中关村大街上所有的餐馆等)。
对空间数据建立索引是一种好的想法,但传统数据库的一维索引并不适合对多维数据的查找。例如 hash 等结构也不适合,因为搜索的时候有一定的范围。而类似 B-Tree 的一些结构不能实现对多维数据的查找。
R-Tree 索引:
R-Tree 索引是一个高度平衡的树,在它的叶节点存放指向数据的指针。并且 RTree 能够保证对一个空间数据的搜索只需要访问很小一部分的 node
空间数据库包含了很多 tuple ,这些 tuple 代表了空间数据。每一个 tuple 有一个唯一的标识( ID ),这样可以访问到某个 tuple 。 RTree 中叶节点包含的索引记录的形式是 (I , tuple-identifier), 这里的 id 指向数据库中的一个 tuple 。 I 表示一个 n 维的矩形,这个矩形是一个 bounding box ,用来涵盖被索引的空间数据对象。
I =(I0, I1, I2, …., In-1) , n 表示维度, Ii 是一个闭区间 [a, b], 用来表示对象在第 i 维中的长度。另外,如果 a 或者 b 是无穷的话,表示该对象延伸到了无限远处。
非叶节点的形式是 (I, child-pointer) 。 child-pointer 是子节点的地址; I 是覆盖了其所有子节点的矩形。
在 RTree 中,每个节点所有的子节点的数目是有限制的,假设每个节点最多拥有 M 个子节点, m<=M/2. 则 RTree 有以下的属性:
1). 除了根节点外,每个节点所拥有的子节点数要在 [m, M] 间。
2). 对于每一个叶节点的索引记录