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

Slides:



Advertisements
Similar presentations
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Advertisements

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.
Internet Skills An Introduction to HTML Alan Noble Room 504 Tel: (44562 internal)
Lecture 22 Miscellaneous Topics 4 + Memory Allocation.
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.
CSE 451 – Operating Systems Section, Autumn 2003 TAs: Mike Swift Adrienne Noble
Variables, Primitives, and Objects A Visual Learner’s Guide.
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.
Homework due Test the random number generator Create a 1D array of n ints Fill the array with random numbers between 0 and 100 Compute and report the average.
Chapter 3 Working with Batches of Data. Objectives Understand vector class and how it can be used to collect, store and manipulate data. Become familiar.
Chapter 8 File Systems FAT 12/16/32. Defragmentation Defrag a hard drive – Control Panel  System and Security  Administration tools  Defrag hard drive.
Day One Every Day per lb You will have 15 minutes to work with your partner to help me solve my problem. Then you will have another 10 minutes.
Database Management 7. course. Reminder Disk and RAM RAID Levels Disk space management Buffering Heap files Page formats Record formats.
Hidden Slide for Instructor
EGR 2261 Unit 11 Pointers and Dynamic Variables
Values vs. References Lecture 13.
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
User-Written Functions
CS/COE 0447 (term 2181) Jarrett Billingsley
CSC207 Fall 2016.
EGR 2261 Unit 10 Two-dimensional Arrays
CSE 326: Data Structures Lecture #8 Pruning (and Pruning for the Lazy)
Hash table CSC317 We have elements with key and satellite data
Development and Testing Ch4.1. Algorithm Analysis
LEARNING OBJECTIVES O(1), O(N) and O(LogN) access times. Hashing:
Z502 File System Contains: Disk Structure Description System Calls
Ch. 8 File Structures Sequential files. Text files. Indexed files.
Secondary Storage Management 13.5 Arranging data on disk
EGR 2261 Unit 4 Control Structures I: Selection
Chapter 11: File System Implementation
A “Walk Through” Experiment
Object-Oriented Programming & Design Lecture 18 Martin van Bommel
Slide design: Dr. Mark L. Hornick
HW3 Hex View Inheritance Constructors/Destructors
CMPE 135: Object-Oriented Analysis and Design October 17 Class Meeting
Arrays in C.
Intro to PHP & Variables
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Dynamic Hashing.
Strings, Line-by-line I/O, Functions, Call-by-Reference, Call-by-Value
Chapter 11: File System Implementation
Lesson 2: Building Blocks of Programming
CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors
Secondary Storage Management 13.5 Arranging data on disk
Chapter 11: File System Implementation
Concurrency Wrap-Up & Final Review
CS-150 Computing for Business Students Final Exam Review
Functions Pass By Value Pass by Reference
EECS 373 Advanced Embedded Systems
What Should I Do About Worries?
EECS 473 Advanced Embedded Systems
Jeff West - Quiz Section 8
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
Jeff West - Quiz Section 9
Homework Reading Programming Assignments Finish K&R Chapter 1
Module 12a: Dynamic Hashing
BIT 115: Introduction To Programming
Chapter 11: File System Implementation
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
Hash-Based Indexes Chapter 11
What Should I Do About Worries?
References Revisted (Ch 5)
CMPE212 – Reminders Assignment 2 due next Friday.
CS 144 Advanced C++ Programming March 21 Class Meeting
CSE 326: Data Structures Lecture #14
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. Normally we would’ve done these slides the week before but since you guys just had a midterm we decided to lay it off until now.

Section Feedback This class should be taught entirely in Spanish! Just kidding! :) More: Jokes Spanish Candy Exam/Exercise Type Problems HW tips Less: Bad jokes WRITE BIGGER/CLEARER/THE BOARD IS HARD TO READ (5 min) Haha… And by far the biggest feedback received was.... Also, I had someone asking about the slides not being in depth enough. Here’s a tip: Download the .pptx files as I have notes written for most of them. Anyways, let’s talk about tips and tricks (see? I’m already starting to apply the feedback!) on debugging the homework due tonight using Hex View!

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 iwe 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!