- 1、本文档共17页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
* 19 * 19 External Sorting Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides Why Sort? A classic problem in computer science! Data requested in sorted order e.g., find students in increasing gpa order First step in bulk loading B+ tree index. Useful for eliminating duplicates (Why?) Useful for summarizing groups of tuples Sort-merge join algorithm involves sorting. Problem: sort 100Gb of data with 1Gb of RAM. why not virtual memory? Streaming Data Through RAM An important method for sorting other DB operations Simple case: Compute f(x) for each record, write out the result Read a page from INPUT to Input Buffer Write f(x) for each item to Output Buffer When Input Buffer is consumed, read another page When Output Buffer fills, write it to OUTPUT Reads and Writes are not coordinated E.g., if f() is Compress(), you read many pages per write. E.g., if f() is DeCompress(), you write many pages per read. f(x) RAM Input Buffer Output Buffer OUTPUT INPUT 2-Way Sort: Requires 3 Buffers Pass 0: Read a page, sort it, write it. only one buffer page is used (as in previous slide) Pass 1, 2, 3, …, etc.: requires 3 buffer pages merge pairs of runs into runs twice as long three buffer pages used. Main memory buffers INPUT 1 INPUT 2 OUTPUT Disk Disk Merging Runs Two-Way External Merge Sort Each pass we read + write each page in file. N pages in the file = the number of passes So total cost is: Idea: Divide and conquer: sort subfiles and merge Input file 1runs 2runs 4runs 8runs PASS 0 PASS 1 PASS 2 PASS 3 9 3,4 6,2 9,4 8,7 5,6 3,1 2 3,4 5,6 2,6 4,9 7,8 1,3 2 2,3 4,6 4,7 8,9 1,3 5,6 2 2,3 4,4 6,7 8,9 1,2 3,5 6 1,2 2,3 3,4 4,5 6,6 7,8 Merging Runs General External Merge Sort To sort a file with N pages using B buffer pages: Pass 0: use B buffer pages. Produce sorted runs of B pages each. Pass 1, 2, …, etc.: merge B-1 runs. B Main memory buffers INPUT 1 INPUT B-1 OUTPUT Disk Disk INPUT 2 . . . . . . . . . More
您可能关注的文档
最近下载
- 2025年青岛港湾职业技术学院单招职业倾向性测试题库(精选题).docx VIP
- FSSC22000 V6食品安全管理体系管理手册.doc VIP
- ZZ030 植物病虫害防治赛项赛题-2023年全国职业院校技能大赛拟设赛项赛题完整版(10套).docx
- 2025年湖南铁道职业技术学院单招职业适应性测试题库审定版.docx VIP
- 临时用电安全培训.ppt VIP
- 国产660MW超临界机组电厂汽轮机设备及系统.pdf
- 预算费合同范本.docx VIP
- 2025年云南昆明市呈贡区城市投资集团有限公司招聘笔试参考题库附带答案详解.pdf
- 胰腺癌的围手术期护理进展.pptx VIP
- 餐饮业报销管理规程x.docx VIP
文档评论(0)