10
README.md
@@ -55,12 +55,12 @@ We are working on a new version of the mini-lsm tutorial that is split into 3 we
|
||||
| 1.5 | Storage Engine - Read Path | ✅ | ✅ | ✅ |
|
||||
| 1.6 | Storage Engine - Write Path | ✅ | ✅ | ✅ |
|
||||
| 1.7 | Bloom Filter and Key Compression | ✅ | ✅ | ✅ |
|
||||
| 2.1 | Compaction Implementation | ✅ | 🚧 | 🚧 |
|
||||
| 2.1 | Compaction Implementation | ✅ | ✅ | ✅ |
|
||||
| 2.2 | Compaction Strategy - Simple | ✅ | 🚧 | 🚧 |
|
||||
| 2.3 | Compaction Strategy - Tiered | ✅ | 🚧 | |
|
||||
| 2.4 | Compaction Strategy - Leveled | ✅ | 🚧 | |
|
||||
| 2.5 | Manifest | ✅ | 🚧 | |
|
||||
| 2.6 | Write-Ahead Log | ✅ | 🚧 | |
|
||||
| 2.3 | Compaction Strategy - Tiered | ✅ | 🚧 | 🚧 |
|
||||
| 2.4 | Compaction Strategy - Leveled | ✅ | 🚧 | 🚧 |
|
||||
| 2.5 | Manifest | ✅ | 🚧 | 🚧 |
|
||||
| 2.6 | Write-Ahead Log | ✅ | 🚧 | 🚧 |
|
||||
| 2.7 | Batch Write + Checksum | | | |
|
||||
| 3.1 | Timestamp Key Encoding + New Block Format | | | |
|
||||
| 3.2 | Prefix Bloom Filter | | | |
|
||||
|
||||
@@ -2,4 +2,10 @@
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.caption {
|
||||
text-align: center;
|
||||
font-size: smaller;
|
||||
color: gray;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-5 170 704 599" width="704" height="599">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="-5 170 704 599" width="704" height="599">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="00-full-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="00-full-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>00-full-overview</title>
|
||||
<rect fill="white" x="-5" y="170" width="704" height="599"/>
|
||||
<g id="00-full-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 194 693 361" width="693" height="361">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 194 693 361" width="693" height="361">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -18,7 +18,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="00-lsm-read-flow" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="00-lsm-read-flow" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>00-lsm-read-flow</title>
|
||||
<rect fill="white" x="6" y="194" width="693" height="361"/>
|
||||
<g id="00-lsm-read-flow_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 245 693 273" width="693" height="273">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 245 693 273" width="693" height="273">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -13,7 +13,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="00-lsm-write-flow" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="00-lsm-write-flow" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>00-lsm-write-flow</title>
|
||||
<rect fill="white" x="6" y="245" width="693" height="273"/>
|
||||
<g id="00-lsm-write-flow_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 214 693 135" width="693" height="135">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 214 693 135" width="693" height="135">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -13,7 +13,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-01-frozen" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-01-frozen" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-01-frozen</title>
|
||||
<rect fill="white" x="6" y="214" width="693" height="135"/>
|
||||
<g id="week1-01-frozen_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 213 693 136" width="693" height="136">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 213 693 136" width="693" height="136">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-01-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-01-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-01-overview</title>
|
||||
<rect fill="white" x="6" y="213" width="693" height="136"/>
|
||||
<g id="week1-01-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 245 693 104" width="693" height="104">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 245 693 104" width="693" height="104">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-01-single" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-01-single" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-01-single</title>
|
||||
<rect fill="white" x="6" y="245" width="693" height="104"/>
|
||||
<g id="week1-01-single_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 213 693 136" width="693" height="136">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 213 693 136" width="693" height="136">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-02-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-02-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-02-overview</title>
|
||||
<rect fill="white" x="6" y="213" width="693" height="136"/>
|
||||
<g id="week1-02-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-5 245 704 524" width="704" height="524">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="-5 245 704 524" width="704" height="524">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-03-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-03-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-03-overview</title>
|
||||
<rect fill="white" x="-5" y="245" width="704" height="524"/>
|
||||
<g id="week1-03-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 245 693 480" width="693" height="480">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 245 693 480" width="693" height="480">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-04-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-04-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-04-overview</title>
|
||||
<rect fill="white" x="6" y="245" width="693" height="480"/>
|
||||
<g id="week1-04-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 170 693 236" width="693" height="236">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 170 693 236" width="693" height="236">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-05-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-05-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-05-overview</title>
|
||||
<rect fill="white" x="6" y="170" width="693" height="236"/>
|
||||
<g id="week1-05-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-5 461 784 308" width="784" height="308">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="-5 461 784 308" width="784" height="308">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="#7f8080">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-07-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-07-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-07-overview</title>
|
||||
<rect fill="white" x="-5" y="461" width="784" height="308"/>
|
||||
<g id="week1-07-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="-5 170 784 599" width="784" height="599">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="-5 170 784 599" width="784" height="599">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -13,7 +13,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week1-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week1-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week1-overview</title>
|
||||
<rect fill="white" x="-5" y="170" width="784" height="599"/>
|
||||
<g id="week1-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
141
mini-lsm-book/src/lsm-tutorial/week2-00-leveled.svg
Normal file
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="85 204 473 245" width="473" height="245">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
<path d="M 8 0 L 0 -3 L 0 3 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/>
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-00-leveled" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-00-leveled</title>
|
||||
<rect fill="white" x="85" y="204" width="473" height="245"/>
|
||||
<g id="week2-00-leveled_Layer_1">
|
||||
<title>Layer 1</title>
|
||||
<g id="Graphic_67">
|
||||
<rect x="119" y="288" width="150.5" height="112.974" fill="white"/>
|
||||
<path d="M 119 288 L 269.5 288 L 269.5 400.974 L 119 400.974 Z" stroke="gray" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4.0,4.0" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_47">
|
||||
<rect x="128.292" y="301.974" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.292" y="301.974" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 313.5)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_46">
|
||||
<text transform="translate(90 313.5)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="1278977e-18" y="15">L0</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_45">
|
||||
<rect x="128.5" y="353.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.5" y="353.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.5 365.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_43">
|
||||
<text transform="translate(90.208 365.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="1278977e-18" y="15">L1</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_42">
|
||||
<rect x="200.88684" y="406.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="200.88684" y="406.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(205.88684 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_41">
|
||||
<rect x="273.48168" y="406.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="273.48168" y="406.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(278.48168 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_40">
|
||||
<text transform="translate(90 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="1278977e-18" y="15">L2</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_39">
|
||||
<rect x="128.292" y="406.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.292" y="406.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_38">
|
||||
<rect x="346.07652" y="406.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="346.07652" y="406.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(351.07652 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Line_69">
|
||||
<line x1="159.69716" y1="204.974" x2="159.69716" y2="292.074" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_77">
|
||||
<rect x="200.88684" y="354.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="200.88684" y="354.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(205.88684 366.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_78">
|
||||
<rect x="340" y="348.5" width="217.5" height="52.474" fill="white"/>
|
||||
<path d="M 340 348.5 L 557.5 348.5 L 557.5 400.974 L 340 400.974 Z" stroke="gray" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4.0,4.0" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_79">
|
||||
<rect x="346.208" y="354.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="346.208" y="354.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(351.208 366.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_80">
|
||||
<rect x="416.5765" y="354.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="416.5765" y="354.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(421.5765 366.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_81">
|
||||
<rect x="486.5765" y="354.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="486.5765" y="354.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(491.5765 366.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Line_83">
|
||||
<line x1="269.5" y1="353.43125" x2="330.1692" y2="360.64243" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_84">
|
||||
<text transform="translate(280.708 319.526)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="0" y="15">Leveled Compaction</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_85">
|
||||
<text transform="translate(309 366.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="1278977e-18" y="15">L1</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_86">
|
||||
<rect x="418.67136" y="406.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="418.67136" y="406.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(423.67136 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_87">
|
||||
<rect x="490.67136" y="406.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="490.67136" y="406.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(495.67136 418.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.5 KiB |
113
mini-lsm-book/src/lsm-tutorial/week2-00-tiered.svg
Normal file
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="62 198 453 306" width="453" height="306">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
<path d="M 8 0 L 0 -3 L 0 3 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/>
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-00-tiered" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-00-tiered</title>
|
||||
<rect fill="white" x="62" y="198" width="453" height="306"/>
|
||||
<g id="week2-00-tiered_Layer_1">
|
||||
<title>Layer 1</title>
|
||||
<g id="Graphic_78">
|
||||
<rect x="119.09484" y="402.5" width="152.90516" height="53" fill="white"/>
|
||||
<path d="M 119.09484 402.5 L 272 402.5 L 272 455.5 L 119.09484 455.5 Z" stroke="gray" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4.0,4.0" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_67">
|
||||
<rect x="119" y="282.026" width="82" height="112.974" fill="white"/>
|
||||
<path d="M 119 282.026 L 201 282.026 L 201 395 L 119 395 Z" stroke="gray" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4.0,4.0" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_47">
|
||||
<rect x="128.292" y="296" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.292" y="296" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 307.526)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_46">
|
||||
<text transform="translate(67.792 307.526)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="0" y="15">Tier 2</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_45">
|
||||
<rect x="128.5" y="347.526" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.5" y="347.526" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.5 359.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_43">
|
||||
<text transform="translate(68 359.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="0" y="15">Tier 1</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_42">
|
||||
<rect x="200.88684" y="461.552" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="200.88684" y="461.552" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(205.88684 473.078)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_41">
|
||||
<rect x="273.48168" y="461.552" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="273.48168" y="461.552" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(278.48168 473.078)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_40">
|
||||
<text transform="translate(67.792 473.078)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="0" y="15">Tier 0</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_39">
|
||||
<rect x="128.292" y="461.552" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.292" y="461.552" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 473.078)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_38">
|
||||
<rect x="346.07652" y="461.552" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="346.07652" y="461.552" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(351.07652 473.078)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Line_23">
|
||||
<path d="M 201 343.76263 C 242.07873 348.44885 295.44256 353.9965 317.5 360.026 C 348.5 368.5 361.5 386.5 346.07652 411.5 C 339.0484 422.8919 311.6731 426.22056 281.90115 427.0682" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Line_69">
|
||||
<line x1="159.69716" y1="199" x2="159.69716" y2="286.1" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_76">
|
||||
<rect x="201.09484" y="407.526" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="201.09484" y="407.526" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(206.09484 419.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_74">
|
||||
<text transform="translate(68 419.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="0" y="15">Tier 3</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_73">
|
||||
<rect x="128.5" y="407.526" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.5" y="407.526" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.5 419.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_77">
|
||||
<text transform="translate(373.07893 377.763)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="0" y="15">Tiered Compaction</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.8 KiB |
68
mini-lsm-book/src/lsm-tutorial/week2-00-two-extremes-1.svg
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="85 277 517 177" width="517" height="177">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
<path d="M 8 0 L 0 -3 L 0 3 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/>
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-00-two-extremes-1" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-00-two-extremes-1</title>
|
||||
<rect fill="white" x="85" y="277" width="517" height="177"/>
|
||||
<g id="week2-00-two-extremes-1_Layer_1">
|
||||
<title>Layer 1</title>
|
||||
<g id="Graphic_47">
|
||||
<rect x="128.292" y="358.5" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.292" y="358.5" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 370.026)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_46">
|
||||
<text transform="translate(90 403.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="6394885e-19" y="15">L0</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_45">
|
||||
<rect x="143.5" y="409.5" width="254" height="17" fill="white"/>
|
||||
<rect x="143.5" y="409.5" width="254" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(148.5 408.776)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="107.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Line_69">
|
||||
<line x1="159.69716" y1="277.5" x2="159.69716" y2="348.6" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_70">
|
||||
<rect x="202" y="383" width="254" height="17" fill="white"/>
|
||||
<rect x="202" y="383" width="254" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(207 382.276)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="107.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_71">
|
||||
<rect x="128.292" y="436" width="473.208" height="17" fill="white"/>
|
||||
<rect x="128.292" y="436" width="473.208" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 435.276)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="216.644" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_72">
|
||||
<rect x="409" y="409.5" width="146" height="17" fill="white"/>
|
||||
<rect x="409" y="409.5" width="146" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(414 408.776)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="53.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_73">
|
||||
<rect x="466.8977" y="383" width="134.60232" height="17" fill="white"/>
|
||||
<rect x="466.8977" y="383" width="134.60232" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(471.8977 382.276)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="47.34116" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
122
mini-lsm-book/src/lsm-tutorial/week2-00-two-extremes-2.svg
Normal file
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="85 277 527 328" width="527" height="328">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
<path d="M 8 0 L 0 -3 L 0 3 Z" fill="currentColor" stroke="currentColor" stroke-width="1"/>
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-00-two-extremes-2" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-00-two-extremes-2</title>
|
||||
<rect fill="white" x="85" y="277" width="527" height="328"/>
|
||||
<g id="week2-00-two-extremes-2_Layer_1">
|
||||
<title>Layer 1</title>
|
||||
<g id="Graphic_85">
|
||||
<rect x="119.69716" y="527.5" width="491.30284" height="77" fill="white"/>
|
||||
<path d="M 119.69716 527.5 L 611 527.5 L 611 604.5 L 119.69716 604.5 Z" stroke="gray" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4.0,4.0" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_84">
|
||||
<rect x="119.69716" y="378.5" width="491.30284" height="108" fill="white"/>
|
||||
<path d="M 119.69716 378.5 L 611 378.5 L 611 486.5 L 119.69716 486.5 Z" stroke="gray" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="4.0,4.0" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_47">
|
||||
<rect x="128.292" y="391.526" width="62.81032" height="41.5" fill="white"/>
|
||||
<rect x="128.292" y="391.526" width="62.81032" height="41.5" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 403.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="11.445159" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_46">
|
||||
<text transform="translate(90 403.052)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="6394885e-19" y="15">L0</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Line_69">
|
||||
<line x1="159.69716" y1="277.5" x2="159.69716" y2="381.626" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_70">
|
||||
<rect x="128.292" y="456.724" width="81.708" height="17" fill="white"/>
|
||||
<rect x="128.292" y="456.724" width="81.708" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(133.292 456)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="20.894" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_74">
|
||||
<text transform="translate(90 456)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="6394885e-19" y="15">L1</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_75">
|
||||
<rect x="225.5" y="456.724" width="152" height="17" fill="white"/>
|
||||
<rect x="225.5" y="456.724" width="152" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(230.5 456)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="56.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_76">
|
||||
<rect x="390" y="456.724" width="125" height="17" fill="white"/>
|
||||
<rect x="390" y="456.724" width="125" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(395 456)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="42.54" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_77">
|
||||
<rect x="527.5" y="456.724" width="74" height="17" fill="white"/>
|
||||
<rect x="527.5" y="456.724" width="74" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(532.5 456)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="17.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_82">
|
||||
<rect x="129.292" y="569.146" width="55.208" height="17" fill="white"/>
|
||||
<rect x="129.292" y="569.146" width="55.208" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(134.292 568.422)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="7.644" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_81">
|
||||
<text transform="translate(91 568.422)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="6394885e-19" y="15">L1</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_80">
|
||||
<rect x="271" y="569.146" width="159.5" height="17" fill="white"/>
|
||||
<rect x="271" y="569.146" width="159.5" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(276 568.422)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="59.79" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_79">
|
||||
<rect x="436" y="569.146" width="74" height="17" fill="white"/>
|
||||
<rect x="436" y="569.146" width="74" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(441 568.422)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="17.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_78">
|
||||
<rect x="515.5" y="569.146" width="86" height="17" fill="white"/>
|
||||
<rect x="515.5" y="569.146" width="86" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(520.5 568.422)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="23.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Graphic_86">
|
||||
<rect x="191.5" y="569.146" width="74" height="17" fill="white"/>
|
||||
<rect x="191.5" y="569.146" width="74" height="17" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
<text transform="translate(196.5 568.422)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="17.04" y="15">SST</tspan>
|
||||
</text>
|
||||
</g>
|
||||
<g id="Line_87">
|
||||
<line x1="365.3486" y1="486.5" x2="365.3486" y2="517.6" marker-end="url(#FilledArrow_Marker)" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="1"/>
|
||||
</g>
|
||||
<g id="Graphic_88">
|
||||
<text transform="translate(374.5 497.776)" fill="black">
|
||||
<tspan font-family="Helvetica Neue" font-size="16" fill="black" x="29132252e-20" y="15">Full Compaction</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 7.2 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 245 693 269" width="693" height="269">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 245 693 269" width="693" height="269">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-01-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week2-01-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-01-overview</title>
|
||||
<rect fill="white" x="6" y="245" width="693" height="269"/>
|
||||
<g id="week2-01-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 245 765 268" width="765" height="268">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 245 765 268" width="765" height="268">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -13,7 +13,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-05-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week2-05-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-05-overview</title>
|
||||
<rect fill="white" x="6" y="245" width="765" height="268"/>
|
||||
<g id="week2-05-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 213 693 291" width="693" height="291">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 213 693 291" width="693" height="291">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -8,7 +8,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-06-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week2-06-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-06-overview</title>
|
||||
<rect fill="white" x="6" y="213" width="693" height="291"/>
|
||||
<g id="week2-06-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="6 156 788 358" width="788" height="358">
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xl="http://www.w3.org/1999/xlink" viewBox="6 156 788 358" width="788" height="358">
|
||||
<defs>
|
||||
<marker orient="auto" overflow="visible" markerUnits="strokeWidth" id="FilledArrow_Marker" stroke-linejoin="miter" stroke-miterlimit="10" viewBox="-1 -4 10 8" markerWidth="10" markerHeight="8" color="black">
|
||||
<g>
|
||||
@@ -13,7 +13,7 @@
|
||||
</g>
|
||||
</marker>
|
||||
</defs>
|
||||
<g id="week2-overview" stroke-dasharray="none" fill="none" fill-opacity="1" stroke="none" stroke-opacity="1">
|
||||
<g id="week2-overview" fill-opacity="1" stroke-opacity="1" stroke="none" fill="none" stroke-dasharray="none">
|
||||
<title>week2-overview</title>
|
||||
<rect fill="white" x="6" y="156" width="788" height="358"/>
|
||||
<g id="week2-overview_Layer_1">
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -39,7 +39,7 @@ fn force_full_compaction(&self) {
|
||||
let state_lock = self.state_lock.lock();
|
||||
let state = self.state.write();
|
||||
state.l0_sstables.remove(/* the ones being compacted */);
|
||||
state.levels[0] = new_ssts;
|
||||
state.levels[0] = new_ssts; // new SSTs added to L1
|
||||
};
|
||||
std::fs::remove(ssts_to_compact)?;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ In your compaction implementation, you only need to handle `FullCompaction` for
|
||||
|
||||
Because we always compact all SSTs, if we find multiple version of a key, we can simply retain the latest one. If the latest version is a delete marker, we do not need to keep it in the produced SST files. This does not apply for the compaction strategies in the next few chapters.
|
||||
|
||||
There are some niches that you might need to think about.
|
||||
There are some things that you might need to think about.
|
||||
|
||||
* How does your implementation handle L0 flush in par with compaction? (Not taking the state lock when doing the compaction, and also need to consider new L0 files produced when compaction is going on.)
|
||||
* If your implementation removes the original SST files immediately after the compaction completes, will it cause problems in your system? (Generally no on macOS/Linux because the OS will not actually remove the file until no file handle is being held.)
|
||||
@@ -89,10 +89,10 @@ You will need to implement `num_active_iterators` for concat iterator so that th
|
||||
* What are the definitions of read/write/space amplifications? (This is covered in the overview chapter)
|
||||
* What are the ways to accurately compute the read/write/space amplifications, and what are the ways to estimate them?
|
||||
* Is it correct that a key will take some storage space even if a user requests to delete it?
|
||||
* Given that compaction takes a lot of write bandwidth and read bandwidth and may interfere with foreground operations, it is a good idea to postpone compaction when there are large write flow. It is even beneficial to stop/pause existing compaction tasks in this situation. What do you think of this idea? (Read the Slik paper!)
|
||||
* Given that compaction takes a lot of write bandwidth and read bandwidth and may interfere with foreground operations, it is a good idea to postpone compaction when there are large write flow. It is even beneficial to stop/pause existing compaction tasks in this situation. What do you think of this idea? (Read the [Silk](https://www.usenix.org/conference/atc19/presentation/balmau) paper!)
|
||||
* Is it a good idea to use/fill the block cache for compactions? Or is it better to fully bypass the block cache when compaction?
|
||||
* Does it make sense to have a `struct ConcatIterator<I: StorageIterator>` in the system?
|
||||
* Some researchers/engineers propose to offload compaction to a remote server or a serverless lambda function. What are the benefits, and what might be the potential challenges and performance impacts of doing remote compaction? (Think of the point when a compaction completes and the block cache...)
|
||||
* Some researchers/engineers propose to offload compaction to a remote server or a serverless lambda function. What are the benefits, and what might be the potential challenges and performance impacts of doing remote compaction? (Think of the point when a compaction completes and what happens to the block cache on the next read request...)
|
||||
|
||||
We do not provide reference answers to the questions, and feel free to discuss about them in the Discord community.
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ In this chapter, you will:
|
||||
|
||||
* Is it correct that a key will only be purged from the LSM tree if the user requests to delete it and it has been compacted in the bottom-most level?
|
||||
* Is it a good strategy to periodically do a full compaction on the LSM tree? Why or why not?
|
||||
* Actively choosing some old files/levels to compact even if they do not violate the level amplifier would be a good choice, is it true? (Look at the Lethe paper!)
|
||||
* Actively choosing some old files/levels to compact even if they do not violate the level amplifier would be a good choice, is it true? (Look at the [Lethe](https://disc-projects.bu.edu/lethe/) paper!)
|
||||
* If the storage device can achieve a sustainable 1GB/s write throughput and the write amplification of the LSM tree is 10x, how much throughput can the user get from the LSM key-value interfaces?
|
||||
* Can you merge L1 and L3 directly if there are SST files in L2? Does it still produce correct result?
|
||||
* What is your favorite boba shop in your city? (If you answered yes in week 1 day 3...)
|
||||
|
||||
We do not provide reference answers to the questions, and feel free to discuss about them in the Discord community.
|
||||
|
||||
@@ -45,6 +45,14 @@ So from the above example, we have 2 naive ways of handling the LSM structure --
|
||||
|
||||
Compaction is a time-consuming operation. It will need to read all data from some files, and write the same amount of files to the disk. This operation takes a lot of CPU resources and I/O resources. Not doing compactions at all leads to high read amplification, but it does not need to write new files. Always doing full compaction reduces the read amplification, but it will need to constantly rewrite the files on the disk.
|
||||
|
||||

|
||||
|
||||
<p class="caption">No Compaction at All</p>
|
||||
|
||||

|
||||
|
||||
<p class="caption">Always compact when new SST being flushed</p>
|
||||
|
||||
The ratio of memtables flushed to the disk versus total data written to the disk is write amplification. That is to say, no compaction has a write amplification ratio of 1x, because once the SSTs are flushed to the disk, they will stay there. Always doing compaction has a very high write amplification. If we do a full compaction every time we get an SST, the data written to the disk will be quadratic to the number of SSTs flushed. For example, if we flushed 100 SSTs to the disk, we will do compactions of 2 files, 3 files, ..., 100 files, where the actual total amount of data we wrote to the disk is about 5000 SSTs. The write amplification after writing 100 SSTs in this cause would be 50x.
|
||||
|
||||
A good compaction strategy can balance read amplification, write amplification, and space amplification (we will talk about it soon). In a general-purpose LSM storage engine, it is generally impossible to find a strategy that can achieve the lowest amplification in all 3 of these factors, unless there are some specific data pattern that the engine could use. The good thing about LSM is that we can theoretically analyze the amplifications of a compaction strategy and all these things happen in the background. We can choose compaction strategies and dynamically change some parameters of them to adjust our storage engine to the optimal state. Compaction strategies are all about tradeoffs, and LSM-based storage engine enables us to select what to be traded at runtime.
|
||||
@@ -57,10 +65,14 @@ If the workload is like a time-series database, it is possible that the user alw
|
||||
|
||||
Compaction strategies usually aim to control the number of sorted runs, so as to keep read amplification in a reasonable amount of number. There are generally two categories of compaction strategies: leveled and tiered.
|
||||
|
||||
In leveled compaction, the user can specify a maximum number of levels, which is the number of sorted runs in the system (except L0). For example, RocksDB usually keeps 6 levels (sorted runs) in leveled compaction mode. During the compaction process, SSTs from two adjacent levels will be merged and then the produced SSTs will be put to the lower level of the two levels. Therefore, you will usually see a small sorted run merged with a large sorted run in leveled compaction. The sorted runs (levels) grow exponentially in size -- the lower level will be < some number x > of the upper level in size.
|
||||
In leveled compaction, the user can specify a maximum number of levels, which is the number of sorted runs in the system (except L0). For example, RocksDB usually keeps 6 levels (sorted runs) in leveled compaction mode. During the compaction process, SSTs from two adjacent levels will be merged and then the produced SSTs will be put to the lower level of the two levels. Therefore, you will usually see a small sorted run merged with a large sorted run in leveled compaction. The sorted runs (levels) grow exponentially in size -- the lower level will be `<some number>` of the upper level in size.
|
||||
|
||||

|
||||
|
||||
In tiered compaction, the engine will dynamically adjust the number of sorted runs by merging them or letting new SSTs flushed as new sorted run (a tier) to minimize write amplification. In this strategy, you will usually see the engine merge two equally-sized sorted runs. The number of tiers can be high if the compaction strategy does not choose to merge tiers, therefore making read amplification high. In this tutorial, we will implement RocksDB's universal compaction, which is a kind of tiered compaction strategy.
|
||||
|
||||

|
||||
|
||||
## Space Amplification
|
||||
|
||||
The most intuitive way to compute space amplification is to divide the actual space used by the LSM engine by the user space usage (i.e., database size, number of rows in the database, etc.) . The engine will need to store delete tombstones, and sometimes multiple version of the same key if compaction is not happening frequently enough, therefore causing space amplification.
|
||||
|
||||
@@ -5,7 +5,7 @@ use bytes::Bytes;
|
||||
|
||||
use crate::{
|
||||
iterators::StorageIterator,
|
||||
lsm_storage::BlockCache,
|
||||
lsm_storage::{BlockCache, LsmStorageInner},
|
||||
table::{SsTable, SsTableBuilder},
|
||||
};
|
||||
|
||||
@@ -123,3 +123,11 @@ pub fn generate_sst(
|
||||
}
|
||||
builder.build(id, block_cache, path.as_ref()).unwrap()
|
||||
}
|
||||
|
||||
|
||||
pub fn sync(storage: &LsmStorageInner) {
|
||||
storage
|
||||
.force_freeze_memtable(&storage.state_lock.lock())
|
||||
.unwrap();
|
||||
storage.force_flush_next_imm_memtable().unwrap();
|
||||
}
|
||||
@@ -3,7 +3,7 @@ use std::{ops::Bound, time::Duration};
|
||||
use bytes::Bytes;
|
||||
use tempfile::tempdir;
|
||||
|
||||
use self::harness::check_iter_result;
|
||||
use self::harness::{check_iter_result, sync};
|
||||
|
||||
use super::*;
|
||||
use crate::{
|
||||
@@ -11,12 +11,6 @@ use crate::{
|
||||
lsm_storage::{LsmStorageInner, LsmStorageOptions, MiniLsm},
|
||||
};
|
||||
|
||||
fn sync(storage: &LsmStorageInner) {
|
||||
storage
|
||||
.force_freeze_memtable(&storage.state_lock.lock())
|
||||
.unwrap();
|
||||
storage.force_flush_next_imm_memtable().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task1_storage_scan() {
|
||||
|
||||
@@ -1,18 +1,143 @@
|
||||
use std::ops::Bound;
|
||||
use std::{ops::Bound, path::Path, sync::Arc};
|
||||
|
||||
use bytes::Bytes;
|
||||
use tempfile::tempdir;
|
||||
use week2_day1::harness::sync;
|
||||
|
||||
use self::harness::check_iter_result;
|
||||
|
||||
use super::*;
|
||||
use crate::lsm_storage::{LsmStorageInner, LsmStorageOptions};
|
||||
use crate::{
|
||||
iterators::{
|
||||
concat_iterator::SstConcatIterator, merge_iterator::MergeIterator, StorageIterator,
|
||||
},
|
||||
lsm_storage::{LsmStorageInner, LsmStorageOptions, LsmStorageState},
|
||||
table::{SsTable, SsTableBuilder, SsTableIterator},
|
||||
};
|
||||
|
||||
fn sync(storage: &LsmStorageInner) {
|
||||
storage
|
||||
.force_freeze_memtable(&storage.state_lock.lock())
|
||||
fn construct_merge_iterator_over_storage(
|
||||
state: &LsmStorageState,
|
||||
) -> MergeIterator<SsTableIterator> {
|
||||
let mut iters = Vec::new();
|
||||
for t in &state.l0_sstables {
|
||||
iters.push(Box::new(
|
||||
SsTableIterator::create_and_seek_to_first(state.sstables.get(t).cloned().unwrap())
|
||||
.unwrap(),
|
||||
));
|
||||
}
|
||||
for (_, files) in &state.levels {
|
||||
for f in files {
|
||||
iters.push(Box::new(
|
||||
SsTableIterator::create_and_seek_to_first(state.sstables.get(f).cloned().unwrap())
|
||||
.unwrap(),
|
||||
));
|
||||
}
|
||||
}
|
||||
MergeIterator::create(iters)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task1_full_compaction() {
|
||||
let dir = tempdir().unwrap();
|
||||
let storage = LsmStorageInner::open(&dir, LsmStorageOptions::default_for_week1_test()).unwrap();
|
||||
storage.put(b"0", b"v1").unwrap();
|
||||
sync(&storage);
|
||||
storage.put(b"0", b"v2").unwrap();
|
||||
storage.put(b"1", b"v2").unwrap();
|
||||
storage.put(b"2", b"v2").unwrap();
|
||||
sync(&storage);
|
||||
storage.delete(b"0").unwrap();
|
||||
storage.delete(b"2").unwrap();
|
||||
sync(&storage);
|
||||
assert_eq!(storage.state.read().l0_sstables.len(), 3);
|
||||
let mut iter = construct_merge_iterator_over_storage(&storage.state.read());
|
||||
check_iter_result(
|
||||
&mut iter,
|
||||
vec![
|
||||
(Bytes::from_static(b"0"), Bytes::from_static(b"")),
|
||||
(Bytes::from_static(b"1"), Bytes::from_static(b"v2")),
|
||||
(Bytes::from_static(b"2"), Bytes::from_static(b"")),
|
||||
],
|
||||
);
|
||||
storage.force_full_compaction().unwrap();
|
||||
assert!(storage.state.read().l0_sstables.is_empty());
|
||||
let mut iter = construct_merge_iterator_over_storage(&storage.state.read());
|
||||
check_iter_result(
|
||||
&mut iter,
|
||||
vec![(Bytes::from_static(b"1"), Bytes::from_static(b"v2"))],
|
||||
);
|
||||
storage.put(b"0", b"v3").unwrap();
|
||||
storage.put(b"2", b"v3").unwrap();
|
||||
sync(&storage);
|
||||
storage.delete(b"1").unwrap();
|
||||
sync(&storage);
|
||||
let mut iter = construct_merge_iterator_over_storage(&storage.state.read());
|
||||
check_iter_result(
|
||||
&mut iter,
|
||||
vec![
|
||||
(Bytes::from_static(b"0"), Bytes::from_static(b"v3")),
|
||||
(Bytes::from_static(b"1"), Bytes::from_static(b"")),
|
||||
(Bytes::from_static(b"2"), Bytes::from_static(b"v3")),
|
||||
],
|
||||
);
|
||||
storage.force_full_compaction().unwrap();
|
||||
assert!(storage.state.read().l0_sstables.is_empty());
|
||||
let mut iter = construct_merge_iterator_over_storage(&storage.state.read());
|
||||
check_iter_result(
|
||||
&mut iter,
|
||||
vec![
|
||||
(Bytes::from_static(b"0"), Bytes::from_static(b"v3")),
|
||||
(Bytes::from_static(b"2"), Bytes::from_static(b"v3")),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn generate_concat_sst(
|
||||
start_key: usize,
|
||||
end_key: usize,
|
||||
dir: impl AsRef<Path>,
|
||||
id: usize,
|
||||
) -> SsTable {
|
||||
let mut builder = SsTableBuilder::new(128);
|
||||
for idx in start_key..end_key {
|
||||
let key = format!("{:05}", idx);
|
||||
builder.add(key.as_bytes(), b"test");
|
||||
}
|
||||
let path = dir.as_ref().join(format!("{id}.sst"));
|
||||
builder.build_for_test(path).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task2_concat_iterator() {
|
||||
let dir = tempdir().unwrap();
|
||||
let mut sstables = Vec::new();
|
||||
for i in 1..=10 {
|
||||
sstables.push(Arc::new(generate_concat_sst(
|
||||
i * 10,
|
||||
(i + 1) * 10,
|
||||
dir.path(),
|
||||
i,
|
||||
)));
|
||||
}
|
||||
for key in 0..120 {
|
||||
let iter = SstConcatIterator::create_and_seek_to_key(
|
||||
sstables.clone(),
|
||||
format!("{:05}", key).as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
storage.force_flush_next_imm_memtable().unwrap();
|
||||
if key < 10 {
|
||||
assert!(iter.is_valid());
|
||||
assert_eq!(iter.key(), b"00010");
|
||||
} else if key >= 110 {
|
||||
assert!(!iter.is_valid());
|
||||
} else {
|
||||
assert!(iter.is_valid());
|
||||
assert_eq!(iter.key(), format!("{:05}", key).as_bytes());
|
||||
}
|
||||
}
|
||||
let iter = SstConcatIterator::create_and_seek_to_first(sstables.clone()).unwrap();
|
||||
assert!(iter.is_valid());
|
||||
assert_eq!(iter.key(), b"00010");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -38,11 +163,11 @@ fn test_task3_integration() {
|
||||
storage.put(b"00", b"2333").unwrap();
|
||||
storage.put(b"3", b"23333").unwrap();
|
||||
storage.delete(b"1").unwrap();
|
||||
// sync(&storage);
|
||||
// storage.force_full_compaction().unwrap();
|
||||
sync(&storage);
|
||||
storage.force_full_compaction().unwrap();
|
||||
|
||||
// assert!(storage.state.read().l0_sstables.is_empty());
|
||||
// assert!(!storage.state.read().levels[0].1.is_empty());
|
||||
assert!(storage.state.read().l0_sstables.is_empty());
|
||||
assert!(!storage.state.read().levels[0].1.is_empty());
|
||||
|
||||
check_iter_result(
|
||||
&mut storage.scan(Bound::Unbounded, Bound::Unbounded).unwrap(),
|
||||
|
||||