190 likes | 370 Views
Representing Block and Record Addresses. Rajhdeep Jandir ID: 103. Agenda. Background Client-Server Systems Logical and Structured Addresses Pointer Swizzling. Background.
E N D
Representing Block and Record Addresses Rajhdeep Jandir ID: 103
Agenda • Background • Client-Server Systems • Logical and Structured Addresses • Pointer Swizzling
Background • Need to know about second storage address representation to see how the addresses, pointers, or references to records and blocks can be represented • In secondary storage: sequence of byted describes the location of the block within the overall system of data accessible to the DBMS. • Record can be found by giving its block and offset of the first byte of the record within the block.
Client-Server Systems • A db consists of server that provides data from secondary storage to client process • Client-Server process can be on one machine or on multiple machines
Client-Server Systems Contd. • Client applications use “virtual” address space: • Typically 32 bits or 4 billion different addresses • OS or DBMS decides which part of the address space are currently located in MM and hw maps VA space to physical location in MM • For us think of client address space as MM
Client-Server Systems Contd. • There are two ways that addresses of the server’s data can be represented: • Physical Addresses • Logical Addresses
Client-Server Systems Contd. • Physical Address: • Byte strings used to determine where the block or record is in the secondary storage • One or more bytes of the string are used to indicate the following 6 things
Client-Server Systems Contd. • The host to which the storage is attached to • An identifier to recognize which block is the data on • The cylinder number on the disk • The track number of the disk • The block number of the track • The offset of the beginning of the record within the block (some cases)
Client-Server Systems Contd. • Logical Addresses: • Each block/record has a “logical address” which is an arbitrary string of bytes of some fixed length. • Map Table: In a disk in a known location • Map Table relates logical to physical addresses
Client-Server Systems Contd. • Physical Addresses are long – 8 bytes minimum and can be as long as 16 bytes. • Ex. A db lasts 100 years and may grow to have 1 mil. machines and each machine can create an object every ns. As a result the system creates around 227 objects. This requires a min. of 10 bytes but need more bytes to represent the host, storage unit,…etc.
Logical and Structured Addresses • Purposes of a logical address: • By using a map table can easily move or delete the record to be changed • Structured address schemes are possible through combo of logical and physical addresses • Ex. Can use physical address for block and add key value for the record being referred to. To find the record, use physical address to get the block and find matching key
Logical and Structured Addresses Contd. • Can also have each block have an offset table that holds the offsets of the records within the block. • Table grows from the front and records placed from the back – this way we don’t have to allocate a fixed amount of block header initially
Logical and Structured Addresses Contd. offset table unused header record 4 record 3 record 2 record 1
Logical and Structured Addresses Contd. • Record address is now physical address of block plus offset entry in block’s offset table. • The advantages: • Can move the record around the block easily • Can move the record to another block if there is sufficient space • A tombstone is made in the position where the record has been deleted so that when a pointer goes there it can be replaced by a null pointer
Pointer Swizzling • Pointers/Addresses are for tuples that represent objects and not relations • OO db allow attributes of pointer type so that needs to be represented • Index structures are blocks which have pointers in them
Pointer Swizzling Contd. • Definitions: • Database Address: the data is in the secondary storage for the server’s db to access • Memory Address: address in virtual memory • Efficient to use MA when item has a pointer • DA time-consuming – need a translation table
Pointer Swizzling Contd. DA MA database address memory address
Pointer Swizzling Contd. • Note: • Logical and physical address represented in DA. MA in TT for copied of corresponding object in memory • All addressable items in db have entries in map table vs only items in memory are in TT
Pointer Swizzling Contd. • Pointer swizzling is a technique to avoid repeated translation from DA to MA • Move a block from MM pointers from block mey be “swizzled” – translated from DA space to VA space • Pointer has: • Bit: indicates if DA or SMA • Database or memory pointer