1 / 21

文件结构及其性能分析

文件结构及其性能分析. 软件室 朱茂盛 Zhums@software.ict.ac.cn 2001.10.26. 主要内容. 介绍 顺序文件 B+- 树文件 Hash 文件 XML 文件及其索引 外部排序. 1. 介绍. 1.1 文件结构设计目的 1.2 基本假定 1.3 基本概念 1.4 一个例子. 1.1 目的. 提高 ( 动态 ) 大文件的访问速度 节省磁盘空间 增加可用性(减少重组). 1.2 基本假定. 存储器容量 单用户环境 文件纪录结构 动态文件结构 I/O 时间 >> 计算时间 没有缓冲区. 1.3 基本概念.

benjy
Download Presentation

文件结构及其性能分析

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 文件结构及其性能分析 软件室 朱茂盛 Zhums@software.ict.ac.cn 2001.10.26

  2. 主要内容 • 介绍 • 顺序文件 • B+-树文件 • Hash文件 • XML文件及其索引 • 外部排序

  3. 1.介绍 • 1.1文件结构设计目的 • 1.2基本假定 • 1.3基本概念 • 1.4一个例子

  4. 1.1目的 • 提高(动态)大文件的访问速度 • 节省磁盘空间 • 增加可用性(减少重组)

  5. 1.2基本假定 • 存储器容量 • 单用户环境 • 文件纪录结构 • 动态文件结构 • I/O 时间>>计算时间 • 没有缓冲区

  6. 1.3基本概念 • Platter,Head,Track,Cylinder,Sector,Block,Bucket,Page. • 寻道时间(Seek Time –s) • 旋转时间(Rotational Time-r) • 传输时间(Transfer Time-t) • 基本文件操作 TF,TN,TI,TU,TD,TX,TY

  7. IBM 3380磁盘参数 • B block size 2400 bytes • Btt block transfer time 0.8ms • C Blocks per cylinder 600 • Ebt effective block tran time 0.84ms • M minimum seek time 3ms • R average rotational latency 8.3ms • S average seek time 16ms • T speed 3000bytes/ms

  8. 1.4一个例子 • 顺序读10Blocks 时间= s+r+10*ebt = 16+8.3+10*0.84=32.7ms; 随机读10Blocks 时间= 10*(s+r+btt) = 10*(16+8.3+0.84) = 10*25.1 = 251ms Seek file test.

  9. 2.顺序文件 • 堆文件 TF = (b/2)*ebt, TN = TF, TX = b*ebt TI= s+r+btt+2r, TU = TD = TF+ 2r TY = (b+n/Bfr)*ebt • 顺序文件 TF = (logb –1)*(s+r+btt), TF(overflow) = (x/b)*(x/2)*ebt, TN=(1/Bfr)*(r+btt), TN(overflow) = (x/b)*(x/2)*ebt TD = TF+2r, TI = s+r+btt+2r(know last block), TU=TD+TI,TU’=TF+2r(sort field not changed)

  10. 3.B+-树文件 • Inverted index • ISAM/VSAM 缺点: 遇到大的动态文件,溢出链很长,单一纪录存取=堆文件,需要重组。 • B+-树(GigaBytes) 无须重组,常数的单一纪录存取次数2

  11. 3.1B+-树定义 • 阶 • 根 • 关键字和指针 • 内部节点 • 叶子节点

  12. 3.2基本概念和参数 • Primary /Second index • Dense / Sparse index • Bucket factor • Fan-out(log2*2v=1.4v) • Two-Disk-Access TF= s+r+btt+s+r+dtt • Why(primary and second condition)

  13. Mem>bk/fan-out2 • TX(primary) = bk*(s+r+dtt), bk = n/(ln2*bkfr) • TX(second) = n*(s+r+dtt)+(n/ln2*2v)*(s+r+btt) • TN(primary) = (1/ln2*bkfr)*(s+r+dtt) • TN(second) = (s+r+dtt)+(1/ln2*2v)*(s+r+btt) • 改变叶结点大小和内部节点大小的影响 TF,TX,树的高度

  14. 3.3范围查询 • FS*n*(s+r+dtt)<=bk*dtt FP*bk*(s+r+dtt)<=bk*dtt(seq reading) FP<=dtt/(s+r+dtt); 如果要求结果有序 F*bk*(s+r+dtt)<=bk*dtt+Tsort(F*n)

  15. 3.4B+树操作 • 插入节点 • 删除节点 • 构造B+树

  16. 4 Hash • 定义 • Direct access /按内容存取 • Buckets • Chaining • 不保持顺序 • 负载因子(lf = n/m*bkfr)

  17. 4.1基本参数 • TF(succ) = s+r+dtt+(x/2)*(s+r+dtt) • TF(fail) = s+r+dtt+x*(s+r+dtt) • TX = n*TF • TI = TF(fail)+2r,TD,TU

  18. 4.2一个例子 • 6M*400-bytes record • 10,000 random individual record fetch • 10*3% range search 三种文件结构: 1.Hash load-factor=70%,bkfr = 50 2.same hash table as 1 with B+-second index 3.B+-树(primary)

  19. 4.3Linear Hash • Constant loaf-factor • Delete algorithm • Search algorithm • Constructing a hash table file (确定参数,估计空间)

  20. 5 XML • Insert algorithm • 不同类型纪录的关联 • Multiring/Multilists File • Natural join 不同的查询请求

  21. 外部排序 • 两阶段,多路合并排序 • 排序阶段(堆排序) • 合并阶段(p-way) • 最优合并路数 2b*ebt+(logp(nsg)*(2*p*(nsg)*(r+s)+2b*ebt)

More Related