Update chapter 20 figures

This commit is contained in:
Zeljko Hrcek
2026-02-27 12:02:50 +01:00
parent b16f8f36cd
commit 6de84f20e6

View File

@@ -183,37 +183,99 @@ The choice of file format determines the "physics" of how your data is read.
::: {#fig-row-vs-col fig-env="figure" fig-pos="htb" fig-cap="**Storage Layouts**: Row-oriented formats pack data together by record (good for transactions). Column-oriented formats pack data by feature (good for analytics)." fig-alt="Diagram contrasting Row Store vs Column Store. Row store shows Record 1 [ID, Name, Age] followed by Record 2. Column store shows Column 1 [ID1, ID2...] followed by Column 2 [Name1, Name2...]."}
```{.tikz}
\begin{tikzpicture}[font=\small\usefont{T1}{phv}{m}{n}, scale=1.0]
\begin{tikzpicture}[font=\small\usefont{T1}{phv}{m}{n}]
\tikzset{
DataBlock/.style={draw=GrayLine, line width=0.8pt, minimum height=0.6cm, minimum width=1.2cm, align=center, font=\scriptsize\usefont{T1}{phv}{m}{n}},
DataBlock/.style={draw=GrayLine, line width=0.8pt, node distance=-0.8pt,
minimum height=8mm, minimum width=16mm, align=center, font=\small\usefont{T1}{phv}{m}{n}},
Label/.style={text=TextBlack, font=\small\bfseries\usefont{T1}{phv}{m}{n}}
}
% Row Store
\node[Label] at (0, 3.5) {Row-Oriented (CSV)};
\node[DataBlock, fill=RedFill] (r1a) at (0, 2.8) {ID: 1};
\node[DataBlock, fill=BlueFill, right=0pt of r1a] (r1b) {Age: 25};
\node[DataBlock, fill=GreenFill, right=0pt of r1b] (r1c) {Loc: US};
\tikzset{mycylinder/.style={cylinder, shape border rotate=90, aspect=1.3, draw, fill=white,
minimum width=25mm,minimum height=11mm,line width=\Linewidth,node distance=-0.15},
pics/data/.style = {
code = {
\pgfkeys{/channel/.cd, #1}
\begin{scope}[local bounding box=STREAMING,scale=\scalefac, every node/.append style={transform shape}]
\node[mycylinder,fill=\filllcolor!50] (A) {};
\node[mycylinder, above=of A,fill=\filllcolor!30] (B) {};
\node[mycylinder, above=of B,fill=\filllcolor!10] (C) {};
\end{scope}
}
}
}
\tikzset{pics/lupa/.style = {
code = {
\pgfkeys{/channel/.cd, #1}
\begin{scope}[local bounding box=BRAIN,scale=\scalefac, every node/.append style={transform shape}]
\coordinate(PO)at(-0.1,0.2);
\node[circle,draw=white,line width=1pt,fill=\filllcirclecolor,minimum size=5mm,inner sep=0pt](LV)at(PO){};
\node[draw=none,rotate=40,rounded corners=2pt,rectangle,minimum width=1.2mm,inner sep=1pt,
fill=\filllcirclecolor,minimum height=6mm,anchor=north]at(PO){};
\node[circle,draw=none,fill=white,minimum size=3.0mm,inner sep=0pt](LM)at(PO){};
\node[font=\tiny\bfseries]at(LM){...};
\end{scope}
}
}
}
\pgfkeys{
/channel/.cd,
Depth/.store in=\Depth,
Height/.store in=\Height,
Width/.store in=\Width,
filllcirclecolor/.store in=\filllcirclecolor,
filllcolor/.store in=\filllcolor,
drawcolor/.store in=\drawcolor,
drawcircle/.store in=\drawcircle,
scalefac/.store in=\scalefac,
Linewidth/.store in=\Linewidth,
picname/.store in=\picname,
filllcolor=BrownLine,
filllcirclecolor=violet!20,
drawcolor=black,
drawcircle=violet,
scalefac=1,
Linewidth=0.5pt,
Depth=1.3,
Height=0.8,
Width=1.1,
picname=C
}
\node[DataBlock, fill=RedFill, right=0.2cm of r1c] (r2a) {ID: 2};
\node[DataBlock, fill=BlueFill, right=0pt of r2a] (r2b) {Age: 30};
\node[DataBlock, fill=GreenFill, right=0pt of r2b] (r2c) {Loc: UK};
% Column Store
\node[Label] at (0, 1.5) {Column-Oriented (Parquet)};
\node[DataBlock, fill=RedFill] (c1a) at (0, 0.8) {ID: 1};
\node[DataBlock, fill=RedFill, right=0pt of c1a] (c1b) {ID: 2};
\node[DataBlock, fill=BlueFill, right=0.2cm of c1b] (c2a) {Age: 25};
\node[DataBlock, fill=BlueFill, right=0pt of c2a] (c2b) {Age: 30};
\node[DataBlock, fill=GreenFill, right=0.2cm of c2b] (c3a) {Loc: US};
\node[DataBlock, fill=GreenFill, right=0pt of c3a] (c3b) {Loc: UK};
% Scan Path
\draw[->, thick, dashed, gray] (-0.8, 2.5) -- (7.5, 2.5) node[right, font=\scriptsize\usefont{T1}{phv}{m}{n}] {Scan reads all fields};
\draw[->, thick, dashed, BlueLine] (2.6, 0.2) -- (5.2, 0.2) node[right, font=\scriptsize\usefont{T1}{phv}{m}{n}] {Scan reads ONLY Age};
% Row Store
\node[DataBlock, fill=RedFill!60] (r1a) at (0, 2.8) {ID: 1};
\node[DataBlock, fill=cyan!20, right=of r1a] (r1b) {Age: 25};
\node[DataBlock, fill=green!80!black!20, right=of r1b] (r1c) {Loc: US};
%
\node[DataBlock, fill=RedFill!60, right=7mm of r1c] (r2a) {ID: 2};
\node[DataBlock, fill=cyan!20, right=of r2a] (r2b) {Age: 30};
\node[DataBlock, fill=green!80!black!20, right=of r2b] (r2c) {Loc: UK};
%%fitting arrow
\node[draw=none,fill=none, inner ysep=3mm, inner xsep=6mm,fit=(r1a)(r2c),xshift=-3mm](A){};
\coordinate(AL)at($($(A.north west)!0.5!(A.south west)$)+(0.6,0)$);
\coordinate(AD)at($($(A.north east)!0.5!(A.south east)$)+(0.6,0)$);
\scoped[on background layer]
\draw[draw=none,fill=black!10](A.north west)--(A.north east)--(AD)--(A.south east)--(A.south west)--(AL)--cycle;
\node[Label,anchor=south,font=\small\usefont{T1}{phv}{b}{n}] at (A.north) {Row-Oriented (CSV)};
\node[anchor=north east]at(A.south east) {Scan reads \textbf{all fields}};
% Column Store
\node[DataBlock, fill=RedFill!60,below=1.5 of A.240] (c1a) {ID: 1};
\node[DataBlock, fill=cyan!20, below=of c1a] (c2a) {Age: 25};
\node[DataBlock, fill=green!80!black!20, below=of c2a] (c3a) {Loc: US};
\node[DataBlock, fill=RedFill!60, right=of c1a] (c1b) {ID: 2};
\node[DataBlock, fill=cyan!20, below=of c1b] (c2b) {Age: 30};
\node[DataBlock, fill=green!80!black!20, below=of c2b] (c3b) {Loc: UK};
%%fitting arrow
\node[draw=none,fill=none, inner ysep=0mm, inner xsep=10mm,fit=(c2a)(c2b),xshift=-3mm](B){};
\coordinate(BL)at($($(B.north west)!0.5!(B.south west)$)+(0.4,0)$);
\coordinate(BD)at($($(B.north east)!0.5!(B.south east)$)+(0.4,0)$);
\scoped[on background layer]
\draw[draw=none,fill=black!10](B.north west)--(B.north east)--(BD)--(B.south east)--(B.south west)--(BL)--cycle;
\node[Label,anchor=south,above=2pt of c1a.north east,font=\small\usefont{T1}{phv}{b}{n}] {Column-Oriented (Parquet)};
\node[anchor=north west]at(B.south east) {Scan reads \textbf{\color{cyan}ONLY Age}};
%icons
\pic[shift={(-1.3,-0.5)}] at (AL){data={scalefac=0.4,picname=1,filllcolor=VioletLine, Linewidth=0.6pt}};
\pic[shift={(-0.8,-0.05)}] at (BL){lupa={scalefac=1,picname=1,filllcirclecolor=VioletLine!60, Linewidth=0.5pt}};
\end{tikzpicture}
```
:::