HW3 Hex View Inheritance Constructors/Destructors

Slides:



Advertisements
Similar presentations
Review of Inheritance. 2 Several Levels of Inheritance Base Class B Derived class D Derived class D1.
Advertisements

Chapter 13 Hash Tables Section 13.4 CS 257 Dr. T.Y.Lin Abhishek Pandya ID
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
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.
Lecture 22 Miscellaneous Topics 4 + Memory Allocation.
CSE 425: Object-Oriented Programming II Implementation of OO Languages Efficient use of instructions and program storage –E.g., a C++ object is stored.
Chapter 9 Defining New Types. Objectives Explore the use of member functions when creating a struct. Introduce some of the concepts behind object-oriented.
1 Inheritance We are modeling the operation of a transportation company that uses trains and trucks to transfer goods. A suitable class hierarchy for the.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
DATA STRUCTURES LAB 1 TA: Nouf Al-harbi
Week 14 - Monday.  What did we talk about last time?  Introduction to C++  Input and output  Functions  Overloadable  Default parameters  Pass.
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.
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.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Module 9: Operator overloading #1 2000/01Scientific Computing in OOCourse code 3C59 Module 9: Operator Overloading In this module we will cover Overloading.
Hidden Slide for Instructor
EGR 2261 Unit 11 Pointers and Dynamic Variables
Values vs. References Lecture 13.
Linear Algebra Review.
User-Written Functions
EGR 2261 Unit 10 Two-dimensional Arrays
CSC201: Computer Programming
Hash table CSC317 We have elements with key and satellite data
Damned if you do and Damned if you don’t
Z502 File System Contains: Disk Structure Description System Calls
EGR 2261 Unit 4 Control Structures I: Selection
A “Walk Through” Experiment
Object-Oriented Programming & Design Lecture 18 Martin van Bommel
Slide design: Dr. Mark L. Hornick
Chapter 5 Classes.
CMPE 135: Object-Oriented Analysis and Design October 17 Class Meeting
Dictionaries, File operations
Web Server Design Assignment #4: Authentication
Arrays in C.
Intro to PHP & Variables
Dynamic Hashing.
void Pointers Lesson xx
CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors
Strings, Line-by-line I/O, Functions, Call-by-Reference, Call-by-Value
CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors
Slide design: Dr. Mark L. Hornick
Concurrency Wrap-Up & Final Review
CS-150 Computing for Business Students Final Exam Review
Personalize Practice with Accelerated Math
Fundamentals of Data Representation
Functions Pass By Value Pass by Reference
Data Science Meetup Matthew Renze Data Science Consultant
SUPER SUCCESS SERIES TIME MANAGEMENT VOL. 1
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
A Useful Footnote Martha Cox Population Health Research Unit Community Health & Epidemiology Dalhousie University Good morning. We've all had this happen:
BIT 115: Introduction To Programming
BIT116: Scripting Radio Buttons.
Lab4 problems More about templates Some STL
Managing 2D Arrays Simple Dynamic Allocation
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
FM2 Section A Planning Workshop
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:

HW3 Hex View Inheritance Constructors/Destructors CSE 333 – Section 7 HW3 Hex View Inheritance Constructors/Destructors 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 (if we get to it) 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.

Hex View Find a hex editor. Learn ‘goto offset’ command. See HW3 pictures. 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. Any questions on network order? 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. 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

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 (As a V-table sneak peek!)

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; } Alright, now let’s do two exercises, 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! Now let’s do it for this one