CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors

Slides:



Advertisements
Similar presentations
The FAT File System CSC 414. Objectives  Understand the structure and components of the FAT (12/16/32) File Systems  Understand what happens when a.
Advertisements

Lecture 12 Destructors “Absolute C++” Chapters 10.3, 15.2.
Chapter 13 Hash Tables Section 13.4 CS 257 Dr. T.Y.Lin Abhishek Pandya ID
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1 The first step in understanding pointers is visualizing what they represent at the machine level. In most modern computers, main memory is divided into.
CSE333 SECTION 7. Template vs Generics C++ templates are similar to preprocessor macros A template will be “materialized” into multiple copies with T.
CSE333 SECTION 7. Midterm Debrief Hex View 1. Find a hex editor. 2. Learn ‘goto offset’ command. 3. See HW3 pictures. The header: Magic word Checksum.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Data Structures Using C++ 2E Chapter 3 Pointers and Array-Based Lists.
SharePoint document libraries I: Introduction to sharing files Sharjah Higher Colleges of Technology presents:
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Week 14 - Monday.  What did we talk about last time?  Introduction to C++  Input and output  Functions  Overloadable  Default parameters  Pass.
COMPUTER PROGRAMMING. Functions’ review What is a function? A function is a group of statements that is executed when it is called from some point of.
CSCI-383 Object-Oriented Programming & Design Lecture 18.
March 23 & 28, Csci 2111: Data and File Structures Week 10, Lectures 1 & 2 Hashing.
Structure Programming Lecture 8 Chapter 5&6 - Function – part I 12 December 2015.
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
CSCI 156: Lab 11 Paging. Our Simple Architecture Logical memory space for a process consists of 16 pages of 4k bytes each. Your program thinks it has.
CSE 332: C++ pointers, arrays, and references Overview of Pointers and References Often need to refer to another object –Without making a copy of the object.
Chapter 8 File Systems FAT 12/16/32. Defragmentation Defrag a hard drive – Control Panel  System and Security  Administration tools  Defrag hard drive.
File System Implementation
Bitwise Operations C includes operators that permit working with the bit-level representation of a value. You can: - shift the bits of a value to the left.
Hidden Slide for Instructor
Values vs. References Lecture 13.
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
CSC207 Fall 2016.
EGR 2261 Unit 10 Two-dimensional Arrays
CSC201: Computer Programming
CSE 326: Data Structures Lecture #8 Pruning (and Pruning for the Lazy)
CMSC201 Computer Science I for Majors Lecture 23 – Sorting
Hash table CSC317 We have elements with key and satellite data
Dynamic Hashing (Chapter 12)
Ch. 8 File Structures Sequential files. Text files. Indexed files.
Secondary Storage Management 13.5 Arranging data on disk
Chapter 11: File System Implementation
Object-Oriented Programming & Design Lecture 18 Martin van Bommel
Slide design: Dr. Mark L. Hornick
Chapter 5 Classes.
HW3 Hex View Inheritance Constructors/Destructors
CMPE 135: Object-Oriented Analysis and Design October 17 Class Meeting
Subject Name: File Structures
Arrays in C.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Dynamic Hashing.
CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors
Lesson 2: Building Blocks of Programming
Extendible Indexing Dina Said
Object Oriented Programming (OOP) LAB # 8
Slide design: Dr. Mark L. Hornick
Secondary Storage Management 13.5 Arranging data on disk
Chapter 11: File System Implementation
Concurrency Wrap-Up & Final Review
Indexing and Hashing Basic Concepts Ordered Indices
CH 9.2 : Hash Tables Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and.
Functions Pass By Value Pass by Reference
How to Run a Java Program
Jeff West - Quiz Section 9
Module 12a: Dynamic Hashing
Chapter 11: File System Implementation
Pointers and dynamic objects
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
Hash-Based Indexes Chapter 11
CMPE212 – Reminders Assignment 2 due next Friday.
CS 144 Advanced C++ Programming March 21 Class Meeting
Advance Database System
CSE 326: Data Structures Lecture #14
Chapter 5 File Systems -Compiled for MCA, PU
CSE 333 – Section 5 C++ (1m).
Presentation transcript:

CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors Static vs Dynamic Dispatch BEFORE STARTING WRITE THIS URL ON THE BOARD: cs.uw.edu/homes/jrios777/vimrc.txt Welcome to week 7 of the best 300-level course in the department! Today we’ll be discussing about going through HW3 using hexdump, Inheritance, and static vs Dynamic Dispatch.

Hex View Find a hex editor. Learn ‘goto offset’ command. See HW3 pictures. So in hw2 you created an in memory index that let you search through a given directory. One thing you’ll notice is that every time you started the search shell it’d take forever to start. Well, in HW3 you’re going to be writing out the index to disk in a serializable format such that we can reconstruct the hash table from the reading the file itself. Alright, so first is Hex View. What I mean by this is viewing the index file in hex as shown here. This can be useful for inspecting to see what’s wrong in the indices you generate. As you guys can see, each of the header makes up the first 16 bytes of the index file shown here with the magic word, checksum, doctable size and index size. The rest of the file, as you might guess are the doctable and index themselves. One thing you’ll notice here is that these bytes in the file are in big endian, i.e. they’re read from left to right. (e.g. 075d is actually 075d and not 5d070000) The reason for this is that we are writing the indices out in network byte order which happens to be big endian. You can imagine that in a world with big and little endian machines we needed a common format such that files like these indices could be shared from one computer to the other without worrying about byte ordering, which is why we’re using network order (big endian). Any questions on network order? TODO: Show toHostFormat() and toDiskFormat() in filelayout.h. When reading from the disk remember to convert to Host Format and when writing to disk remember to convert to Disk Format! The header: Magic word Checksum Doctable size Index size

Here are the commands for emacs and vim that let you view the hexdump. I’ve actually set up some extra stuff in my .vimrc specifically for this purpose if any of you vim users want to ask me afterwards or during office hours. My .vimrc is at the link on the board. I’ll show you guys some of my neat tricks for this For you emacs users… I’m sorry. All I know how to do is quit emacs when I accidentally open it

Hex View The doctable So! Let’s see how the doctable is laid out It’s a hashtable so we first write the number of buckets, and for each bucket write its length and position (within the file). (Next slides) Any questions on that so far? (Next slide) The doctable

Hex View As we can see from the same example, this bucket has 1024 buckets, and the bucket records themselves follow with each bucket’s length and position, and finally the buckets themselves at 2014, which is where the first bucket is located. (Some lines were omited) Bucket 0 as you can see has no buckets and is located at 2014. Bucket 1 has an element and starts at 2014 also. Can someone tell me why this is?? (CANDY) The next bucket is then located at 2031 after the second bucket! Questions? The doctable (part 1): Num buckets ( Chain len Bucket offset )*

Hex View After providing the records for each bucket we write out the buckets themselves which begin with all the positions of each element and is shortly followed by a doctable element that consists of the doc ID, docname length and filename itself. Any questions on this layout? The doctable

Hex View Going back to the same example, we saw that both the first and second buckets started at 2014. Of course bucket 0 is empty so at 2014 is actually the bucket info for bucket 1. This first bucket actually has 1 element as we can tell from the bucket record and inside the bucket it says element 0’s position is 2018, has docId 1, filename length of 15(0xf), and the filename itself is “small_dir/c.txt”, which indeed is 15 characters long. The doctable (part 2): ( (Element offset)n ( DocID Filename len Filename )n )*

Hex View Any questions on doctable and how it’s represented in the index files? The doctable

Hex View The index Next we have the index. You’ll notice that initially it looks almost identical to the doctable. Of course they’re both hash tables so it’s not really surprising to see bucket records and buckets. The key difference though is the values stored in buckets. Rather than storing a doc ID with its corresponding filename we are instead storing words with their corresponding DocID tables…. (Next slide) The index

Hex View The docID table … and the docID table itself is also just another hash table where the bucket elements are a list of positions of where the corresponding word appears in a given docID. Any questions? One of the things I like about this assignment is the amount of indirection you have to get through to get from reading the file to reading where the word “the” appears in docID 15 The docID table

Hex View Demo Demo: tinytree/ tiny.idx teeny.idx (10 min)

Inheritance Constructors/Destructors The derived class: Does not inherit any constructors. MUST call their base class constructor. Omission == calling the default constructor. Constructors resolve from base to derived. Destructors should be virtual ! Demo: destructex.cc and vtable.cc (7 min)

Section Exercise class B { public: B(int *k) : k_(k) { out("B::cons“); } void p() { out("B::p”); } virtual void q() { out("B::q“); } void operator=(B &rhs) { out("B::=“); } ~B() { out(“B::~”); } protected: int *k_; }; class Der : public B { Der() : B(new int(9)) { out("Der::cons“); } void p() { out("Der::p“); } virtual void q() { out("Der::q“); } void operator=(Der &rhs) { out("Der::=" ); } ~Der() { delete k_; out(“Der::~”); } void out(string s) { cout << s << endl; } void main() { B base(nullptr), *baseptr; Der der; base = der; base.p(); base.q(); baseptr = (B *) new Der; baseptr->p(); baseptr->q(); der.p(); der.q(); delete baseptr; } (8 min) Alright, now let’s do this exercise, I’ll give you guys a few minutes, pair up with somebody and figure out what this program will print out

Section Exercise void main() { B base(nullptr), *baseptr; Der der; base = der; base.p(); base.q(); baseptr = (B *) new Der; baseptr->p(); baseptr->q(); der.p(); der.q(); delete baseptr; } B::cons Der::cons B::= B::p B::q Der::q Der::p B::~ Der::~ Note that destructor behavior is undefined if not virtual! Here’s the solution!