- 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
您可能关注的文档
- 数据库课件07-第七章数据库恢复技术-new幻灯片.ppt
- 摩擦学第一章节绪论课件幻灯片.ppt
- 晶体的结构和性质课件幻灯片.ppt
- 数据库课件08-第八章并发控制-new幻灯片.ppt
- 数控机床与编程第2版郑堤基本课件第3章数控机床的机械结构幻灯片.ppt
- 晶体的生长课件幻灯片.ppt
- 数据库课件08第八章节并发控制new幻灯片.ppt
- 数据库课件09第九章节数据库安全性new幻灯片.ppt
- 数控机床与编程第2版郑堤基本课件第4章节数控加工与编程基础幻灯片.ppt
- 数据库课件09第九章节数据库安全性ntz幻灯片.ppt
- 第十一章 电流和电路专题特训二 实物图与电路图的互画 教学设计 2024-2025学年鲁科版物理九年级上册.docx
- 人教版七年级上册信息技术6.3加工音频素材 教学设计.docx
- 5.1自然地理环境的整体性 说课教案 (1).docx
- 4.1 夯实法治基础 教学设计-2023-2024学年统编版九年级道德与法治上册.docx
- 3.1 光的色彩 颜色 电子教案 2023-2024学年苏科版为了八年级上学期.docx
- 小学体育与健康 四年级下册健康教育 教案.docx
- 2024-2025学年初中数学九年级下册北京课改版(2024)教学设计合集.docx
- 2024-2025学年初中科学七年级下册浙教版(2024)教学设计合集.docx
- 2024-2025学年小学信息技术(信息科技)六年级下册浙摄影版(2013)教学设计合集.docx
- 2024-2025学年小学美术二年级下册人美版(常锐伦、欧京海)教学设计合集.docx
文档评论(0)