1 / 84

Univerzální B-stromy (UB-Stromy)

Univerzální B-stromy (UB-Stromy). V ícerozměrná přístupová metoda. Rudolf Bayer. Michal Krátký, michal.kratky@vsb.cz http://www.cs.vsb.cz/kratky. Obsah. Úvod Vícerozměrná data Principy UB-stromů Algoritmus vkládání bodu Algoritmus výpočtu Z-adresy Algoritmus rozsahového dotazu

shima
Download Presentation

Univerzální B-stromy (UB-Stromy)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Univerzální B-stromy (UB-Stromy) Vícerozměrná přístupová metoda Rudolf Bayer Michal Krátký, michal.kratky@vsb.cz http://www.cs.vsb.cz/kratky

  2. Obsah • Úvod • Vícerozměrná data • Principy UB-stromů • Algoritmus vkládání bodu • Algoritmus výpočtu Z-adresy • Algoritmus rozsahového dotazu • Práce s nebodovými objekty • Složitosti algoritmů, výhody

  3. Úvod • UB-strom je vícerozměrná přístupová metoda • autorem je Rudolf Bayer, další výzkum Volker Markl • Využívá Z-uspořádání a B-stromů

  4. Vícerozměrná data • Kartézským součinem domén atributů vznikne vícerozměrný prostor • n-tice (řádek, tuple, entita, objekt) je bodem v n-dimenzionálním prostoru a je takto indexován • Prostorová blízkost umožňuje shlukování těchto bodů pro uložení na diskové stránky => snížení počtu přístupů na disk => rychlejší operace • Využití v data warehousingu, GIS, ...

  5. Z-uspořádání Pro x ÎW a binární reprezentaci každého atributu xi= x i,s-1 x i,s-2 ... x i,0 definujeme Z-hodnotuZ(x): • Z(x) počítá pro každou n-tici Z-adresu (tj. jeho pozici na Z-křivce) • Z-hodnoty jsou efektivně počítány tzv. bitovým prokládáním (bit-interleaving)

  6. Z-uspořádání pro univerzum 8x8 0 1 2 3 4 5 6 7 0 1 4 5 16 17 20 21 0 2 3 6 7 18 19 22 23 1 8 9 12 13 24 25 28 29 2 10 11 14 15 26 27 30 31 3 32 33 36 37 48 49 52 53 4 34 35 38 39 50 51 54 55 5 40 41 44 45 56 57 60 61 6 42 43 46 47 58 59 62 63 7 (a) (b)

  7. Z-regiony/UB-stromy 4 20 Z-region [4 : 20] UB-Stromové dělení: [0 : 3],[4 : 20], [21 : 35], [36 : 47], [48 : 63] Z-region [a :b ]je prostor pokrytý intervalem na Z-křivce.

  8. UB-strom V uzlu B-stromu jsou uloženy adresy Z-regionů UB-index UB-soubor V listech B-stromu jsou uloženy n-tice náležící k danému Z-regionu

  9. Algoritmus vkládání bodu Vstup: x: bod, který má být vložen do UB-Stromu Výstup: žádný x = Z(x) find [a : g] in the UB-Tree, such that a Łx Ł g retrieve page(a : g) insert x into page(a : g) if count(a : g) > C choose bÎ[a : g], so that ½C - e Ł count(a : b) Ł ½C + e split page(a : g) into page(a : b) and page(b + 1 : g) end if

  10. Ukázka vkládání bodů

  11. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  12. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  13. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  14. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  15. Po vložení dalších dvou bodů ...

  16. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  17. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  18. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  19. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  20. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  21. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  22. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  23. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  24. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  25. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  26. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  27. UB-Strom UB-Strom B-Strom B-Strom Z-adresa Z-adresa

  28. UB-Strom UB-Strom B-Strom B-Strom Z-adresa Z-adresa

  29. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  30. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  31. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  32. Po vložení dalších bodů obsahuje UB-strom 5 Z-regionů ..

  33. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  34. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  35. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  36. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  37. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  38. A po vložení dalších bodů ...

  39. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  40. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  41. Zdrojový kód UB-Strom Insert(Tuple tuple) { Zaddress za = Z(tuple); BtreeInsert(za, tuple); } Ubvalue findSplitPoint(Tuple t1, Tuple t2) { /* nalezení optimální Z-adresy mezi t1 a t2 */ } B-Strom Z-adresa

  42. Výpočet Z-adresy

  43. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 1 0 0 1 0 1 1 0 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 _ _ _ _ _ _ _ _ _ _ Z-adresa

  44. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 1 0 0 1 0 1 1 0 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 _ _ _ _ _ _ _ _ _ _ Z-adresa

  45. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 10 0 1 0 1 1 0 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 0 _ _ _ _ _ _ _ _ _ _ Z-adresa

  46. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 10 0 1 0 11 0 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 0 1 _ _ _ _ _ _ _ _ _ _ Z-adresa

  47. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 100 1 0 11 0 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 0 1 0 _ _ _ _ _ _ _ _ _ _ Z-adresa

  48. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 100 1 0 110 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 0 1 0 0 _ _ _ _ _ _ _ _ _ _ Z-adresa

  49. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 1001 0 110 0 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 0 1 0 0 1 _ _ _ _ _ _ _ _ _ _ Z-adresa

  50. (25,18) Zdrojový kód UB-strom Zaddress Z(Tuple tuple) { Zaddress za = 0; int pos = 0, bit ; for (bit = 0; bit < maxbits(tuple); bit++) { foreach attribute of tuple do { if (attribute[bit] exists) { if (attribute[bit] is set) ZaddressSetBit(&za, pos); pos++; } } } return za; } Atribut 1 Atribut 2 Z-adresa Atribut 2 Atribut 1 _ _ _ _ _ 1001 0 1100 1 _ _ _ _ _ Bitové řetězce _ _ _ _ _ _ _ _ _ _ 1 1 0 1 0 0 1 0 _ _ _ _ _ _ _ _ _ _ Z-adresa

More Related