SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Files and Data Storage
Files and Data Storage
● Most computers are used for data
processing, as a big growth area in the
“information age”
● Data processing from a computer science
perspective:
– Storage of data
– Organization of data
– Access to data
– Processing of data
Data Structures vs File Structures
• Both involve:
– Representation of Data
+
– Operations for accessing data
• Difference:
– Data structures: deal with data in the
main memory
– File structures: deal with the data in the
secondary storage
File Structure in Computer Science
Data Storage in Computer
Goal of the File Structures
● Minimize the number of trips to the
secondary storage (SS) in order to get
desired information.
● Group related information so that we are
likely to get everything we new with fewer
trip to the SS.
● Select the right file structures so that
performance can be increased.
File and File Operations
● A file is a collection of data stored on mass
storage like hard disk, CD etc.
● File data consist of records (student
information) and each record contains
number of fields (ID, Name etc.).
● We can perform following operations on a
file.
– Search for a particular data in a file.
– Add a certain data item.
– Remove / Update a certain item.
File and File operations
– Order the data items according to a
certain criterion, merge of files.
– Creation of new files from existing files.
– Finally create, open, and close
operations which have implications in the
operating system.
Organization of Files
● Sequential
● Indexed
● Hashing
Sequential File Organization
● Records are conceptually organized in a
sequential list and can only be accessed
sequentially.
● The actual storage might or might not be
sequential (on tape or on disk)
Sequential File (Write/Read in C++)
● Create ofstream object (after including file
fstream.h at the top)
● Open file for output or for appending at the
end of file.
● Test whether the file open operation of step
2 is successful. If not successful then exit
else continue.
● Write / Read data to output file.
● Close file after writing / reading data.
Sequential File Implementation
● #include <iostream.h>
● #include <fstream.h>
● #include <stdlib.h>
●
● Void main() {
● Int i, Roll[N] = { 171,717, 834, 394, 475 };
● float Percentage[N]= {45.3, 84.5, 95.0,
48.2, 39.2 };
● Char* Name[N] = {“wajid”, “Aashir”,
“Luqman”, “Tushar”, “Waseem” };
● // Step1: Create ofstream and ifstream
objects
● Ofstream outFile; ifstream inFile;
● // Step 2: Open file for output
● outFile.open(“percent.dat”, ios::out);
● // Step 3 Test weather open operation is
successful
● If (!outFile) {
– cout<<”File could not open “;
– Exit(1);
● Else
– Cout<<”n File open successfullyn”;
● //Step 4: Write to file
● For( i=0; i<N; i++)
– OutFile <<Name[i]<<' '<<Roll[i]<< ' '
<<Percentage[i]<<endl;
● cout<<”n File write successfully. n”;
● // Step 5: Close file
● outFile.close();
Sequential File Implementation
● // Step 6 open file for input
● inFile.open(“percentage.dat”, ios::in);
● // Step 7: Test wether file open successfully.
● if(!inFile) {
– cout<<”File could not open”<<endl;
– Exit(1);
● }
● // Step 8: Read from input File
● While( inFile>> Name >>Roll >> Percentage)
– cout<<setiosflags(ios::left)<<setw(14)<<roll <<setw(16)<<Name <<setw(9)<<Setprecision(4)
– <<setiosflags(ios::showpoint | ios:: right)
– <<percent<<'%'<< endl;
● //Step 9: Close file
● inFile.close(); }
Sequential File Implementation
● OUTPUT:
Roll Number Name Percentage
171 Wajid 45.30%
717 Aashir 84.50%
834 Luqman 95.00%
394 Tushar 48.20%
475 Waseem 39.20%
Indexed File Organization
● Sequential search is even slower on
disk/tape than in main memory. Try to
improve performance using more
sophisticated data structures.
● An index for a file is a list of key field values
occurring in the file along with the address
of the corresponding record in the mass
storage.
● Typically the key field is much smaller than
the entire record, so the index will fit in
main memory.
Indexed File Organization ...
● The index can be organized as a list, a
search tree, a hash table, etc. To find a
particular record:
● Search the index for the desired key.
● When the search returns the index entry,
extract the record’s address on mass
storage.
● Access the mass storage at the given
address to get the desired record.
Indexed File Organization ...
Hashed File Organization
● A hashed file uses a hash function to map
the key to the address.
● Eliminates the need for an extra file (index).
● There is no need for an index and all of the
overhead associated with it.
● Use an array of M < N linked lists, good
choice is M~ N/10
● Hash: map key to integer i between 0 and
M-1.
● Insert: put at front of ith chain (if not already
there).
● Search: only need to search ith chain.
Collusion Resolution (Separate Chaining)
Collusion Resolution (Separate Chaining)
Separate Chaining Implementation
Separate Chaining Implementation
● Use an array of size M >> N, good choice
M~2N
● Hash: map key to integer i between 0 and
M-1.
● Insert: put in slot i if free; if not try i+1, i+2,
etc.
● Search: search slot i; if occupied but no
match, try i+1, i+2, etc.
Collusion Resolution (Open Addressing)
Collusion Resolution (Open addressing)
Open Addressing Implementation

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell scriptBhavesh Padharia
 
OS UNIT 1 PPT.pptx
OS UNIT 1 PPT.pptxOS UNIT 1 PPT.pptx
OS UNIT 1 PPT.pptxPRABAVATHIH
 
File system Os
File system OsFile system Os
File system OsNehal Naik
 
Data base security & integrity
Data base security &  integrityData base security &  integrity
Data base security & integrityPooja Dixit
 
Centralised and distributed database
Centralised and distributed databaseCentralised and distributed database
Centralised and distributed databaseSantosh Singh
 
Network File System in Distributed Computing
Network File System in Distributed ComputingNetwork File System in Distributed Computing
Network File System in Distributed ComputingChandan Padalkar
 
Basic Dynamic Analysis of Malware
Basic Dynamic Analysis of MalwareBasic Dynamic Analysis of Malware
Basic Dynamic Analysis of MalwareNatraj G
 
File system.
File system.File system.
File system.elyza12
 
Web-servers & Application Hacking
Web-servers & Application HackingWeb-servers & Application Hacking
Web-servers & Application HackingRaghav Bisht
 
Understanding das-nas-san
Understanding das-nas-sanUnderstanding das-nas-san
Understanding das-nas-sanAshwin Pawar
 
Complete dbms notes
Complete dbms notesComplete dbms notes
Complete dbms notesTanya Makkar
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access methodrajshreemuthiah
 
multi dimensional data model
multi dimensional data modelmulti dimensional data model
multi dimensional data modelmoni sindhu
 

Was ist angesagt? (20)

Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
OS UNIT 1 PPT.pptx
OS UNIT 1 PPT.pptxOS UNIT 1 PPT.pptx
OS UNIT 1 PPT.pptx
 
Database
DatabaseDatabase
Database
 
File system Os
File system OsFile system Os
File system Os
 
MS Dos command
MS Dos commandMS Dos command
MS Dos command
 
File system
File systemFile system
File system
 
Data base security & integrity
Data base security &  integrityData base security &  integrity
Data base security & integrity
 
Windows Forensics
Windows ForensicsWindows Forensics
Windows Forensics
 
Centralised and distributed database
Centralised and distributed databaseCentralised and distributed database
Centralised and distributed database
 
Network File System in Distributed Computing
Network File System in Distributed ComputingNetwork File System in Distributed Computing
Network File System in Distributed Computing
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 
File sharing
File sharingFile sharing
File sharing
 
Basic Dynamic Analysis of Malware
Basic Dynamic Analysis of MalwareBasic Dynamic Analysis of Malware
Basic Dynamic Analysis of Malware
 
File system.
File system.File system.
File system.
 
Web-servers & Application Hacking
Web-servers & Application HackingWeb-servers & Application Hacking
Web-servers & Application Hacking
 
Understanding das-nas-san
Understanding das-nas-sanUnderstanding das-nas-san
Understanding das-nas-san
 
Complete dbms notes
Complete dbms notesComplete dbms notes
Complete dbms notes
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access method
 
multi dimensional data model
multi dimensional data modelmulti dimensional data model
multi dimensional data model
 

Andere mochten auch

Data Storage for the Long Haul: Compliance and Archive
Data Storage for the Long Haul: Compliance and ArchiveData Storage for the Long Haul: Compliance and Archive
Data Storage for the Long Haul: Compliance and ArchiveAmazon Web Services
 
AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...
AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...
AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...Editor IJCATR
 
Csci12 report aug18
Csci12 report aug18Csci12 report aug18
Csci12 report aug18karenostil
 
Fileorganization AbnMagdy
Fileorganization AbnMagdyFileorganization AbnMagdy
Fileorganization AbnMagdyMohamed Magdy
 
Cloud Computing through FCAPS Managed Services in a Virtualized Data Center
Cloud Computing through FCAPS Managed Services in a Virtualized Data CenterCloud Computing through FCAPS Managed Services in a Virtualized Data Center
Cloud Computing through FCAPS Managed Services in a Virtualized Data Centervsarathy
 
Database, data storage, hosting with Firebase
Database, data storage, hosting with FirebaseDatabase, data storage, hosting with Firebase
Database, data storage, hosting with FirebaseTu Pham
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data StructureAnuj Modi
 
File Organization
File OrganizationFile Organization
File OrganizationManyi Man
 

Andere mochten auch (13)

Data Storage for the Long Haul: Compliance and Archive
Data Storage for the Long Haul: Compliance and ArchiveData Storage for the Long Haul: Compliance and Archive
Data Storage for the Long Haul: Compliance and Archive
 
AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...
AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...
AN INVERTED LIST BASED APPROACH TO GENERATE OPTIMISED PATH IN DSR IN MANETS –...
 
Csci12 report aug18
Csci12 report aug18Csci12 report aug18
Csci12 report aug18
 
Fileorganization AbnMagdy
Fileorganization AbnMagdyFileorganization AbnMagdy
Fileorganization AbnMagdy
 
Cloud Computing through FCAPS Managed Services in a Virtualized Data Center
Cloud Computing through FCAPS Managed Services in a Virtualized Data CenterCloud Computing through FCAPS Managed Services in a Virtualized Data Center
Cloud Computing through FCAPS Managed Services in a Virtualized Data Center
 
external sorting
external sortingexternal sorting
external sorting
 
Database, data storage, hosting with Firebase
Database, data storage, hosting with FirebaseDatabase, data storage, hosting with Firebase
Database, data storage, hosting with Firebase
 
File organization
File organizationFile organization
File organization
 
File organisation
File organisationFile organisation
File organisation
 
B trees in Data Structure
B trees in Data StructureB trees in Data Structure
B trees in Data Structure
 
File Organization
File OrganizationFile Organization
File Organization
 
File Management
File ManagementFile Management
File Management
 
File organization
File organizationFile organization
File organization
 

Ähnlich wie Files and data storage

Linux and windows file system
Linux and windows  file systemLinux and windows  file system
Linux and windows file systemlin yucheng
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))Papu Kumar
 
File Structure.pptx
File Structure.pptxFile Structure.pptx
File Structure.pptxzedd15
 
File handling & basic operation on file in python
File handling & basic operation on file in pythonFile handling & basic operation on file in python
File handling & basic operation on file in pythonishantjaiswal2004
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file systemNikhil Anurag VN
 
ch11_fileInterface.pdf
ch11_fileInterface.pdfch11_fileInterface.pdf
ch11_fileInterface.pdfHoNguyn746501
 
Lecture 8 comp forensics 03 10-18 file system
Lecture 8 comp forensics 03 10-18 file systemLecture 8 comp forensics 03 10-18 file system
Lecture 8 comp forensics 03 10-18 file systemAlchemist095
 
fileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdfFraolUmeta
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMSVrushaliSolanke
 
Physical Database Design for database student-1.pdf
Physical Database Design for database student-1.pdfPhysical Database Design for database student-1.pdf
Physical Database Design for database student-1.pdfBolando
 
Assets, files, and data parsing
Assets, files, and data parsingAssets, files, and data parsing
Assets, files, and data parsingAly Arman
 
Presentation of file handling in C language
Presentation of file handling in C languagePresentation of file handling in C language
Presentation of file handling in C languageShruthi48
 
Reading and Writing Files
Reading and Writing FilesReading and Writing Files
Reading and Writing Filesprimeteacher32
 
File organisation in system analysis and design
File organisation in system analysis and designFile organisation in system analysis and design
File organisation in system analysis and designMohitgauri
 
Understanding EDP (Electronic Data Processing) Environment
Understanding EDP (Electronic Data Processing) EnvironmentUnderstanding EDP (Electronic Data Processing) Environment
Understanding EDP (Electronic Data Processing) EnvironmentAdetula Bunmi
 
Concept of computer files
Concept of computer filesConcept of computer files
Concept of computer filesSamuel Igbanogu
 

Ähnlich wie Files and data storage (20)

Linux and windows file system
Linux and windows  file systemLinux and windows  file system
Linux and windows file system
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashing
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
File Structure.pptx
File Structure.pptxFile Structure.pptx
File Structure.pptx
 
File handling & basic operation on file in python
File handling & basic operation on file in pythonFile handling & basic operation on file in python
File handling & basic operation on file in python
 
How to design a file system
How to design a file systemHow to design a file system
How to design a file system
 
ch11_fileInterface.pdf
ch11_fileInterface.pdfch11_fileInterface.pdf
ch11_fileInterface.pdf
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
Lecture 8 comp forensics 03 10-18 file system
Lecture 8 comp forensics 03 10-18 file systemLecture 8 comp forensics 03 10-18 file system
Lecture 8 comp forensics 03 10-18 file system
 
fileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdffileorganizationandintroductionofdbms-210313163900.pdf
fileorganizationandintroductionofdbms-210313163900.pdf
 
File organization and introduction of DBMS
File organization and introduction of DBMSFile organization and introduction of DBMS
File organization and introduction of DBMS
 
Physical Database Design for database student-1.pdf
Physical Database Design for database student-1.pdfPhysical Database Design for database student-1.pdf
Physical Database Design for database student-1.pdf
 
oslectureset7.pdf
oslectureset7.pdfoslectureset7.pdf
oslectureset7.pdf
 
Assets, files, and data parsing
Assets, files, and data parsingAssets, files, and data parsing
Assets, files, and data parsing
 
Presentation of file handling in C language
Presentation of file handling in C languagePresentation of file handling in C language
Presentation of file handling in C language
 
Reading and Writing Files
Reading and Writing FilesReading and Writing Files
Reading and Writing Files
 
File organisation in system analysis and design
File organisation in system analysis and designFile organisation in system analysis and design
File organisation in system analysis and design
 
Data storage and indexing
Data storage and indexingData storage and indexing
Data storage and indexing
 
Understanding EDP (Electronic Data Processing) Environment
Understanding EDP (Electronic Data Processing) EnvironmentUnderstanding EDP (Electronic Data Processing) Environment
Understanding EDP (Electronic Data Processing) Environment
 
Concept of computer files
Concept of computer filesConcept of computer files
Concept of computer files
 

Mehr von Zaid Shabbir

Modern SDLC and QA.pptx
Modern SDLC and QA.pptxModern SDLC and QA.pptx
Modern SDLC and QA.pptxZaid Shabbir
 
Software Agility.pptx
Software Agility.pptxSoftware Agility.pptx
Software Agility.pptxZaid Shabbir
 
Software Development Guide To Accelerate Performance
Software Development Guide To Accelerate PerformanceSoftware Development Guide To Accelerate Performance
Software Development Guide To Accelerate PerformanceZaid Shabbir
 
Software Testing and Agility
Software Testing and Agility Software Testing and Agility
Software Testing and Agility Zaid Shabbir
 
Data security and Integrity
Data security and IntegrityData security and Integrity
Data security and IntegrityZaid Shabbir
 
Cloud computing &amp; dbms
Cloud computing &amp; dbmsCloud computing &amp; dbms
Cloud computing &amp; dbmsZaid Shabbir
 
No sql bigdata and postgresql
No sql bigdata and postgresqlNo sql bigdata and postgresql
No sql bigdata and postgresqlZaid Shabbir
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary treeZaid Shabbir
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureZaid Shabbir
 

Mehr von Zaid Shabbir (14)

Modern SDLC and QA.pptx
Modern SDLC and QA.pptxModern SDLC and QA.pptx
Modern SDLC and QA.pptx
 
Software Agility.pptx
Software Agility.pptxSoftware Agility.pptx
Software Agility.pptx
 
Software Development Guide To Accelerate Performance
Software Development Guide To Accelerate PerformanceSoftware Development Guide To Accelerate Performance
Software Development Guide To Accelerate Performance
 
Software Testing and Agility
Software Testing and Agility Software Testing and Agility
Software Testing and Agility
 
Data security and Integrity
Data security and IntegrityData security and Integrity
Data security and Integrity
 
Cloud computing &amp; dbms
Cloud computing &amp; dbmsCloud computing &amp; dbms
Cloud computing &amp; dbms
 
No sql bigdata and postgresql
No sql bigdata and postgresqlNo sql bigdata and postgresql
No sql bigdata and postgresql
 
Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Sorting
SortingSorting
Sorting
 
Stack
StackStack
Stack
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Sorting
SortingSorting
Sorting
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 

Kürzlich hochgeladen

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 

Kürzlich hochgeladen (20)

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 

Files and data storage

  • 1. Files and Data Storage
  • 2. Files and Data Storage ● Most computers are used for data processing, as a big growth area in the “information age” ● Data processing from a computer science perspective: – Storage of data – Organization of data – Access to data – Processing of data
  • 3. Data Structures vs File Structures • Both involve: – Representation of Data + – Operations for accessing data • Difference: – Data structures: deal with data in the main memory – File structures: deal with the data in the secondary storage
  • 4. File Structure in Computer Science
  • 5. Data Storage in Computer
  • 6. Goal of the File Structures ● Minimize the number of trips to the secondary storage (SS) in order to get desired information. ● Group related information so that we are likely to get everything we new with fewer trip to the SS. ● Select the right file structures so that performance can be increased.
  • 7. File and File Operations ● A file is a collection of data stored on mass storage like hard disk, CD etc. ● File data consist of records (student information) and each record contains number of fields (ID, Name etc.). ● We can perform following operations on a file. – Search for a particular data in a file. – Add a certain data item. – Remove / Update a certain item.
  • 8. File and File operations – Order the data items according to a certain criterion, merge of files. – Creation of new files from existing files. – Finally create, open, and close operations which have implications in the operating system.
  • 9. Organization of Files ● Sequential ● Indexed ● Hashing
  • 10. Sequential File Organization ● Records are conceptually organized in a sequential list and can only be accessed sequentially. ● The actual storage might or might not be sequential (on tape or on disk)
  • 11. Sequential File (Write/Read in C++) ● Create ofstream object (after including file fstream.h at the top) ● Open file for output or for appending at the end of file. ● Test whether the file open operation of step 2 is successful. If not successful then exit else continue. ● Write / Read data to output file. ● Close file after writing / reading data.
  • 12. Sequential File Implementation ● #include <iostream.h> ● #include <fstream.h> ● #include <stdlib.h> ● ● Void main() { ● Int i, Roll[N] = { 171,717, 834, 394, 475 }; ● float Percentage[N]= {45.3, 84.5, 95.0, 48.2, 39.2 }; ● Char* Name[N] = {“wajid”, “Aashir”, “Luqman”, “Tushar”, “Waseem” }; ● // Step1: Create ofstream and ifstream objects ● Ofstream outFile; ifstream inFile; ● // Step 2: Open file for output ● outFile.open(“percent.dat”, ios::out); ● // Step 3 Test weather open operation is successful ● If (!outFile) { – cout<<”File could not open “; – Exit(1); ● Else – Cout<<”n File open successfullyn”; ● //Step 4: Write to file ● For( i=0; i<N; i++) – OutFile <<Name[i]<<' '<<Roll[i]<< ' ' <<Percentage[i]<<endl; ● cout<<”n File write successfully. n”; ● // Step 5: Close file ● outFile.close();
  • 13. Sequential File Implementation ● // Step 6 open file for input ● inFile.open(“percentage.dat”, ios::in); ● // Step 7: Test wether file open successfully. ● if(!inFile) { – cout<<”File could not open”<<endl; – Exit(1); ● } ● // Step 8: Read from input File ● While( inFile>> Name >>Roll >> Percentage) – cout<<setiosflags(ios::left)<<setw(14)<<roll <<setw(16)<<Name <<setw(9)<<Setprecision(4) – <<setiosflags(ios::showpoint | ios:: right) – <<percent<<'%'<< endl; ● //Step 9: Close file ● inFile.close(); }
  • 14. Sequential File Implementation ● OUTPUT: Roll Number Name Percentage 171 Wajid 45.30% 717 Aashir 84.50% 834 Luqman 95.00% 394 Tushar 48.20% 475 Waseem 39.20%
  • 15. Indexed File Organization ● Sequential search is even slower on disk/tape than in main memory. Try to improve performance using more sophisticated data structures. ● An index for a file is a list of key field values occurring in the file along with the address of the corresponding record in the mass storage. ● Typically the key field is much smaller than the entire record, so the index will fit in main memory.
  • 16. Indexed File Organization ... ● The index can be organized as a list, a search tree, a hash table, etc. To find a particular record: ● Search the index for the desired key. ● When the search returns the index entry, extract the record’s address on mass storage. ● Access the mass storage at the given address to get the desired record.
  • 18. Hashed File Organization ● A hashed file uses a hash function to map the key to the address. ● Eliminates the need for an extra file (index). ● There is no need for an index and all of the overhead associated with it.
  • 19. ● Use an array of M < N linked lists, good choice is M~ N/10 ● Hash: map key to integer i between 0 and M-1. ● Insert: put at front of ith chain (if not already there). ● Search: only need to search ith chain. Collusion Resolution (Separate Chaining)
  • 23. ● Use an array of size M >> N, good choice M~2N ● Hash: map key to integer i between 0 and M-1. ● Insert: put in slot i if free; if not try i+1, i+2, etc. ● Search: search slot i; if occupied but no match, try i+1, i+2, etc. Collusion Resolution (Open Addressing)