Presentation is loading. Please wait.

Presentation is loading. Please wait.

A. Frank File Organization Building on the Stream Model Thanks to Adi Gutman and Noa Cohen.

Similar presentations


Presentation on theme: "A. Frank File Organization Building on the Stream Model Thanks to Adi Gutman and Noa Cohen."— Presentation transcript:

1 A. Frank File Organization Building on the Stream Model Thanks to Adi Gutman and Noa Cohen

2 2 A. Frank How to build on the Stream Model? What about other operations - –More basic? Rest complex? Meta-operations? Add position of unit as a parameter. Refer to Segment of units. Add file descriptor. Need for two pointers (both read and write pointers)? Model other file models/structures?

3 3 A. Frank append(buf) = seek(n); insert(buf) n - 1 0 12 i = 1 buf 0 n - 1 0 12 i = n buf 1 n 0 12 i = n buf 2 append(buf) ).nסיפוח מוסיף יחידה לסוף הקובץ (במקום ה-

4 4 A. Frank delete(); (prepare buf) insert(buf) 0 2 i = 1 buf n -1 1 3 replace()/overwrite() החלפה משנה לגמרי את היחידה הנוכחית. 0 1 i = 1 buf n - 2 2 n - 1 0 12 i = 1 buf 0 1 0 1 i = 1 buf n - 2

5 5 A. Frank b uf := fetch(); delete(); (update buf) insert(buf) n - 1 0 12 i = 1 buf 0 n - 1 0 12 i = 1 buf 1 0 1 i = 1 buf n - 2 2 0 2 i = 1 buf n -1 1 4 update(buf) עדכון משנה את התוכן של היחידה הנוכחית. 0 1 i = 1 buf n - 2 3

6 6 A. Frank buf := fetch(j) = seek(j); buf := fetch(); j -1 0 i i i+1 j buf 0 j -1 0 i i i+1 j buf 1 j -1 0 i i i+1 j buf 2 buf:=fetch(j)

7 7 A. Frank insert(buf, j) = seek(j); insert(buf); j -1 0 i i j buf 0 j -1 0 i i j j +1 buf 2 j -1 0 i i j buf 1 insert(buf, j)

8 8 A. Frank delete(j) = seek(j); delete(); j 0 i i j+1 0 0 i i 1 j 0 i i j 2 delete(j)

9 9 A. Frank buf := fetch(i); insert(buf, j) (i = i) buf := fetch(i); delete(i); insert(buf, j-1) copy(i, j): העתקה move(i, j): הזזה swap(i, j): חילוף More complex operations? שילוב מושכל של פעולות ?move compare(i, j): השוואה איך להסתדר עם buf אחד ?

10 10 A. Frank var buffer: SEGMENT; (* a sequence of units … * ) len: POSITION; (* of length len *). buffer := fetch(j, len); insert(buffer, j, len); delete(j, len); Refer to Segment of units פעולות על מקטע (Segment) של יחידות.  for i := j to j+len-1 do … end;

11 11 A. Frank What about Meta-Operations ? פעולות-על: Meta- Operations: Create – יצירה Open – פתיחה Close – סגירה Rename – שינוי שם Destroy – מחיקה פעולות-על הם מחוץ למודל. הם עובדים על הקובץ כולו ולא על יחידות הקובץ עצמם.

12 12 A. Frank Add File Descriptor גישה להרבה תזרימים (קבצים) ע"י שימוש במזהי קובץ. var fd: FILE; (* fd = File Descriptor *) buffer := fetch(fd, j, len); insert(fd, buffer, j, len); delete(fd, j, len); מזהי קובץ הם מחוץ למודל. הם מתייחסים לקובץ כולו ולא ליחידות הקובץ עצמם.

13 13 A. Frank One Read pointer and one Write pointer. Different positions at file opening. Depends on open mode (Read, Write, Update). Need for Two Pointers? Read pointer i = 0 Write pointer i = n אפשר למדל שני מצביעים r, w ולהשתמש בהם מעל למודל עם seek.

14 14 A. Frank Model other file models/structures? Each sub-file (of a complicated file structure) can be modeled by one stream. All streams together form the complex file model/system. Modeling UNIX Streams (sequence of bytes) is most natural. Relation to C++ Streams? Relation to Communication Streams?


Download ppt "A. Frank File Organization Building on the Stream Model Thanks to Adi Gutman and Noa Cohen."

Similar presentations


Ads by Google