120 likes | 267 Views
One Pass Algorithm Presented By: Pradhyuman raol ID : 114. Instructor: Dr T.Y. LIN. Agenda . One Pass algorithm Tuple-at-a-Time Unary Operators Binary Operations. One-Pass Algorithms . One Pass Algorithm: Some methods involve reading the data only once from disk.
E N D
One Pass Algorithm Presented By: Pradhyuman raol ID : 114 Instructor: Dr T.Y. LIN
Agenda • One Pass algorithm • Tuple-at-a-Time • Unary Operators • Binary Operations
One-Pass Algorithms • One Pass Algorithm: • Some methods involve reading the data only once from disk. • They work only when at least one of the arguments of the operation fits in main memory.
Tuple-at-a-Time • We read the blocks of R one at a time into an input buffer, perform the operation on the tuple, and more the selected tuples or the projected tuples to the output buffer. • Examples: Selection & Projection
Tuple at a time Diagram R Unary operator Input buffer Output buffer
Unary Operators • The unary operations that apply to relations as a whole, rather than to one tuple at a time. • Duplicate Elimination d(R) :Check whether that tuple is already there or not. M= Main memory B(d(R))= Size of Relation R Assumption: B(d(R)) <= M
Unary Operators • Grouping : A grouping operation gives us zero or more grouping attributes and presumably one or more accumulated value or values for each aggregation. • Min or Max • Count – For any count aggregation, add one for each tuple of the group that is seen. • Sum- add the value of attribute a to the accumulated sum for its group provided, a is not NULL. • Average
Binary Operations • Set Union- We read S into M-1 buffers of main memory and build a search structure whose search key is the entire tuple. • Set Intersection- Read S into M-1 buffers and build a search structure with full tuples as the search key.
Continued… Set Difference Bag Intersection Bag Difference Product Natural Join- To compute the Natural Join we have to do the following: 1.Read all the tuples of S form them into a main memory search structures with the attributes of Y as the search key. Use M-1 block of memory for this purpose.
Continued… 2. Read each block of R into the one remaining main memory buffer. For each tuple t of R, find the tuples of S that agree with t on all attributes of Y, using the search Structure. For each matching tuple S, form a tuple by joining it with t, and move the resulting tuple to the output.