登机门|登机门CS 2008 |问题70

考虑一个16384个记录的文件。每条记录的长度为32字节,其密钥字段的大小为6字节。文件在非键字段上排序,文件组织未经扫描。文件存储在块大小为1024字节的文件系统中,块指针的大小为10字节。如果二级索引建立在文件的键字段上,并且使用多级索引方案存储二级索引,则多级索引中的第一级和第二级块的数量分别为。 (A) 8和0 (B) 128和6 (C) 256和4 (D) 512和5 答复: (C) 说明: 索引机制用于优化对文件中管理的数据(记录)的某些访问。例如,库中的作者目录是一种索引。索引文件由表单的记录(称为索引项)组成

null
-----------------------------------
| Search-Key  |  Pointer to Block |
----------------------------------- 

如果外部索引太大,无法放入主内存,则可以创建另一级别的索引,以此类推。

multilevelindex

Number of records in file = 16384

Record size = 32 bytes
Key Size = 6 bytes
Block Size on file system = 1024 bytes
Size of Block Pointer = 10 bytes

Size of a record or index Entry = 10 + 6 = 16 

Number of blocks in first level = (Number of records in file)/
                                   (Disk Block Size)
                                = (16384 * 16)/(1024)
                                = 16 * 16
                                = 256

In second level, there will be 256 * 16 entries.
Number of blocks in second level = (Number of entries) / 
                                   (Block Size)
                                 = (256 * 16) / 1024
                                 = 4

这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享