Managing Files of Records
Managing Files of Records
Direct Access
► How do we know where the beginning of the required record is?
 It may be in an Index (discussed in a different lecture)
Fundamental File Structure 5
►Sequential Search
– Look at records sequentially until matching record is found.
Time is in O(n) for n records.
– Appropriate for Pattern matching, file with few records
►Direct Access
– Being able to seek directly to the beginning of the record. Time
is in O(1) for n records.
– Possible when we know the Relative Record Number (RRN):
First record has RRN 0, the next has RRN 1, etc.
– Fixed-length record.
► File Access issues
– Direct Access.
– Sequential Access
► File organization depends on what use you want to make of the file.
►Metadata
Metadata
►Data About Data
– Usually in the form of a file header
Fundamental File Structure 5
– Example in text
• Astronomy image storage format
– Where in the sky the image from?
– When it was made?
– …..
• HTML format (name = value)
– FITS (Flexible Image Transport System)
• A stander which developed by the international Astronomer’s
Union.
• 2880 byte blocks of 80-byte ASCII records.
• Each record contains a single piece of metadata.
• See page 177.
CIS 256 (File Structures) 30
Metadata
►Parsing this kind of data
– Read field name; read field value
Fundamental File Structure 5
More Metadata
►Graphics Storage Formats
– Data
Fundamental File Structure 5
File Portability
» PC stores the low order byte flowed by the high order (2000).
» SUN stores the high order byte flowed by low order byte (0020).
• Word size may affect file layout
– For a struct item, may allocate:
» 8-bytes (64-bit word)
» 4-bytes (32-bit word)
» 3-bytes (24-bit word)
– Different encodings for text
• ASCII
• EBCDIC
• Maybe other problems with international languages
– IEEE standard
» Specifies format for 32, 64, & 128-bit floating point
» Specifies format for 8, 16, &32-bit integers
» Most computers follow
– XDR (External Data Representation)
» External Data Representation
» Specifies IEEE formats
» Also provides routines to convert to/from XDR format
and host machine format
IBM IBM
Vax Vax
Cray Cray
Fundamental File Structure 5
Sun 3 Sun 3
IBM PC IBM PC
IBM IBM
Vax Vax