SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
Maintain Indexes.
Adding a data record with Indexing.
Deleting a data record with Indexing.
Reclaiming space.
Multilevel Index.
Dr. Hussien M.
Sharaf
2
Dr. Hussien M.
Sharaf
3
Structure of Indexes
Indexes must be sorted on ascending or descending
order with respect to a (one or more ) field(s).
CompanyName offset
Google 211Record1
n
n
IBM 0Record2 n
ITE 643Record3 n
Microsoft 462Record4 n
Apple Mac 985
New
record n
Dr. Hussien M.
Sharaf
4
Operations needed for an Index:
1. Create an index at memory by
looping on all records from the
original data file.
2. If the there is an index file, load it
into memory before using it.
3. Write the index into file at the
closing of the program.
Dr. Hussien M.
Sharaf
5
-Now Index is loaded at memory, the following
operations are needed:
1. Add: Add data records to the data file and
insert an index record at the correct position.
2. Delete: mark the record at data file as
deleted and delete the related record from
the index.
3. Deleting and updating data records requires
updating the offsets of all index records. Is it
the same for the adding a data record?
Dr. Hussien M.
Sharaf
6
R1
R2
R3
R4
R5
Data records
R4
R3
R2
R5
R1
Index on Name
R2
R3
R1
R4
R5
Index on Phone
Dr. Hussien M.
Sharaf
7
R1
R2
R3
R4
R5
Data records
on disk
R4
R3
R2
R5
R1
Name Index on RAM
R2
R3
R1
R4
R5
Phone Index on RAM
R6
R6
R6
Dr. Hussien M.
Sharaf
8
1. Go to the end of data file, get current offset.
2. Data record is appended to the end of data
file.
3. An index entry is built using offset and key
of the new data record. (offset, Key)
4. The new index entry is inserted into its
correct position at sorted index list.
5. At the end of the program the index list is
saved into disk.
Dr. Hussien M.
Sharaf
9
1. Search for index entry by comparing target
value with the key field value.
2. Mark the index entry as deleted.
3. Get the offset of the target data record.
4. Seek for the target offset , mark the data
record as deleted.
NOTE: Data record is not actually deleted
immediately. Space reclaiming function is
required to run.
Dr. Hussien M.
Sharaf
10
R1
R2
R3
R4
R5
Data records
on disk
R4
R6
R2
R5
R1
Name Index on RAM
R2
R6
R1
R4
R5
Phone Index on RAM
R6
R3
R3
Dr. Hussien M.
Sharaf
11
A. Create a new file stream.
B. While not end of records
1. Read a collection of records into buffer.
2. For each record in the buffer:
If record is marked deleted, go to the next record.
Else copy record to the new file stream.
C. End While
D. Rebuild all indexes based on the new data
file.
NOTE: in the process of copying data to the
new stream, buffering is used.
Dr. Hussien M.
Sharaf
12
When an Index gets very big, it can not
be stored in RAM.
It should be stored on file, hence another
level of index that can be loaded into
memory is required.
Hence we need multilevel of indexing.
Dr. Hussien M.
Sharaf
13
Level #4 Index can be loaded into memory
CS215 - Lec 9  indexing and reclaiming space in files

Mais conteúdo relacionado

Mais procurados

Tutorial for Circular and Rectangular Manhattan plots
Tutorial for Circular and Rectangular Manhattan plotsTutorial for Circular and Rectangular Manhattan plots
Tutorial for Circular and Rectangular Manhattan plotsAvjinder (Avi) Kaler
 
Data Wrangling with Open Refine
Data Wrangling with Open RefineData Wrangling with Open Refine
Data Wrangling with Open RefineLOUIS Libraries
 
Big Data & Hadoop Data Analysis
Big Data & Hadoop Data AnalysisBig Data & Hadoop Data Analysis
Big Data & Hadoop Data AnalysisKoushik Mondal
 
Basic Tutorial of Association Mapping by Avjinder Kaler
Basic Tutorial of Association Mapping by Avjinder KalerBasic Tutorial of Association Mapping by Avjinder Kaler
Basic Tutorial of Association Mapping by Avjinder KalerAvjinder (Avi) Kaler
 
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...John Fonner
 
WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016
WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016
WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016Penn State University
 
Computation systems for protecting delimited data
Computation systems for protecting delimited dataComputation systems for protecting delimited data
Computation systems for protecting delimited dataG Prachi
 

Mais procurados (10)

Tutorial for Circular and Rectangular Manhattan plots
Tutorial for Circular and Rectangular Manhattan plotsTutorial for Circular and Rectangular Manhattan plots
Tutorial for Circular and Rectangular Manhattan plots
 
Data Wrangling with Open Refine
Data Wrangling with Open RefineData Wrangling with Open Refine
Data Wrangling with Open Refine
 
Big Data & Hadoop Data Analysis
Big Data & Hadoop Data AnalysisBig Data & Hadoop Data Analysis
Big Data & Hadoop Data Analysis
 
Design and creation of ontologies for environmental information retrieval
Design and creation of ontologies for environmental information retrievalDesign and creation of ontologies for environmental information retrieval
Design and creation of ontologies for environmental information retrieval
 
Basic Tutorial of Association Mapping by Avjinder Kaler
Basic Tutorial of Association Mapping by Avjinder KalerBasic Tutorial of Association Mapping by Avjinder Kaler
Basic Tutorial of Association Mapping by Avjinder Kaler
 
Beautiful Research Data (Structured Data and Open Refine)
Beautiful Research Data (Structured Data and Open Refine)Beautiful Research Data (Structured Data and Open Refine)
Beautiful Research Data (Structured Data and Open Refine)
 
Db lec 08_new
Db lec 08_newDb lec 08_new
Db lec 08_new
 
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
 
WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016
WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016
WF ED 540, Class Meeting 3 - Introduction to dplyr, 2016
 
Computation systems for protecting delimited data
Computation systems for protecting delimited dataComputation systems for protecting delimited data
Computation systems for protecting delimited data
 

Destaque

Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File OrganizationMISY
 
Disk structure & File Handling
Disk structure & File HandlingDisk structure & File Handling
Disk structure & File HandlingMomina Idrees
 
Gps file structure explained
Gps file structure explainedGps file structure explained
Gps file structure explainedJaap Oosterhoff
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure ConceptsDileep Kodira
 
Discussion : File structure of Meteor Apps
Discussion : File structure of Meteor AppsDiscussion : File structure of Meteor Apps
Discussion : File structure of Meteor AppsSangwon Lee
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organizationBishal Ghimire
 
register file structure of PIC controller
register file structure of PIC controllerregister file structure of PIC controller
register file structure of PIC controllerNirbhay Singh
 
File organization and processing
File organization and processingFile organization and processing
File organization and processingburhan123456
 
Ch 1-final-file organization from korth
Ch 1-final-file organization from korthCh 1-final-file organization from korth
Ch 1-final-file organization from korthRupali Rana
 
Concept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnersConcept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnerswellingtonoboh
 
File organization techniques
File organization techniquesFile organization techniques
File organization techniquesMeghlal Khan
 
Office administration ppowerpoitn wed
Office administration ppowerpoitn wedOffice administration ppowerpoitn wed
Office administration ppowerpoitn wedcindyanna
 
Concept of computer files
Concept of computer filesConcept of computer files
Concept of computer filesSamuel Igbanogu
 

Destaque (20)

CS215 - Lec 2 file organization
CS215 - Lec 2   file organizationCS215 - Lec 2   file organization
CS215 - Lec 2 file organization
 
Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File Organization
 
Disk structure & File Handling
Disk structure & File HandlingDisk structure & File Handling
Disk structure & File Handling
 
Gps file structure explained
Gps file structure explainedGps file structure explained
Gps file structure explained
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure Concepts
 
Discussion : File structure of Meteor Apps
Discussion : File structure of Meteor AppsDiscussion : File structure of Meteor Apps
Discussion : File structure of Meteor Apps
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organization
 
File organisation
File organisationFile organisation
File organisation
 
register file structure of PIC controller
register file structure of PIC controllerregister file structure of PIC controller
register file structure of PIC controller
 
File organization and processing
File organization and processingFile organization and processing
File organization and processing
 
Ch 1-final-file organization from korth
Ch 1-final-file organization from korthCh 1-final-file organization from korth
Ch 1-final-file organization from korth
 
Model answer of compilers june spring 2013
Model answer of compilers june spring 2013Model answer of compilers june spring 2013
Model answer of compilers june spring 2013
 
Concept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnersConcept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learners
 
File organization techniques
File organization techniquesFile organization techniques
File organization techniques
 
Office administration ppowerpoitn wed
Office administration ppowerpoitn wedOffice administration ppowerpoitn wed
Office administration ppowerpoitn wed
 
Handling computer files
Handling computer filesHandling computer files
Handling computer files
 
Concept of computer files
Concept of computer filesConcept of computer files
Concept of computer files
 
File organization
File organizationFile organization
File organization
 
File handling
File handlingFile handling
File handling
 
File organisation
File organisationFile organisation
File organisation
 

Semelhante a CS215 - Lec 9 indexing and reclaiming space in files

Vikas 500 BIG DATA TECHNOLOGIES LAB.pdf
Vikas 500 BIG DATA TECHNOLOGIES LAB.pdfVikas 500 BIG DATA TECHNOLOGIES LAB.pdf
Vikas 500 BIG DATA TECHNOLOGIES LAB.pdfvikas12611618
 
MARUTHI_INVERTED_SEARCH_presentation.pptx
MARUTHI_INVERTED_SEARCH_presentation.pptxMARUTHI_INVERTED_SEARCH_presentation.pptx
MARUTHI_INVERTED_SEARCH_presentation.pptxMaruthiRock
 
File handling in qbasic
File handling in qbasicFile handling in qbasic
File handling in qbasicSmritiGurung4
 
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdfReaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdffashionbigchennai
 
iLAB OVERVIEWScenario and SummarySuccessful database recovery re.docx
iLAB OVERVIEWScenario and SummarySuccessful database recovery re.docxiLAB OVERVIEWScenario and SummarySuccessful database recovery re.docx
iLAB OVERVIEWScenario and SummarySuccessful database recovery re.docxrochellscroop
 
Unit 4 data storage and querying
Unit 4   data storage and queryingUnit 4   data storage and querying
Unit 4 data storage and queryingRavindran Kannan
 
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docxLog into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docxdesteinbrook
 
Overview of Storage and Indexing ...
Overview of Storage and Indexing                                             ...Overview of Storage and Indexing                                             ...
Overview of Storage and Indexing ...Javed Khan
 
Creating a Scheduled Backup and Replicating System Folders Introduct.docx
Creating a Scheduled Backup and Replicating System Folders Introduct.docxCreating a Scheduled Backup and Replicating System Folders Introduct.docx
Creating a Scheduled Backup and Replicating System Folders Introduct.docxwilliejgrant41084
 
A practical-guide-for-“essbase-backup-and-recovery-part-ii -
A practical-guide-for-“essbase-backup-and-recovery-part-ii - A practical-guide-for-“essbase-backup-and-recovery-part-ii -
A practical-guide-for-“essbase-backup-and-recovery-part-ii - Abdoulaye M Yansane
 

Semelhante a CS215 - Lec 9 indexing and reclaiming space in files (20)

CS215 - Lec 7 managing records collection
CS215 - Lec 7  managing records collectionCS215 - Lec 7  managing records collection
CS215 - Lec 7 managing records collection
 
Vikas 500 BIG DATA TECHNOLOGIES LAB.pdf
Vikas 500 BIG DATA TECHNOLOGIES LAB.pdfVikas 500 BIG DATA TECHNOLOGIES LAB.pdf
Vikas 500 BIG DATA TECHNOLOGIES LAB.pdf
 
MARUTHI_INVERTED_SEARCH_presentation.pptx
MARUTHI_INVERTED_SEARCH_presentation.pptxMARUTHI_INVERTED_SEARCH_presentation.pptx
MARUTHI_INVERTED_SEARCH_presentation.pptx
 
File handling in qbasic
File handling in qbasicFile handling in qbasic
File handling in qbasic
 
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdfReaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
 
Preparing Import Files
Preparing Import FilesPreparing Import Files
Preparing Import Files
 
DATASTORAGE.pdf
DATASTORAGE.pdfDATASTORAGE.pdf
DATASTORAGE.pdf
 
DATASTORAGE
DATASTORAGEDATASTORAGE
DATASTORAGE
 
DATASTORAGE.pptx
DATASTORAGE.pptxDATASTORAGE.pptx
DATASTORAGE.pptx
 
File handling
File handlingFile handling
File handling
 
Hadoop -HDFS.ppt
Hadoop -HDFS.pptHadoop -HDFS.ppt
Hadoop -HDFS.ppt
 
iLAB OVERVIEWScenario and SummarySuccessful database recovery re.docx
iLAB OVERVIEWScenario and SummarySuccessful database recovery re.docxiLAB OVERVIEWScenario and SummarySuccessful database recovery re.docx
iLAB OVERVIEWScenario and SummarySuccessful database recovery re.docx
 
Unit 4 data storage and querying
Unit 4   data storage and queryingUnit 4   data storage and querying
Unit 4 data storage and querying
 
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docxLog into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
 
Overview of Storage and Indexing ...
Overview of Storage and Indexing                                             ...Overview of Storage and Indexing                                             ...
Overview of Storage and Indexing ...
 
Installing pidsr
Installing pidsrInstalling pidsr
Installing pidsr
 
Lec 1 indexing and hashing
Lec 1 indexing and hashing Lec 1 indexing and hashing
Lec 1 indexing and hashing
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashing
 
Creating a Scheduled Backup and Replicating System Folders Introduct.docx
Creating a Scheduled Backup and Replicating System Folders Introduct.docxCreating a Scheduled Backup and Replicating System Folders Introduct.docx
Creating a Scheduled Backup and Replicating System Folders Introduct.docx
 
A practical-guide-for-“essbase-backup-and-recovery-part-ii -
A practical-guide-for-“essbase-backup-and-recovery-part-ii - A practical-guide-for-“essbase-backup-and-recovery-part-ii -
A practical-guide-for-“essbase-backup-and-recovery-part-ii -
 

Mais de Arab Open University and Cairo University

Mais de Arab Open University and Cairo University (20)

Infos2014
Infos2014Infos2014
Infos2014
 
File Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswerFile Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswer
 
Model answer of exam TC_spring 2013
Model answer of exam TC_spring 2013Model answer of exam TC_spring 2013
Model answer of exam TC_spring 2013
 
Theory of computation Lec6
Theory of computation Lec6Theory of computation Lec6
Theory of computation Lec6
 
Lec4
Lec4Lec4
Lec4
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
Theory of computation Lec2
Theory of computation Lec2Theory of computation Lec2
Theory of computation Lec2
 
Theory of computation Lec1
Theory of computation Lec1Theory of computation Lec1
Theory of computation Lec1
 
Theory of computation Lec7 pda
Theory of computation Lec7 pdaTheory of computation Lec7 pda
Theory of computation Lec7 pda
 
Setup python with eclipse
Setup python with eclipseSetup python with eclipse
Setup python with eclipse
 
Cs419 lec8 top-down parsing
Cs419 lec8    top-down parsingCs419 lec8    top-down parsing
Cs419 lec8 top-down parsing
 
Cs419 lec11 bottom-up parsing
Cs419 lec11   bottom-up parsingCs419 lec11   bottom-up parsing
Cs419 lec11 bottom-up parsing
 
Cs419 lec12 semantic analyzer
Cs419 lec12  semantic analyzerCs419 lec12  semantic analyzer
Cs419 lec12 semantic analyzer
 
Cs419 lec9 constructing parsing table ll1
Cs419 lec9   constructing parsing table ll1Cs419 lec9   constructing parsing table ll1
Cs419 lec9 constructing parsing table ll1
 
Cs419 lec10 left recursion and left factoring
Cs419 lec10   left recursion and left factoringCs419 lec10   left recursion and left factoring
Cs419 lec10 left recursion and left factoring
 
Cs419 lec7 cfg
Cs419 lec7   cfgCs419 lec7   cfg
Cs419 lec7 cfg
 
Cs419 lec6 lexical analysis using nfa
Cs419 lec6   lexical analysis using nfaCs419 lec6   lexical analysis using nfa
Cs419 lec6 lexical analysis using nfa
 
Cs419 lec5 lexical analysis using dfa
Cs419 lec5   lexical analysis using dfaCs419 lec5   lexical analysis using dfa
Cs419 lec5 lexical analysis using dfa
 
Cs419 lec4 lexical analysis using re
Cs419 lec4   lexical analysis using reCs419 lec4   lexical analysis using re
Cs419 lec4 lexical analysis using re
 
Cs419 lec3 lexical analysis using re
Cs419 lec3   lexical analysis using reCs419 lec3   lexical analysis using re
Cs419 lec3 lexical analysis using re
 

Último

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Último (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

CS215 - Lec 9 indexing and reclaiming space in files

  • 1.
  • 2. Maintain Indexes. Adding a data record with Indexing. Deleting a data record with Indexing. Reclaiming space. Multilevel Index. Dr. Hussien M. Sharaf 2
  • 3. Dr. Hussien M. Sharaf 3 Structure of Indexes Indexes must be sorted on ascending or descending order with respect to a (one or more ) field(s). CompanyName offset Google 211Record1 n n IBM 0Record2 n ITE 643Record3 n Microsoft 462Record4 n Apple Mac 985 New record n
  • 4. Dr. Hussien M. Sharaf 4 Operations needed for an Index: 1. Create an index at memory by looping on all records from the original data file. 2. If the there is an index file, load it into memory before using it. 3. Write the index into file at the closing of the program.
  • 5. Dr. Hussien M. Sharaf 5 -Now Index is loaded at memory, the following operations are needed: 1. Add: Add data records to the data file and insert an index record at the correct position. 2. Delete: mark the record at data file as deleted and delete the related record from the index. 3. Deleting and updating data records requires updating the offsets of all index records. Is it the same for the adding a data record?
  • 6. Dr. Hussien M. Sharaf 6 R1 R2 R3 R4 R5 Data records R4 R3 R2 R5 R1 Index on Name R2 R3 R1 R4 R5 Index on Phone
  • 7. Dr. Hussien M. Sharaf 7 R1 R2 R3 R4 R5 Data records on disk R4 R3 R2 R5 R1 Name Index on RAM R2 R3 R1 R4 R5 Phone Index on RAM R6 R6 R6
  • 8. Dr. Hussien M. Sharaf 8 1. Go to the end of data file, get current offset. 2. Data record is appended to the end of data file. 3. An index entry is built using offset and key of the new data record. (offset, Key) 4. The new index entry is inserted into its correct position at sorted index list. 5. At the end of the program the index list is saved into disk.
  • 9. Dr. Hussien M. Sharaf 9 1. Search for index entry by comparing target value with the key field value. 2. Mark the index entry as deleted. 3. Get the offset of the target data record. 4. Seek for the target offset , mark the data record as deleted. NOTE: Data record is not actually deleted immediately. Space reclaiming function is required to run.
  • 10. Dr. Hussien M. Sharaf 10 R1 R2 R3 R4 R5 Data records on disk R4 R6 R2 R5 R1 Name Index on RAM R2 R6 R1 R4 R5 Phone Index on RAM R6 R3 R3
  • 11. Dr. Hussien M. Sharaf 11 A. Create a new file stream. B. While not end of records 1. Read a collection of records into buffer. 2. For each record in the buffer: If record is marked deleted, go to the next record. Else copy record to the new file stream. C. End While D. Rebuild all indexes based on the new data file. NOTE: in the process of copying data to the new stream, buffering is used.
  • 12. Dr. Hussien M. Sharaf 12 When an Index gets very big, it can not be stored in RAM. It should be stored on file, hence another level of index that can be loaded into memory is required. Hence we need multilevel of indexing.
  • 13. Dr. Hussien M. Sharaf 13 Level #4 Index can be loaded into memory