CIS 402: File Management Techniques Chapter 5

1770 days ago, 788 views
PowerPoint PPT Presentation
2. Part Objectives. Broaden the record structure ideas of Chapter 4:Search keys and sanctioned formsSequential pursuit and Direct get to Files get to and document organizationExamine different sorts of the record structures regarding Abstract information modelsMetadataObject-arranged document accessExtensibilityExamine issues of convenientce and institutionalization..

Presentation Transcript

Slide 1

CIS 402: File Management Techniques Chapter 5 Managing Files of Records

Slide 2

Chapter Objectives Extend the document structure ideas of Chapter 4: Search keys and accepted structures Sequential hunt and Direct get to Files get to and record association Examine different sorts of the record structures as far as Abstract information models Metadata Object-arranged document get to Extensibility Examine issues of versatility and institutionalization.

Slide 3

Record Access Record Key Canonical frame : a standard type of a key e.g. Ames or ames or AMES (require transformation) Distinct keys : interestingly recognize a solitary record Primary keys, Secondary keys, Candidate keys Primary keys ought to be dataless (not updatable) Primary keys ought to be perpetual Social-securiy-number: great essential key be that as it may, 999-99-9999 for all non-enlisted outsiders Measurement of work: Comparisons: happen in fundamental memory Disk gets to : principle bottleneck

Slide 4

Sequential Search Sequential inquiry is minimum productive. Our principle interest for the length of the term is to introduce enhanced inquiry techniques O (n), n : the quantity of records Use record hindering to lessen work A square of a few records fields < records < pieces O(n), however blocking diminishes the quantity of look for consecutive inside each square e.g.- 4000 records, 512 bytes every, area measure 512 bytes Unblocked (part estimated cradles): 512 (½K support) => normal 2000 READ() calls Blocked (16 recs/square) : 8K estimate cushion => normal 125 READ() calls Can additionally enhance execution by utilizing square key containing last record key to abstain from seeking inside squares where information can't be

Slide 5

Sequential Search: Best Uses UNIX successive handling charges feline, wc, grep When is Sequential Search Superior? Redundant hits Searching for examples in ASCII documents Searching records with a specific auxiliary key esteem Small Search Set Processing records with few records Devices/media most cordial to consecutive get to tape twofold record on plate

Slide 6

Direct Access a record without looking O(1) operation RRN ( R elative R ecord N umber ) Gives relative position of the record O(n) handle with variable-length records Easy with settled length records: RRN*sizeof(record) View document as accumulation of records, not bytes; all byte information is interior Byte balance = N X r : record measure n : RRN esteem Class IOBuffer incorporates coordinate read (DRead) coordinate compose (DWrite) take byte balance as contention, alongside stream utilize polymorphism to pick remedy Read/Write fns.

Slide 7

OHIO 10847115 7264.9 4133035 3 1180317COLUMBUS OHIO|10847115|7|264.9|41330|35|3|1|1803|17|COLUMBUS\0....\0 Choosing Record Length and Structure Record length is identified with the measure of the fields Access versus fragmentaion versus execution Fixed length record settled length fields variable-length fields Unused space segment is loaded with invalid character in C e.g. delimited

Slide 8

Header Records File as a Self-Describing Object General data about document date and time of late refresh, number of records size of record, fields (settled length record & field) delimiter (variable-length field) Often set toward the start of the document Pascal did not actually bolster header records (File is a rehashed accumulation of a similar sort) Use variation records (contingent upon setting) In C: union polymorphic structure

Slide 9

Abstract base class for record cradles class IOBuffer open : virtual int Read( istream & ) = 0;/read a support from the stream virtual int Write( ostream &) const = 0;/compose a cushion to the stream/these are the immediate get to peruse and compose operations virtual int DRead( istream &, int recref );/read indicated record virtual int DWrite( ostream &, int recref ) const;/compose determined record/these header operations give back the extent of the header virtual int ReadHeader ( istream & ); virtual int WriteHeader ( ostream &) const; ensured : int Initialized ;/TRUE if cushion is introduced scorch *Buffer;/character exhibit to hold handle values IO Buffer Class definition

Slide 10

IO Buffer Class definition Full meaning of support class chain of importance WriteHeader technique : composes the header string toward the start of the record. Conceivable strings: "Variable" "Settled" Returns size of header composed ReadHeader technique : peruses the header id string. Must be the normal record sort, variable or settled length If the string matches that subclass' header string, returns size of header some other string causes return of –1  header doesn't coordinate cradle DWrite/DRead strategies : works utilizing the byte address of the record as the record reference. Strategies start by looking to the asked for spot.

Slide 11

Encapsulating Record I/O Operations in a Single Class Good plan for making objects tenacious give operation to peruse and compose questions specifically Write operation up to this point : two operations : pack into a cushion compose the cradle to a document Class "RecordFile" underpins a compose operation that takes a protest and composes it to a record. utilization of cushions is embodied inside the class must be summed up, as it is worked with a nonexclusive sort

Slide 12

Encapsulation Record: I/O Operation in a Single Class "RecordFile" utilizes C++ layout elements to wind up distinctly non specific meaning of the format class RecordFile format <class RecType> class RecordFile : open BufferFile { open: int Read(RecType& record, int recaddr = - 1); int Write(const RecType& record, int recaddr=-1); RecordFile(IOBuffer& support) : BufferFile(buffer) { };

Slide 13

/layout strategy bodies format <class RecType> int RecordFile<RecType>::Read ( RecType &record, int recaddr) { int writeAdd, result; writeAddr = BufferFile::Read (recaddr); if (!writeAddr) return - 1; result = record.Unpack(Buffer); if (!result) return - 1; return writeAddr; } format <class RecType> int RecordFile<RecType>::Write (const RecType &record, int recaddr) { int result; result = record . Pack (Buffer); if (!result) return - 1; return BufferFile::Write (recaddr); }

Slide 14

File Organization File Access Variable-length Records Sequential get to Fixed-length records D irect get to File Access and File Organization There is distinction between document get to and record association. Variable-length records Sequential get to is reasonable Fixed-length records Direct get to and consecutive get to are conceivable Note: Book references to Pascal are totally out of date. It is surprising in present-day programming dialects to be not able openly move inside a record

Slide 15

Abstract Data Model Data protest, for example, report, pictures, sound e.g. pictures, sound Abstract Data Model does not see information as it shows up on a specific medium. application-arranged view application protected from subtle elements of capacity on medium How to determine a document's substance? Headers and Self-depicting records e.g. pictures: jpg: ÿøÿà JFIF gif: GIF89a e.g. sounds: mp3: ÿûD EQ¹à wav: RIFF$P WAVEfmt

Slide 16

Metadata Data that portray the essential information in a document e.g. <Meta> in html Store in the header record Standard configuration As appeared on past slide

Slide 17

Mixing object Types in a document Each field is distinguished utilizing "catchphrase = esteem" Index table with labels e.g.

Slide 18

Object-arranged record get to Separate meaning and from the physical organization and application ( portrayal free document get to) give a capacity to deal with get to (OO style) typify subtle elements read_image() is picture record sort autonomous; technique decides record sort Program find_star : read_image("star1", picture) handle picture : end find_star picture : star1 star2 RAM Disk

Slide 19

Extensibility Advantage of utilizing labels Identify protest inside records don't require from the earlier learning of the sorts of items New kind of question execute strategy for perusing and writing in suitable module (isolate concerns) call the strategy.

Slide 20

Factor influencing Portability Differences among working frameworks e.g. CR/LF in DOS Differences among dialects physical design of records might be compelled by dialect restriction Differences in machine structures byte arrange: e.g. Unix: hton, ntoh Differences on stages e.g. EBCDIC versus ASCII

Slide 21

Achieving Portability Standardization Standard physical record design extensible, basic Standard twofold encoding for information components IEEE, XDR File structure transformation Number and content change Established, surely understood techniques for change

Slide 22

Achieving Portability File framework contrast Block size is 512 bytes on UNIX frameworks Block size is 2880 bytes on numerous non-UNIX frameworks UNIX and Portability UNIX bolster transportability by being regularly accessible on an expansive number of stages UNIX gives an utility called dd : encourages information change