# Supplementary Material for “Emergent Haldane model and photon number locking
in chiral cavities”

Liu Yang  Tsung-Dao Lee Institute, Shanghai Jiao Tong University, Shanghai
200240, China  School of Physics and Astronomy, Shanghai Jiao Tong University,
Shanghai 200240, China  Qing-Dong Jiang<EMAIL_ADDRESS>Tsung-Dao
Lee Institute, Shanghai Jiao Tong University, Shanghai 200240, China  School
of Physics and Astronomy, Shanghai Jiao Tong University, Shanghai 200240,
China  Shanghai Branch, Hefei National Laboratory, Shanghai 201315, China

###### Contents

  1. I Effective Hamiltonian in the asymptotically decoupled frame
  2. II The modified and effective potentials of graphene in chiral cavities
  3. III Plane wave expansion of the effective Hamiltonian
  4. IV Brief review of the Quantum geometric tensor
  5. V Quantum geometry of graphene and Haldane model
  6. VI Chern number calculation through Wilson loop formalism
  7. VII Valley energy splitting in a general cavity with hybrid chirality
  8. VIII The photon number change in a function of the coupling strength

##  I Effective Hamiltonian in the asymptotically decoupled frame

The Hamiltonian for materials in a general single-mode cavity can be written
as

$\displaystyle\hat{H}^{C}$
$\displaystyle=\frac{(\hat{\boldsymbol{p}}+e\hat{\mathbf{A}})^{2}}{2m}+V(\boldsymbol{r})+\hbar\omega_{c}\left(\hat{a}^{\dagger}\hat{a}+\frac{1}{2}\right),$
(S1) $\displaystyle\hat{\mathbf{A}}$
$\displaystyle=A_{0}\left(\boldsymbol{f}\hat{a}+\boldsymbol{f}^{*}\hat{a}^{\dagger}\right).$
(S2)

Here, the vector potential $\hat{\mathbf{A}}$ is quantized in the Coulomb
gauge. If we consider a generalized polarization as a superposition of right-
and left-handed directions, $\boldsymbol{f}$ can be defined as

$\displaystyle\boldsymbol{f}$
$\displaystyle=\boldsymbol{\epsilon}\cos{\theta}+\boldsymbol{\epsilon}^{\ast}\sin{\theta}$
$\displaystyle=\boldsymbol{e}_{x}\cos(\frac{\pi}{4}-\theta)-i\boldsymbol{e}_{y}\sin(\frac{\pi}{4}-\theta),$
(S3) $\displaystyle\boldsymbol{\epsilon}$
$\displaystyle=\frac{\boldsymbol{e}_{x}-\mathrm{i}\boldsymbol{e}_{y}}{\sqrt{2}}.$
(S4)

When $\theta=0$ ($\pi/2$), $\boldsymbol{f}$ corresponds to the right-handed
(left-handed) circular polarization. When $\theta=\pi/4$,
$\boldsymbol{f}=\boldsymbol{e}_{x}$.

Then, we rewrite the gauge potential operator as

$\displaystyle\hat{\mathbf{A}}$
$\displaystyle=A_{0}\left(c_{x}\boldsymbol{e}_{x}\hat{\phi}_{x}+c_{y}\boldsymbol{e}_{y}\hat{\phi}_{y}\right),$
(S5) $\displaystyle\hat{\phi}_{x}$
$\displaystyle=\frac{a^{\dagger}+a}{\sqrt{2}},\quad\hat{\phi}_{y}=\mathrm{i}\frac{a^{\dagger}-a}{\sqrt{2}}$
(S6) $\displaystyle c_{x}$
$\displaystyle=\sqrt{2}\cos{(\frac{\pi}{4}-\theta)},c_{y}=\sqrt{2}\sin{(\frac{\pi}{4}-\theta)}.$
(S7)

Here, $\hat{\phi}_{x}$ and $\hat{\phi}_{y}$ satisfy

$\displaystyle[\hat{\phi}_{x},\hat{\phi}_{y}]=\mathrm{i}.$ (S8)

The unitary transformation $\hat{U}$ that decouples the light-matter
interaction asymptotically is

$\displaystyle\hat{U}$
$\displaystyle=\exp\left[\mathrm{i}(\xi_{x}\hat{\phi}_{y}\hat{k}_{x}-\xi_{y}\hat{\phi}_{x}\hat{k}_{y})\right],$
(S9) $\displaystyle\xi_{\mu}$
$\displaystyle=\sqrt{\frac{\hbar}{m\omega_{c}}}\frac{c_{\mu}g/\omega_{c}}{1+c_{\mu}^{2}g^{2}/\omega_{c}^{2}},$
(S10) $\displaystyle\frac{g}{\omega_{c}}$
$\displaystyle=\frac{eA_{0}}{\sqrt{m\hbar\omega_{c}}}.$ (S11)

Here $\hat{k}_{\mu}=-\mathrm{i}\partial_{\mu}$. We then obtain the Hamiltonian
in the asymptotically decoupled (AD) frame:

$\displaystyle\hat{U}^{\dagger}\hat{H}^{C}\hat{U}$
$\displaystyle=\frac{\hat{p}_{x}^{2}}{2m\gamma^{2}_{x}}+\frac{\hat{p}_{y}^{2}}{2m\gamma^{2}_{y}}+V(\boldsymbol{r}+\hat{\boldsymbol{\tau}})+\frac{\hbar\Omega}{2}\left(\hat{\Phi}_{x}^{2}+\hat{\Phi}_{y}^{2}\right),$
(S12)

where

$\displaystyle\Omega$ $\displaystyle=\omega_{c}\gamma_{x}\gamma_{y},$ (S13)
$\displaystyle\gamma^{2}_{\mu}$
$\displaystyle=1+\frac{c_{\mu}^{2}g^{2}}{\omega_{c}^{2}},$ (S14)

and $\hat{\Phi}_{x}$ and $\hat{\Phi}_{y}$ are defined as

$\displaystyle\hat{\Phi}_{x}$
$\displaystyle=\sqrt{\frac{\gamma_{x}}{\gamma_{y}}}\hat{\phi}_{x},\hat{\Phi}_{y}=\sqrt{\frac{\gamma_{y}}{\gamma_{x}}}\hat{\phi}_{y}.$
(S15)

The commutation relation between $\hat{\Phi}_{x}$ and $\hat{\Phi}_{y}$ is
normalized as

$\displaystyle[\hat{\Phi}_{x},\hat{\Phi}_{y}]=\mathrm{i}.$ (S16)

We define a characteristic length

$\displaystyle\xi$
$\displaystyle=\sqrt{\frac{\hbar}{m\omega_{c}}}\frac{g/\omega_{c}}{\gamma_{x}\gamma_{y}}.$
(S17)

Using $\xi$, we can express the operator $\hat{\boldsymbol{\tau}}$ as follow

$\displaystyle\hat{\boldsymbol{\tau}}$
$\displaystyle=\frac{\xi^{2}}{2}\cos(2\theta)\hat{\boldsymbol{k}}\times\boldsymbol{e}_{z}+\xi\hat{\boldsymbol{\Pi}},$
(S18)

where the operator $\hat{\boldsymbol{\Pi}}$ is defined as

$\displaystyle\hat{\Pi}_{x}$
$\displaystyle=-c_{x}\sqrt{\frac{\gamma_{y}}{\gamma_{x}}}\hat{\Phi}_{y},$
(S19) $\displaystyle\hat{\Pi}_{y}$
$\displaystyle=c_{y}\sqrt{\frac{\gamma_{x}}{\gamma_{y}}}\hat{\Phi}_{x}.$ (S20)

Note that the commutation relation between the operators $\hat{\Pi}_{x}$ and
$\hat{\Pi}_{y}$ is

$\displaystyle[\hat{\Pi}_{x},\hat{\Pi}_{y}]=\mathrm{i}\,\cos(2\theta).$ (S21)

By the above notations, the unitary transformation Eq. (S9) can be rewritten
as

$\displaystyle\hat{U}=\exp[-\mathrm{i}\xi\hat{\boldsymbol{\Pi}}\cdot\hat{\boldsymbol{k}}].$
(S22)

We now introduce the crystalline potential of the material by the Fourier
series

$\displaystyle
V(\boldsymbol{r})=\sum_{\boldsymbol{b}}V_{\boldsymbol{b}}e^{\mathrm{i}\boldsymbol{b}\cdot\boldsymbol{r}},$
(S23)

where $\boldsymbol{b}$ are the reciprocal lattice vectors. By the photon
vacuum approximation in the AD frame, we derive the effective Hamiltonian as
follows

$\displaystyle\hat{H}^{U}$ $\displaystyle=\langle
0_{\text{photon}}|\hat{U}^{\dagger}\hat{H}^{C}\hat{U}|0_{\text{photon}}\rangle$
$\displaystyle=\frac{\hat{p}_{x}^{2}}{2m\gamma^{2}_{x}}+\frac{\hat{p}_{y}^{2}}{2m\gamma^{2}_{y}}+\widetilde{V}\left(\boldsymbol{r}+\frac{\xi^{2}}{2}\cos(2\theta)\hat{\boldsymbol{k}}\times\boldsymbol{e}_{z}\right),$
(S24)

where the modified potential function is defined as

$\displaystyle\widetilde{V}(\boldsymbol{r})$
$\displaystyle=\sum_{\boldsymbol{b}}V_{\boldsymbol{b}}e^{\mathrm{i}\boldsymbol{b}\cdot\boldsymbol{r}}\langle
0_{\text{photon}}|e^{\mathrm{i}\xi\boldsymbol{b}\cdot\hat{\boldsymbol{\Pi}}}|0_{\text{photon}}\rangle+\frac{\hbar\Omega}{2}$
$\displaystyle=\sum_{\boldsymbol{b}}\widetilde{V}_{\boldsymbol{b}}e^{\mathrm{i}\boldsymbol{b}\cdot\boldsymbol{r}}+\frac{\hbar\Omega}{2},$
(S25) $\displaystyle\widetilde{V}_{\boldsymbol{b}}$
$\displaystyle=V_{\boldsymbol{b}}e^{-\frac{\xi^{2}}{4}\left(b_{x}^{2}c_{x}^{2}\frac{\gamma_{y}}{\gamma_{x}}+b_{y}^{2}c_{y}^{2}\frac{\gamma_{x}}{\gamma_{y}}\right)}.$
(S26)

For standard chiral cavities, $\theta=0$. The effective Hamiltonian (which we
used in the main text) is

$\displaystyle\hat{H}^{U}$ $\displaystyle=\langle
0_{\text{photon}}|\hat{U}^{\dagger}\hat{H}^{C}\hat{U}|0_{\text{photon}}\rangle$
$\displaystyle=\frac{\hat{p}^{2}}{2m_{\text{eff}}}+\widetilde{V}(\boldsymbol{r}+\frac{\xi^{2}}{2\hbar}\hat{\boldsymbol{p}}\times\boldsymbol{e}_{z}),$
(S27)

where

$\displaystyle m_{\text{eff}}$
$\displaystyle=m(1+\frac{g^{2}}{\omega_{c}^{2}}),$ (S28) $\displaystyle\xi$
$\displaystyle=\sqrt{\frac{\hbar}{m\omega_{c}}}\frac{g/\omega_{c}}{1+g^{2}/\omega_{c}^{2}}.$
(S29)

As $\xi$ is usually small [1, 2], we can expand this Hamiltonian to the first-
order of $\xi$ and obtain the effective Hamiltonian as

$\displaystyle\hat{H}^{\text{eff}}\approx\frac{[\hat{\boldsymbol{p}}+e\boldsymbol{A}(\boldsymbol{r})]^{2}}{2m_{\text{eff}}}+V_{\text{eff}}(\boldsymbol{r}),$
(S30)

where

$\displaystyle\boldsymbol{A}(\boldsymbol{r})$
$\displaystyle=\frac{\beta}{2e\omega_{c}}\boldsymbol{e}_{z}\times\nabla\widetilde{V},$
(S31) $\displaystyle V_{\text{eff}}(\boldsymbol{r})$
$\displaystyle=\widetilde{V}(\boldsymbol{r})-\frac{\beta^{3}}{8mg^{2}}|\nabla\widetilde{V}(\boldsymbol{r})|^{2}.$
(S32)

##  II The modified and effective potentials of graphene in chiral cavities

We show the graphene lattices in Fig. S1, where the lattice and reciprocal
lattice bases are defined as

$\displaystyle\boldsymbol{a}_{1}$
$\displaystyle=\sqrt{3}a_{0}(\cos\frac{\pi}{6},\sin\frac{\pi}{6}),$
$\displaystyle\boldsymbol{a}_{2}$
$\displaystyle=\sqrt{3}a_{0}(\cos\frac{5\pi}{6},\sin\frac{5\pi}{6}),$
$\displaystyle\boldsymbol{b}_{1}$
$\displaystyle=\frac{4\pi}{3a_{0}}(\cos\frac{\pi}{3},\sin\frac{\pi}{3}),$
$\displaystyle\boldsymbol{b}_{2}$
$\displaystyle=\frac{4\pi}{3a_{0}}(\cos\frac{2\pi}{3},\sin\frac{2\pi}{3}),$
(S33)

where $a_{0}$ is the lattice constant, and we set it to be 1 for convenience.
These vectors satisfy the orthonormalization relation

$\displaystyle\boldsymbol{a}_{i}\cdot\boldsymbol{b}_{j}=2\pi\delta_{ij}$ (S34)

Any crystal momentum $\boldsymbol{k}$ in the Brillouin zone (BZ) can be
expressed as

$\displaystyle\boldsymbol{k}=\sum_{i=1,2}\frac{k_{i}}{2\pi}\boldsymbol{b}_{i}.$
(S35)

To cover the whole first BZ, the value of the coordinate $k_{i}$ should be
taken from 0 to $2\pi$.

Figure S1: Lattices and reciprocal lattices of graphene.

For the graphene continuum model we use in the main text, the potential
function for the honeycomb lattices can be described by

$V(\boldsymbol{r})=\sum_{i=1}^{6}\left(V_{0}+\frac{\Delta}{9}e^{-\mathrm{i}\boldsymbol{b}_{i}\cdot\boldsymbol{\delta}}\right)\exp(\mathrm{i}\boldsymbol{b}_{i}\cdot\boldsymbol{r}),$
(S36)

where $\boldsymbol{\delta}=(1,0)$, the reciprocal lattice vector
$\boldsymbol{b}_{i}=4\pi(3a_{0})^{-1}(\cos{2\pi i/3},\sin{2\pi i/3})$.

In the effective Hamiltonians Eqs. S24 and (S30), we have defined a modified
potential function $\widetilde{V}(\boldsymbol{r})$ and an effective potential
$V_{\text{eff}}(\boldsymbol{r})$. We now check whether these two potential
functions still hold the honeycomb lattice structure as the original
$V(\boldsymbol{r})$. In Figs. S2 (a)-(b), we show these potential functions at
the coupling strength $g/\omega_{c}=1$. Throughout our work, we set $a_{0}=1$,
$\hbar=1$, and $e=1$ for convenience. Also, We will fix the material
parameters $V_{0}=m=1.5$, and the cavity parameter $\omega_{c}=2$ in the later
discussion. The sub-lattice onsite energy split $\Delta$ is $0$ or $2$ in (a)
or (b), respectively. We see that the modified and effective potential
functions still hold the same pattern as the potential of the bare graphene.

Figure S2: The potential functions of the cavity graphene at the coupling
strength $g/\omega_{c}=1$. $V(\boldsymbol{r})$,
$\widetilde{V}(\boldsymbol{r})$ and $V_{\text{eff}}(\boldsymbol{r})$ are
defined in Eqs. (S36), (S25) and (S32), respectively. We have chosen the
material parameters $V_{0}=m=1.5$, and the cavity parameter $\omega_{c}=2$.
The corresponding sub-lattice split $\Delta$ in (a) and (b) have been written
in the figures.

##  III Plane wave expansion of the effective Hamiltonian

For the numerical calculation of the spectrum and the quantum geometric tensor
of the cavity materials, we use plane-wave states $|\boldsymbol{K}\rangle$
($\boldsymbol{K}=\sum_{i=1,2}K_{i}\boldsymbol{b}_{i}=(K_{x},K_{y})$) to expand
the periodic Bloch states $|u_{n\boldsymbol{k}}\rangle$
($\boldsymbol{k}=(k_{x},k_{y})$) as

$\displaystyle|u_{n\boldsymbol{k}}\rangle=\sum_{\boldsymbol{K}}c_{\boldsymbol{K}}|\boldsymbol{K}\rangle.$
(S37)

Thus, the effective Hamiltonian at momentum $\boldsymbol{k}$ becomes

$\displaystyle\hat{H}^{\text{eff}}_{\boldsymbol{k}}$
$\displaystyle=\sum_{\boldsymbol{K}}\left[\frac{\hbar^{2}(K_{x}+k_{x})^{2}}{2m_{x}}+\frac{\hbar^{2}(K_{y}+k_{y})^{2}}{2m_{y}}\right]|\boldsymbol{K}\rangle\langle\boldsymbol{K}|$
$\displaystyle+\sum_{\boldsymbol{b}}\widetilde{V}_{\boldsymbol{b}}\sum_{\boldsymbol{K}}e^{\mathrm{i}\frac{\xi^{2}\cos(2\theta)}{2}[(\boldsymbol{k}+\boldsymbol{K})\times\boldsymbol{e}_{z}]\cdot\boldsymbol{b}}|\boldsymbol{K}+\boldsymbol{b}\rangle\langle\boldsymbol{K}|.$
(S38)

The corresponding derivative of $\hat{H}^{\text{eff}}_{\boldsymbol{k}}$ along
$\mu$ direction is

$\displaystyle\partial_{k_{\mu}}\hat{H}^{\text{eff}}_{\boldsymbol{k}}$
$\displaystyle=\sum_{\boldsymbol{K}}\left[\frac{\hbar^{2}(K_{x}+k_{x})}{m_{x}}+\frac{\hbar^{2}(K_{y}+k_{y})}{m_{y}}\right]|\boldsymbol{K}\rangle\langle\boldsymbol{K}|$
$\displaystyle+\sum_{\boldsymbol{b}}\widetilde{V}_{\boldsymbol{b}}\left(-\mathrm{i}\frac{\xi^{2}\cos(2\theta)}{2}\epsilon_{\mu\nu}b_{\nu}\right)\sum_{\boldsymbol{K}}e^{\mathrm{i}\frac{\xi^{2}\cos(2\theta)}{2}[(\boldsymbol{k}+\boldsymbol{K})\times\boldsymbol{e}_{z}]\cdot\boldsymbol{b}}|\boldsymbol{K}+\boldsymbol{b}\rangle\langle\boldsymbol{K}|.$
(S39)

##  IV Brief review of the Quantum geometric tensor

The quantum geometric tensor (QGT), or the Fubini-Study metric, describes the
associated geometric and topological properties of the band structures. For
the single occupied band, it is defined as

$\displaystyle
Q_{\mu\nu}(\boldsymbol{k})=\langle\partial_{k_{\mu}}u_{n}(\boldsymbol{k})|\partial_{k_{\nu}}u_{n}(\boldsymbol{k})\rangle-\mathcal{A}_{\mu}(\boldsymbol{k})\mathcal{A}_{\nu}(\boldsymbol{k}),$
(S40)

where

$\displaystyle\mathcal{A}_{\mu}(\boldsymbol{k})=\mathrm{i}\langle
u_{n}(\boldsymbol{k})|\partial_{k_{\mu}}u_{n}(\boldsymbol{k})\rangle.$ (S41)

Since the periodic Bloch wave function can be made orthonormalized as

$\displaystyle\int_{\text{unit
cell}}d^{D}\boldsymbol{r}\,u^{\ast}_{n\boldsymbol{k}^{\prime}}(\boldsymbol{r})u_{n\boldsymbol{k}}(\boldsymbol{r})=\delta_{\boldsymbol{k}^{\prime}\boldsymbol{k}},$
(S42)

we can prove $\mathcal{A}_{\mu}$ is real. The real part of the quantum
geometric tensor, which is also called the quantum metric, can be expressed as

$\displaystyle g_{\mu\nu}$ $\displaystyle=\text{Re}[Q_{\mu\nu}]$
$\displaystyle=-\langle
u_{n}(\boldsymbol{k})|\partial_{k_{\mu}}\partial_{k_{\nu}}u_{n}(\boldsymbol{k})\rangle-\mathcal{A}_{\mu}(\boldsymbol{k})\mathcal{A}_{\nu}(\boldsymbol{k}),$
(S43)

which can be derived by calculating the differential change of the transition
probability between $|u_{n}(\boldsymbol{k})\rangle$ at $\boldsymbol{k}$ and
$|u_{n}(\boldsymbol{k})\rangle$ at $\boldsymbol{k}+\Delta\boldsymbol{k}$:

$\displaystyle 1-|\langle
u_{n}(\boldsymbol{k})|u_{n}(\boldsymbol{k}+\Delta\boldsymbol{k})\rangle\big{|}^{2}=g_{\mu\nu}(\boldsymbol{k})dk^{\mu}dk^{\nu}.$
(S44)

The imaginary part of the quantum geometric tensor is proportional to the
Berry curvature

$\displaystyle\mathcal{F}_{\mu\nu}(\boldsymbol{k})$
$\displaystyle=-2\,\text{Im}[Q_{\mu\nu}]$
$\displaystyle=\partial_{k_{\mu}}\mathcal{A}_{\nu}-\partial_{k_{\nu}}\mathcal{A}_{\mu}.$
(S45)

While the integral of the Berry curvature is a topological invariant, the
integral of the quantum metric can be related to the spread of the Wannier
states[3, 4, 5, 6], which is regarded as a geometrical property.
Interestingly, there are inequality relations between the real and imaginary
part of the quantum geometric tensor as follows [7],

$\displaystyle\text{Tr}(g)$ $\displaystyle\geq
2\sqrt{\text{det}(g)}\geq|\mathcal{F}_{xy}|.$ (S46)

The first and second inequalities above are caused by the semi-definitive
properties of the tensor $g_{\mu\nu}$ and $Q_{\mu\nu}$, respectively. These
inequality relations give the lower bound of the integral of the quantum
metric [7]. This lower bound recently has been used to explain the phase
stiffness of the twisted bilayer graphene flat band [8].

Now, we introduce a useful formula to calculate the quantum geometric tensor
of a single band (labeled by $n$):

$\displaystyle Q_{\mu\nu}=\sum_{m}^{m\neq n}\frac{\langle
u_{n}(\boldsymbol{k})|\partial_{k_{\mu}}\hat{H}_{\boldsymbol{k}}|u_{m}(\boldsymbol{k})\rangle\langle
u_{m}(\boldsymbol{k})|\partial_{k_{\nu}}\hat{H}_{\boldsymbol{k}}|u_{n}(\boldsymbol{k})\rangle}{\left(E_{n}(\boldsymbol{k})-E_{m}(\boldsymbol{k})\right)^{2}},$
(S47)

where
$\hat{H}_{\boldsymbol{k}}=\exp(-\mathrm{i}\boldsymbol{k}\cdot\boldsymbol{r})\hat{H}\exp(\mathrm{i}\boldsymbol{k}\cdot\boldsymbol{r})$.
The power of this formula in the numerical calculation is that the Bloch wave
functions do not need to have a smooth gauge at different crystal momentum
$\boldsymbol{k}$.

To compare the geometric tensor of the cavity graphene and the Haldane model,
we show the tensor for a general two-band model. If we consider a two-band
Dirac-type Hamiltonian

$\displaystyle\mathcal{H}(\boldsymbol{k})=\boldsymbol{d}(\boldsymbol{k})\cdot\boldsymbol{\sigma}.$
(S48)

Here all components of $\boldsymbol{d}$ are real functions. Normally, we call
$\boldsymbol{d}$ the characteristic vector. First, we show the eigenstates of
Eq. (S48) as follows

$\displaystyle|\psi_{+}\rangle$
$\displaystyle=\left(\begin{array}[]{c}e^{-\mathrm{i}\phi}\cos{\frac{\theta}{2}}\\\
\sin{\frac{\theta}{2}}\end{array}\right),$ (S51)
$\displaystyle|\psi_{-}\rangle$
$\displaystyle=\left(\begin{array}[]{c}e^{-\mathrm{i}\phi}\sin{\frac{\theta}{2}}\\\
-\cos{\frac{\theta}{2}}\end{array}\right).$ (S54)

where the eigenstates $|\psi_{\pm}\rangle$ have the eigenenergies
$E_{\pm}(\boldsymbol{k})=\pm|\boldsymbol{d}(\boldsymbol{k})|$. The
characteristic vector $\boldsymbol{d}$ is parameterized by the spherical
angles $\theta$ and $\phi$. Then the quantum geometric tensor for the lowest
band can be expressed as

$\displaystyle g_{\mu\nu}$
$\displaystyle=\frac{1}{4}\frac{\partial\boldsymbol{n}}{\partial
k_{\mu}}\cdot\frac{\partial\boldsymbol{n}}{\partial k_{\nu}},$ (S55)
$\displaystyle\mathcal{F}_{xy}$
$\displaystyle=\frac{1}{2}(\frac{\partial\boldsymbol{n}}{\partial
k_{x}}\times\frac{\partial\boldsymbol{n}}{\partial
k_{y}})\cdot\boldsymbol{n},$ (S56) $\displaystyle\boldsymbol{n}$
$\displaystyle=\frac{\boldsymbol{d}}{|\boldsymbol{d}|}.$ (S57)

The imaginary part of $Q_{\mu\nu}$ is related to a topological number $C_{1}$
[9], which is the first Chern number [10]:

$\displaystyle C_{1}$
$\displaystyle=\frac{1}{2\pi}\int_{\text{FBZ}}d^{2}k\,\mathcal{F}_{xy}=\frac{1}{4\pi}\int_{\text{FBZ}}d^{2}k\left(\frac{\partial\boldsymbol{n}}{\partial
k_{x}}\times\frac{\partial\boldsymbol{n}}{\partial
k_{y}}\right)\cdot\boldsymbol{n}.$ (S58)

The integrand element $(\frac{\partial\boldsymbol{n}}{\partial
k_{x}}\times\frac{\partial\boldsymbol{n}}{\partial k_{y}})\cdot\boldsymbol{n}$
in Eq. (S58) is the differential solid angle on the unit sphere formed by
$\boldsymbol{n}$, which maps the FBZ (a Torus manifold) to a sphere. Hence,
the first Chern number counts how many times $T^{2}$ wraps around $S^{2}$
through the mapping $f$. The phases with non-zero $C_{1}$ are non-trivial
topological phases, while $C_{1}=0$ corresponds to the trivial phase. However,
the integral of the quantum metric tensor $g_{\mu\nu}$ is not quantized by a
topological invariant, which is thus a geometric quantity.

For a general Dirac Hamiltonian

$\displaystyle\mathcal{H}(\mathbf{k})=\sum_{i}f_{i}(\mathbf{k})\Gamma_{i},$
(S59)

where $f_{i}(\mathbf{k})$ is a real function and $d_{M}$-dimensional
$\Gamma_{i}$ matrices satisfy the Clifford’s algebra
$\\{\Gamma_{i},\Gamma_{j}\\}$, $Q_{\mu\nu}$ has the following form [11]

$\displaystyle
Q_{\mu\nu}=\sum_{i,j}\partial_{\mu}f_{i}\partial_{\nu}f_{j}\frac{d_{M}(\delta_{ij}-\hat{f}_{i}\hat{f}_{j}-i\epsilon_{ijk}\hat{f}_{k})}{8f^{2}}.$
(S60)

##  V Quantum geometry of graphene and Haldane model

This section will discuss the quantum geometry of the single-layer graphene
lattice models. First, we introduce the tight-binding model of graphene with
nearest-neighbor hopping $t$ and onsite energy split $\Delta$. The Hamiltonian
of the graphene is

$\displaystyle
h=\left(\begin{array}[]{cc}\Delta&t[1+T(\boldsymbol{a}_{1})+T^{\dagger}(\boldsymbol{a}_{2})]\\\
t[1+T^{\dagger}(\boldsymbol{a}_{1})+T(\boldsymbol{a}_{2})]&-\Delta\end{array}\right),$
(S63)

where $T(\boldsymbol{a}_{i})$ is the translation operator for
$\boldsymbol{a}_{i}$ displacement, which can be expressed as
$\sum_{\boldsymbol{R}}|\boldsymbol{R}+\boldsymbol{a}_{i}\rangle\langle\boldsymbol{R}|$.
In momentum space, the Hamiltonian becomes

$\displaystyle
h(\boldsymbol{k})=\left(\begin{array}[]{cc}\Delta&t[1+e^{-\mathrm{i}k_{1}}+e^{\mathrm{i}k_{2}}]\\\
t[1+e^{\mathrm{i}k_{1}}+e^{-\mathrm{i}k_{2}}]&-\Delta\end{array}\right),$
(S66)

where

$\displaystyle\boldsymbol{k}$
$\displaystyle=\sum_{i}\frac{k_{i}}{2\pi}\boldsymbol{b}_{i},$ (S67)
$\displaystyle k_{i}$ $\displaystyle=\boldsymbol{a}_{i}\cdot\boldsymbol{k}.$
(S68)

The corresponding characteristic vector is

$\displaystyle\boldsymbol{d}(\boldsymbol{k})$
$\displaystyle=\left(t(1+\cos{k_{1}}+\cos{k_{2}}),t(1+\sin{k_{1}}-\sin{k_{2}}),\Delta\right).$
(S69)

There are two important points in the Brillouin zone called $K$ and
$K^{\prime}$ where the two energy bands touch, and the direction of the
characteristic vector becomes ill-defined. The position vectors of $K$ and
$K^{\prime}$ are $\boldsymbol{K}=2(\boldsymbol{b}_{1}+\boldsymbol{b}_{2})/3$
and
$\boldsymbol{K}^{\prime}=(\boldsymbol{b}_{1}+\boldsymbol{b}_{2})/3=-\boldsymbol{K}+\boldsymbol{b}_{1}+\boldsymbol{b}_{2}$,
respectively. Around $K$ and $K^{\prime}$ points, the Hamiltonian becomes a
massive Dirac Hamiltonian:

$\displaystyle h_{K}(\boldsymbol{\kappa})$
$\displaystyle=h(\boldsymbol{K}+\boldsymbol{\kappa})\approx\Delta\sigma_{z}-\frac{3t}{2}(\kappa_{x}\sigma_{y}-\kappa_{y}\sigma_{x}),$
(S70) $\displaystyle h_{K^{\prime}}(\boldsymbol{\kappa})$
$\displaystyle=h(\boldsymbol{K}^{\prime}+\boldsymbol{\kappa})\approx\Delta\sigma_{z}-\frac{3t}{2}(\kappa_{x}\sigma_{y}+\kappa_{y}\sigma_{x}).$
(S71)

We see that at $K$ and $K^{\prime}$, there is an energy gap $2\Delta$. When
$\Delta\to 0$, these Hamiltonians approximately describe Dirac-Weyl particles.
The Berry curvature at $K$ ($\boldsymbol{K}$) or $K^{\prime}$
($-\boldsymbol{K}$) point is approximated as

$\displaystyle\mathcal{F}_{xy}(\pm\boldsymbol{K}+\boldsymbol{\kappa})$
$\displaystyle=\frac{1}{2}(\frac{\partial\boldsymbol{d}}{\partial\kappa_{x}}\times\frac{\partial\boldsymbol{d}}{\partial\kappa_{y}})\cdot\frac{\boldsymbol{d}}{d^{3}}\approx\pm\frac{\delta}{2(\boldsymbol{\kappa}^{2}+\delta^{2})^{3/2}},$
(S72)

where $\delta=2\Delta/(3|t|)$. States around $K$ ($\boldsymbol{K}$) or
$K^{\prime}$ ($-\boldsymbol{K}$) point have opposite signs of the Berry
curvature and will produce inverse Berry phases as follows

$\displaystyle\int
d^{2}\boldsymbol{\kappa}\,\mathcal{F}_{xy}(\pm\boldsymbol{K}+\boldsymbol{\kappa})=\pm\pi\,\,\text{sign}(\delta),$
(S73)

When summarizing the Berry phases at $K$ and $K^{\prime}$, one observes zero
since the time-reversal symmetry always makes the total Berry phase vanish.

We use the same way to calculate the quantum metric of Dirac particles around
$K$ and $K^{\prime}$ points. Let us first derive the results around $K$ point,

$\displaystyle\frac{\partial\boldsymbol{n}}{\partial\kappa_{\mu}}$
$\displaystyle=-\frac{\epsilon_{\mu\nu}\mathbf{e}_{\nu}}{\sqrt{\kappa^{2}+\delta^{2}}}-\frac{\kappa_{\mu}\boldsymbol{n}}{\kappa^{2}+\delta^{2}},$
(S74) $\displaystyle g_{xx}$
$\displaystyle=\frac{1}{4}\frac{\kappa_{y}^{2}+\delta^{2}}{(\kappa^{2}+\delta^{2})^{2}},$
(S75) $\displaystyle g_{yy}$
$\displaystyle=\frac{1}{4}\frac{\kappa_{x}^{2}+\delta^{2}}{(\kappa^{2}+\delta^{2})^{2}},$
(S76) $\displaystyle g_{xy}$
$\displaystyle=-\frac{1}{4}\frac{\kappa_{x}\kappa_{y}}{(\kappa^{2}+\delta^{2})^{2}}.$
(S77)

We can see that all of the $g_{\mu\nu}$ components have the order
$1/\kappa^{2}$ as $\kappa\to\infty$. Thus, the integrals of them all have
ultraviolet divergence. However, we find that the quantum geometric volume
$d^{2}k\sqrt{\text{det}(g)}$ for the Dirac particles has a convergent value
after integrating over the total momentum space since the volume form

$\displaystyle\sqrt{\text{det}(g(\pm\boldsymbol{K}+\boldsymbol{\kappa}))}=\frac{1}{2}|\mathcal{F}_{xy}(\pm\boldsymbol{K}+\boldsymbol{\kappa})|$
(S78)

is equal to the absolute value of the Berry curvature. Unlike the total Berry
phase, which vanishes, the quantum geometric volume

$\displaystyle\mathcal{V}=\frac{1}{\pi}\int_{\text{BZ}}d^{2}\boldsymbol{k}\sqrt{\text{det}(g(\boldsymbol{k}))}$
(S79)

for the graphene is approximated as 1.

So far, we have looked at the quantum geometric phases produced by the
particles around $K$ and $K^{\prime}$ points when $\Delta\to 0$. For a finite
split energy $\Delta$, we use a numerical calculation to study the quantum
geometry. By discretizing the BZ by $200\times 200$ lattices, we calculate the
QGT of graphene with parameters $t=-1$ and $\Delta=0.1,0.2,0.6$. We show the
distributions of the QGT for the lowest band in Figs. S3 (a)-(c). We can see
that as $\Delta$ increases, which makes the energy band more flat, the quantum
geometry becomes more flattened.

Figure S3: The components of the quantum geometric tensor of the graphene
lowest band. The on-site energy split is set as $\Delta=0.1,0.2,0.6$ in (a),
(b) and (c), respectively. The nearest-neighboring hopping $t=-1$. Figure S4:
Quantum geometric tensor of the lowest band of the Haldane model described by
the Hamiltonian Eq. (S83). The fixed parameters are $t=-1$, $u=0.14$,
$\varphi=3\pi/4$. We have chosen different onsite energy splits $\Delta$ as 0,
0.2, and 1 in (a)-(c) respectively.

Let us review the Haldane model on honeycomb lattices. We can obtain the
Haldane model with a non-trivial Chern number by generalizing the graphene
model shown in Fig. S1 with next-nearest hopping carrying magnetic flux
$\varphi$. Here, we first write its lattice Hamiltonian as follows

$\displaystyle H$
$\displaystyle=h+u\\{\left(\begin{array}[]{cc}{e^{-\mathrm{i}\varphi}}&{}\hfil\\\
{}\hfil&{e^{\mathrm{i}\varphi}}\end{array}\right)[T(\boldsymbol{a}_{1})+T(\boldsymbol{a}_{2})+T^{\dagger}(\boldsymbol{a}_{1}+\boldsymbol{a}_{2})]+\text{h.c.}\\}.$
(S82)

Here, $h$ is the graphene lattice Hamiltonian Eq. (S63), and we have removed
the onsite energy. By using discrete Fourier transformation, we obtain the
Bloch Hamiltonian as

$\displaystyle\mathcal{H}(\boldsymbol{k})$
$\displaystyle=h(\boldsymbol{k})+\sum_{i=1}^{3}2u\cos\varphi\cos{(\boldsymbol{k}\cdot\boldsymbol{a}_{i})}\,\sigma_{0}-2u\sin\varphi\sin{(\boldsymbol{k}\cdot\boldsymbol{a}_{i})}\,\sigma_{z},$
(S83)

where $h(\boldsymbol{k})$ is defined in Eq. (S66) and
$\boldsymbol{a}_{i}=\sqrt{3}a_{0}(\cos(\pi/6+2i\pi/3),\sin(\pi/6+2i\pi/3))$
($i=1,2$). The characteristic vector is

$\displaystyle\boldsymbol{d}(\boldsymbol{k})$
$\displaystyle=\left(t(1+\cos{k_{1}}+\cos{k_{2}}),t(1+\sin{k_{1}}-\sin{k_{2}}),\Delta-2u\sin\varphi\sum_{i=1}^{3}\sin{(\boldsymbol{k}\cdot\boldsymbol{a}_{i})}\right).$
(S84)

Around $K$ and $K^{\prime}$ points, the Hamiltonian becomes

$\displaystyle h_{K}(\boldsymbol{\kappa})$
$\displaystyle=h(\boldsymbol{K}+\boldsymbol{\kappa})\approx\Delta_{K}\sigma_{z}-\frac{3t}{2}(\kappa_{x}\sigma_{y}-\kappa_{y}\sigma_{x})-\frac{3}{2}u\cos\varphi,$
(S85) $\displaystyle h_{K^{\prime}}(\boldsymbol{\kappa})$
$\displaystyle=h(\boldsymbol{K}^{\prime}+\boldsymbol{\kappa})\approx\Delta_{K^{\prime}}\sigma_{z}-\frac{3t}{2}(\kappa_{x}\sigma_{y}+\kappa_{y}\sigma_{x})-\frac{3}{2}u\cos\varphi.$
(S86)

Here, we define

$\displaystyle\Delta_{K}$
$\displaystyle=\Delta+2u\sqrt{3}\sin\varphi=\frac{3|t|}{2}\delta_{K},$ (S87)
$\displaystyle\Delta_{K^{\prime}}$
$\displaystyle=\Delta-2u\sqrt{3}\sin\varphi=\frac{3|t|}{2}\delta_{-K}.$ (S88)

By replacing the $\delta$ in Eq. (S72) by $\delta_{K}$ or $\delta_{-K}$, we
obtain the quantum geometric tensor around $K$ or $K^{\prime}$ point:

$\displaystyle\mathcal{F}_{xy}^{\pm\boldsymbol{K}}(\boldsymbol{\kappa})$
$\displaystyle=\pm\frac{\delta_{\pm K}}{2(\boldsymbol{\kappa}^{2}+\delta_{\pm
K}^{2})^{3/2}},$ (S89) $\displaystyle g^{\pm K}_{xx}(\boldsymbol{\kappa})$
$\displaystyle=\frac{1}{4}\frac{\kappa_{y}^{2}+\delta_{\pm
K}^{2}}{(\kappa^{2}+\delta_{\pm K}^{2})^{2}},$ (S90) $\displaystyle g^{\pm
K}_{yy}(\boldsymbol{\kappa})$
$\displaystyle=\frac{1}{4}\frac{\kappa_{x}^{2}+\delta_{\pm
K}^{2}}{(\kappa^{2}+\delta_{\pm K}^{2})^{2}},$ (S91) $\displaystyle g^{\pm
K}_{xy}(\boldsymbol{\kappa})$
$\displaystyle=-\frac{1}{4}\frac{\kappa_{x}\kappa_{y}}{(\kappa^{2}+\delta_{\pm
K}^{2})^{2}}.$ (S92)

and the corresponding total Chern number

$\displaystyle\frac{\text{sign}(\delta_{K})-\text{sign}(\delta_{-K})}{2}=\frac{\text{sign}(\Delta+2u\sqrt{3}\sin\varphi)-\text{sign}(\Delta-2u\sqrt{3}\sin\varphi)}{2}.$
(S93)

We now show the quantum geometries of the Haldane model in the Brillouin zone
in Fig. S4. The hopping amplitudes used in Fig. S4 are chosen as $t=-1$ and
$u=0.14$. The corresponding onsite energy split of the sublattices in (a)-(c)
is written underneath the label. Unlike the Landau level, which has constant
Berry curvature and quantum geometric metric over BZ, the Haldane model has a
non-uniform distribution of the geometric tensor in the momentum space [12,
13, 7]. When $\Delta$ crosses $\Delta_{c}=\sqrt{6}u\approx 0.343$, the Chern
number becomes trivial. Thus, the Berry curvature around $K^{\prime}$ point
becomes negative when $\Delta=1>\Delta_{c}$.

In the main text, we have used the emergent gauge field and Peierls
substitution to derive the Hamildane model. For the fixed parameters (we
mentioned under Eq. (S36)) in the main text, we obtain
$\varphi=3\pi/4\exp(-\pi^{2}/27)$ at $g/\omega_{c}=1$. In principle,
increasing the coupling strength can increase the magnetic flux and probably
lead to the topological phase transition based on Eq. (S93) [14]. However, it
does not happen in the numerical results as we see the reentrant trivial phase
when $g/\omega_{c}$ is high in the main text and in Ref. [2]. We argue that
this is because Peierl substitution is a qualitative approximation to deal
with the classical vector potential in the Hamiltonian, and the accurate phase
factor of the hoppings may deviate from the magnetic flux $\varphi$ [15]. In
the tight-binding Hamiltonian built from the lattice model, $t$, $u$, and
$\varphi$ in Eq. (S83) are independent parameters. However, they are all
related to the more fundamental parameters of the system, especially the
coupling strength $g/\omega_{c}$.

##  VI Chern number calculation through Wilson loop formalism

If we numerically integrate the discrete values of the Berry curvatures over
the BZ mesh, we will not get an exact integer Chern number. To confirm the
non-trivial Chern number in Fig. 2 in the main text, one should resort to the
Wilson loop formalism [3, 16]. The (abelian) Wilson loop over the $n$-th band
along the loop $k_{2}:0\to 2\pi$ is defined as follow

$\displaystyle\mathcal{W}_{k_{2}}(k_{1})=\lim_{N_{2}\to\infty}\prod_{m=1}^{N_{2}}\langle
u_{n}(k_{1},k_{2}+\frac{2\pi
m}{N_{2}})|u_{n}(k_{1},k_{2}+\frac{2\pi(m-1)}{N_{2}})\rangle,$ (S94)

where $k_{i}$ is defined through Eq. (S35), and
$|u_{n}(\boldsymbol{k})\rangle$ is the Bloch wave function with the gauge
$|u_{n}(\boldsymbol{k})\rangle=|u_{n}(\boldsymbol{k}+\boldsymbol{K})\rangle$.
Then, the Chern number of the $n$-th band is related to the phase flow of the
Wilson loop from $k_{1}$ to $k_{1}+2\pi$:

$\displaystyle\mathcal{C}$
$\displaystyle=\frac{\varphi(k_{1}+2\pi)-\varphi(k_{1})}{2\pi},$ (S95)
$\displaystyle\varphi(k_{1})$
$\displaystyle=\text{arg}(\mathcal{W}_{k_{2}}(k_{1})).$ (S96)

Note that $\varphi(k_{1})$ should be made continuous. In Fig. S5, we show the
numerical results of $\varphi(k_{1})$ for the lowest band of the cavity
graphene model in the domain $k_{1}\in[0,2\pi]$. The corresponding parameters
are chosen as $\omega_{c}=2$, $g/\omega_{c}=1$, $V_{0}=m=1.5$ and $\Delta=0$
(left) or $\Delta=1$ (right). In the numerical calculation, we discretize the
loops of $k_{1}:0\to 2\pi$ and $k_{2}:0\to 2\pi$ by $N_{1}=100$ and $N_{2}=30$
lattice points. We see that the smooth change of the phase $\varphi$ over the
loop $k_{1}:0\to 2\pi$ is $2\pi$ for the left figure, and 0 for the right
figure, respectively. This confirms the non-trivial Chern number of the
lowest-band Berry curvature in Fig. 2 of the main text.

Figure S5: Phase flow of the Wilson loop along $k_{1}:0\to 2\pi$ of the lowest
band of the cavity graphene. The cavity parameter used here are
$\omega_{c}=2$, $g/\omega_{c}=1$, and the material parameters are set as
$V_{0}=m=1.5$ and $\Delta=0$ (left) or $1$ (right). We can see that the smooth
change of the phase is $2\pi$ for the left figure and 0 for the right.

##  VII Valley energy splitting in a general cavity with hybrid chirality

We numerically calculate the lowest energy band of the effective Hamiltonian
Eq. (S24) with different hybrid degree $\theta$. In Fig. S6 (a), we show the
energy shift of valleys $K$ and $K^{\prime}$ for the system with $\Delta=0.6$.
We find that if the cavity photon has net chiral component, the energy shift
of valleys becomes different. Apart from that, $K^{\prime}$ ($K$) valley
becomes more energetic in the hybrid-chiral cavity when $0<\theta<\pi/4$
($\pi/4<\theta<\pi/2$). However, if the photon is linearly polarized at
$\theta=\pi/4$, the two valleys are degenerate since the time reversal
symmetry holds again.

For more details about how the valley energy split can be changed by the
hybrid degree of the photon chirality, we calculate the ratio of the energy
difference $E_{K}-E_{K^{\prime}}$ to the bandwidth $\delta E$, which is
estimated by $\max(E_{K},E_{K^{\prime}})-E_{\Gamma}$. The calculation is
processed with fixed sub-lattice energy split $\Delta=0.6$ at several coupling
strength factors $g/\omega_{c}=0.5,0.75,1$. In Fig. S6) (b), we see that the
split of the two valleys changes the sign as $\theta$ exceeds $\pi/4$. Also,
for the chiral cavities, the ratio $(E_{K}-E_{K^{\prime}})/\delta E$ is
increased if the coupling strength becomes larger. This means that for a
$C_{2}$-symmetry-breaking material in a chiral cavity, the energy imbalance of
the two valleys can be increased if one makes the light-matter coupling
stronger.

Figure S6: (a) The lowest energy band of the graphene in a cavity with hybrid
chirality defined in Eq. S4. The onsite energy split here is $\Delta=0.6$. By
tuning $\theta$ from 0 to $\pi/2$, the energy difference of the two valleys
changes the sign. At $\theta=\pi/4$ when the photons in the cavity become all
linearly polarized, the two valleys become degenerate. (b) The valley energy
split ratio $(E_{K}-E_{K^{\prime}})/\delta E$ as $\theta$ changes. We show the
results with different coupling strength factors $g/\omega_{c}=0.5,0.75,1$.

##  VIII The photon number change in a function of the coupling strength

In the main text, we have analyzed the photon number of the light-matter
interacting bands. Here, we complement the results of the photon number change
during the interband excitation in a function of the coupling strength
$g/\omega_{c}$ with a fixed sub-lattice split $\Delta$. In Fig. S7 (a), we
present the change of photon numbers $\Delta n_{p}$ for a light-matter
interacting state at $K$ and $K^{\prime}$ points during the transition from
the lowest to the upper band for $\Delta=0.6$ across a range of $g/\omega_{c}$
from 0 to 2. The associated energy gap within the same range is illustrated in
(b), aiding in identifying points of topological phase transition where the
gap closes. Through (a), we observe that $\Delta n_{p}(K)$ consistently
remains positive with increasing $g/\omega_{c}$, while $\Delta
n_{p}(K^{\prime})$ changes sign as the Chern number becomes zero. The
transition in Chern number aligns with the sign change of Berry curvature
around $K^{\prime}$ (refer to Eqs. (S89) and (S93)). Consequently, we can
conclude that the signs of $\Delta n_{p}(K)$ and $\Delta n_{p}(K^{\prime})$
are governed by the Berry curvature’s signs in that region. Note that this
conclusion is within the regime where the energy gap is much smaller than the
single-photon energy $\hbar\omega_{c}$ (see (b)).

Figure S7: (a): The photon number changes during the interband excitation from
the lowest band to the upper band in a function of the coupling strength
$g/\omega_{c}$ ranging from 0 to 2. The sub-lattice split is set to be
$\Delta=0.6$. The dashed lines label two topological transition points at
$g/\omega_{c}=0.453$ and $g/\omega_{c}=1.301$. (b): The energy gap between the
lowest energy band and the upper band. We observe that the system is off-
resonant, indicated by the condition $\Delta E\ll\hbar\omega_{c}$, and thus
the tunneling from the lower band to the upper band at $K^{\prime}$ point cost
the minimal excitation energy.

## References

  * Ashida  _et al._ [2021] Y. Ashida, A. m. c. İmamoğlu, and E. Demler, Cavity quantum electrodynamics at arbitrary light-matter coupling strengths, Phys. Rev. Lett. 126, 153603 (2021).
  * Masuki and Ashida [2023] K. Masuki and Y. Ashida, Berry phase and topology in ultrastrongly coupled quantum light-matter systems, Phys. Rev. B 107, 195104 (2023).
  * Resta [1994] R. Resta, Macroscopic polarization in crystalline dielectrics: the geometric phase approach, Rev. Mod. Phys. 66, 899 (1994).
  * Marzari and Vanderbilt [1997] N. Marzari and D. Vanderbilt, Maximally localized generalized wannier functions for composite energy bands, Phys. Rev. B 56, 12847 (1997).
  * Resta [2006] R. Resta, Kohn’s theory of the insulating state: A quantum-chemistry viewpoint, The Journal of Chemical Physics 124, 104104 (2006).
  * Resta [2011] R. Resta, The insulating state of matter: a geometrical theory, The European Physical Journal B 79, 121 (2011).
  * Ozawa and Mera [2021] T. Ozawa and B. Mera, Relations between topology and the quantum metric for chern insulators, Phys. Rev. B 104, 045103 (2021).
  * Xie  _et al._ [2020] F. Xie, Z. Song, B. Lian, and B. A. Bernevig, Topology-bounded superfluid weight in twisted bilayer graphene, Phys. Rev. Lett. 124, 167002 (2020).
  * Qi  _et al._ [2006] X.-L. Qi, Y.-S. Wu, and S.-C. Zhang, Topological quantization of the spin hall effect in two-dimensional paramagnetic semiconductors, Phys. Rev. B 74, 085308 (2006).
  * Thouless  _et al._ [1982] D. J. Thouless, M. Kohmoto, M. P. Nightingale, and M. den Nijs, Quantized hall conductance in a two-dimensional periodic potential, Phys. Rev. Lett. 49, 405 (1982).
  * Ahn  _et al._ [2020] J. Ahn, G.-Y. Guo, and N. Nagaosa, Low-frequency divergence and quantum geometry of the bulk photovoltaic effect in topological semimetals, Phys. Rev. X 10, 041041 (2020).
  * Roy [2014] R. Roy, Band geometry of fractional topological insulators, Phys. Rev. B 90, 165139 (2014).
  * Ledwith  _et al._ [2020] P. J. Ledwith, G. Tarnopolsky, E. Khalaf, and A. Vishwanath, Fractional chern insulator states in twisted bilayer graphene: An analytical approach, Phys. Rev. Res. 2, 023237 (2020).
  * Haldane [1988] F. D. M. Haldane, Model for a quantum hall effect without landau levels: Condensed-matter realization of the ”parity anomaly”, Phys. Rev. Lett. 61, 2015 (1988).
  * Kohn [1959] W. Kohn, Theory of bloch electrons in a magnetic field: The effective hamiltonian, Phys. Rev. 115, 1460 (1959).
  * Alexandradinata  _et al._ [2014] A. Alexandradinata, X. Dai, and B. A. Bernevig, Wilson-loop characterization of inversion-symmetric topological insulators, Phys. Rev. B 89, 155114 (2014).


11institutetext: (1) University of Bergen, Norway, 11email:
<EMAIL_ADDRESS>22institutetext: (2) University of Agder, Norway,
22email<EMAIL_ADDRESS>
# Big Data

Andreas L. Opdahl 11 Vimala Nunavath 2211

###### Abstract

The Internet of Things, crowdsourcing, social media, public authorities, and
other sources generate bigger and bigger data sets. Big and open data offers
many benefits for emergency management, but also pose new challenges. This
chapter will review the sources of big data and their characteristics. We then
discuss potential benefits of big data for emergency management along with the
technological and the societal challenges it poses. We review central
technologies for big-data storage and processing in general, before presenting
the Spark big-data engine in more detail. Finally, we review ethical and
societal threats that big data pose.

##  1 What is Big Data?

There is already much more data available on the internet than humans can
meaningfully process. Spread out among this data may lie central keys to
prevent and better manage emergencies. To unlock the knowledge they contain,
big data sets must become effectively processable by machines and the results
easily interpretable for humans (Berners-Lee et al, 2001).

Big data is a broad term with many related meanings on the technical,
computing, data, and usage levels. On the technical-infrastructure level, big
data has often been used about data collections that are too large to be
straightforwardly handled with traditional mainstream data-processing
techniques and tools. Starting in the 2000s, big internet companies like
Google, Amazon, and Facebook found they needed new ways and new software tools
to store and process the enormous data collections they were amassing at the
hearts of their businesses. The result was a new generation of distributed
technologies we will review later in this chapter: file systems such as HDFS;
grid and cloud technologies such as Amazon’s Web Services (AWS); big-data
stores such as Cassandra; and big-data processing engines such as Spark.

On the computing level, big-data computing methods also differ from past
mainstream approaches. Most importantly, they need to be highly distributed
because computing, networking, and storage demands can go way beyond the
abilities of single computers. In consequence, computing must also be fault-
tolerant because, when a distributed system consists of hundreds or thousands
of computers, failing components become the norm rather than the exception. To
achieve this, big-data computing must therefore be highly redundant, so that
each computation is carried out and each piece of data stored in several
places simultaneously, and so that computation can go on even when some of the
computers, disks, or networks fail. While solutions to each of these problems
have existed for a long time, big-data computing has brought them together in
new techniques and tools and moved their use from the fringe into the
mainstream (Ghemawat et al, 2003; Dean and Ghemawat, 2008; Lakshman and Malik,
2010; Zaharia et al, 2016).

On the data level, big data refers to _“the three Vs”_ : data that has large
volume, arrives at high velocity, and has great variety — consisting of both
structured data, natural language, images, audio, and video (Kitchin, 2014).
While earlier mainstream approaches could deal with two of these at the
expense of the third, the ability to support all three “Vs” at the same time
is a central requirement of big data. Two more “Vs” are that big data must be
valid or true (veracity) and provide value to users. In addition, big data
aims to be exhaustive, by representing each and every relevant phenomenon
rather than just a sample. It tends to be fine-grained, by representing every
available piece of information in the life-cycle of a phenomenon. It is
indexical, in that it uses, as much as possible, standard identifiers for
phenomena, attributes, and events. It is relational, in the sense that
information about different phenomena are connected by use of standard
identifiers. It is also easily extendible to new types of phenomena,
attributes and events and scalable in size as more information is added. It is
historical, by representing not just current but also all previous states of
phenomena. And it can be opportunistic, in the sense that data is stored
exhaustively, historically and in full detail because it can potentially
generate value in the future, even if it is not yet needed today (Kitchin,
2014). Despite including the word “big”, data size is less used as a central
characteristic of big data. Although the big global players today manage data
collections in the peta- ($10^{15}$) and exabyte ($10^{18}$) range, many
smaller- and medium-sized companies find big-data techniques essential for
creating value from datasets with high variety and velocity, even when the
volumes are much smaller.

Finally, on the usage level, big data refers to new data-driven ways of
managing and organising private, public, and ideal enterprises. So-called
data-driven projects, businesses/organisations, and societies continuously
harvest exhaustive, fine-grained data about their inner workings and
environment. They process the data in real time, using machine learning
techniques on historical data to continuously describe and diagnose the past
and present in order to optimally predict the future and prescribe optimal
actions in advance (Kitchin, 2014).

##  2 Big Data Sources for Emergency Management

Several organisations provide online overviews of big and other data sources
that can be useful in emergencies. The Humanitarian Data Exchange
(HDX111https://data.humdata.org) indexes more than 6000 crisis-relevant data
sets, searchable by features, location, format, organisation, license, year,
and general tags. CSV-tables is the most common data format by far.
PreventionWeb222http://www.preventionweb.net offers a portal to diaster-
related datasets and sites across the globe, focussing on past disaster loss
and damage, historical and synthetic hazard catalogues, socio-economic factors
that can impact vulnerability and resilience on a local level, and exposure
data about populations and buildings in particular locations.

General open data sources can also serve as useful references in emergencies.
GeoNames333http://geonames.org is a global database of geographical features
that is searchable and browsable through a map interface.
OpenStreetMap444http://openstreetmap.org is similar, but provides more
detailed information about populated areas. The Humanitarian
OpenStreetMap555http://www.hotosm.org/ is an international network dedicated
to humanitarian action and community development through open mapping, for
example of refugee situations, volcanic eruptions, and ebola outbreaks.
Wikipedia is an important source of open reference data, along with its more
recent sister project Wikidata666http://www.wikidata.org/ for factual and
structured data. Google Crisis Map and Person
Finder777http://www.google.org/\\{crisismap,personfinder\\} are examples of
proprietary data resources that can be leveraged in crisis situations through
well-defined interfaces.

Public authorities on the international, national, and local levels are also
important providers of reference data, for example census and map data. Many
authorities also maintain emergency-relevant data about buildings
(kindergartens, schools, hospitals, care facilities) and statistical data
about their population. More sensitive governmental data include data about
critical infrastructures: water supply and sewage, electricity, communication,
roads and railways, and military installations and operations. Some local
governments may also maintain information about vulnerable citizens that need
particular assistance. In many countries, a wide variety of emergency-related
data sets are already available through portals and data hotels such as
http://data.europa.eu in the EU and http://data.gov in the US. Unfortunately,
many datasets provide only static, aggregated, historical statistics. There
are fewer live web APIs that offer minute-to-minute information.

There are also many closed (for-pay or restricted) data sources provided by
businesses and governments. Some of them have higher quality than their open
counterparts in terms of completeness, correctness, precision, timeliness,
etc. Examples of private and semi-private companies that maintain potentially
emergency-related information are: mapping agencies (maps, buildings, critical
infrastructure); telecommunications companies (location and movement of
subscribers, communication patterns, habits, pictures); transport companies
(movement patterns, locations of people and vehicles); and app providers (many
of the above and more). In some countries, previous government agencies have
been privatised or semi-privatised in recent years, making emergency-relevant
data sources less accessible.

The Internet of Things (IoT) is another source of big data, whose importance
is rapidly growing (Atzori et al, 2010). There are already many times more
things connected to the internet than there are people. These things can be
sensors that measure and observe, such as a thermometer or surveillance
camera, or they can be actuators that change the state of physical things,
such as an alarm or a traffic light. Many things on the internet, such as
mobile phones, can be both sensors and actuators, and they are quickly
becoming smarter. Some of them have enough processing power and storage
capacity to run heavy computing tasks locally, and others run apps that
collaborate tightly with software agents running on more powerful computers in
the cloud. As the Internet of Things continues to grow, it will offer enormous
opportunities for preventing, detecting, limiting, managing, and recovering
from emergency situations, which we discuss in the following section.

Of course, social media is another central source of big data. It is so
important that we devote a separate chapter to it. For research purposes,
CrisisLex888\https://www.crisislex.org/data-collections.html contains brief
descriptions of downloadable emergency-related social-message collections from
the past. In a later chapter we will also discuss emergency-related datasets
that are available in semantic formats (such as RDF and OWL).

##  3 Big Data Benefits and Challenges

###  3.1 Benefits

Big-data analytics can be helpful in all phases of emergency management, from
preparation, through detection and response, to recovery (Castillo, 2016).

For preparation purposes, big data can be used to create baseline models that
describe and diagnose (explain) normal conditions, such as the normal movement
of people and goods in a city; normal consumption of transport services, power
and water; normal geographical and meteorological conditions; and normal
physical conditions inside a building. Diagnosing these and other conditions
calls for big-data analytics because they may be highly dependent on
contextual factors, not only on the most obvious ones, such as the location,
time-of-day, day-of-week, and part-of-year, but also on weather, holidays and
their types, public health situation, state of the economy, accidents and
emergencies, culture and sports events (both local and global, such as the
football World Cup finals). Baseline models can be used to quickly identify
deviating conditions and as input to simulating likely consequences of
deviations, such as choke points or single points of infrastructural failure.
Baselines can also be used for emergency preparation and training and for
post-hoc analysis after the crisis or emergency. Baselines can be created from
measurements and physical-observations from IoT devices and from social media
sensors (see the chapter on social media in this book) that gauge people’s
moods and concerns, augmented with contextual information from private and
public data sets, such as maps and information about buildings,
infrastructure, population, vulnerable citizens, etc.

For detection purposes, potential emergency situations can be identified early
by continuously monitoring people and their environments. In some cases, a
quick response can even prevent an unstable or crisis situation from evolving
into a full-blown emergency. Useful common sensor types include: surveillance
cameras, mobile phones, wearable devices, and social media messages that
signal people who are dangerously crammed together at a public event; all
kinds of indoor heath, humidity, temperature, and light sensors that can
inform about deviations such as break-ins, fires and leakages; positioning
devices in vehicles, combined with mobile phone positioning data, social media
messages, traffic sensors, road cameras, and live weather data that indicate
traffic accidents — or increased risk of such; and, of course, all kinds of
weather sensors combined with satellite images that give the earliest warning
possible about looming deviations from normal geophysical and meteorological
conditions.

For response purposes, similar types of information can be used during an
unfolding emergency both to gain (strategic) situational overviews and
(tactical) actionable insights (Castillo, 2016), for example using map-based
visualisations and interfaces. Information from physical and social sensors
can be corroborated with open and reference data to improve data-quality
attributes such as correctness and trustworthiness. Actuators can be
repurposed to actively relieve and improve the situation. For example, a
traffic light or gated crossing can be taken out of normal operation and
instead be used to direct traffic around an affected area. Remote-controlled
drones and other vehicles can be used to collect detailed information and to
disseminate medical equipment and food. Social media and other communication
technologies can be used in a similar manner (as social actuators) to
disseminate results of big-data analysis and other information back to
responders, victims, and their families and friends.

For recovery purposes, big-data technologies can be used to make full data
traces of the emergency available for post-mortem analysis, both of the
unfolding disaster itself, of its preconditions, of the the detection and
response effort, and of their impacts. Of course, emergency-data traces, when
combined with physical and social baselines and reference data also have
numerous uses in the aftermath of an emergency: for rebuilding and to prevent
or prepare for similar situations in the future.

###  3.2 Challenges

Properly leveraging big-data technologies for emergency management also poses
many challenges. Most of all, big-data harvesting, preparation, curation,
analysis, and interpretation is skill intensive process and demand for big-
data competency is vastly greater than supply. Recruiting people with the
right competencies, both as professional emergency workers and as volunteers,
is therefore a challenging task. Global networks-of-networks are in place for
recruiting, training, and coordinating volunteers in various types of
emergency and environment related activities, for example in global-mapping
activities or satellite-image analysis. Subnetworks of volunteers with
competencies in big-data analytics are called for.

Availability of computing infrastructures is a also an issue, both at the
emergency site and remotely. Cloud computing makes it feasible to create big-
data infrastructures in advance. After they have been set up and tested, the
cloud resources and services can be paused until an emergency occurs. Then
they can be restarted quickly and easily scaled when computing demands
increase. However, advance-preparing for an emergency is hard. Some of the
data and processing needs that arise during an emergency will always be
unexpected, and preparations must therefore focus on flexibility and
responsiveness to change. Availability of computation and communication
facilities near the emergency site can be a bigger issue. For example, local
sensor networks may be damaged or disconnected due to network or power
failure. Aerial-network drones and store-and-forward networking are possible
ways to temporarily reinstate networking capacity in affected areas.
Disseminating analysis results to the affected people is also a challenge,
because most of the techniques and tools have been developed for highly-
trained scientists, business people, and other skilled decision makes.
Communicating the results of complex big-data analyses to emergency workers,
victims, and their families and friends most likely requires different
presentation techniques. In a crisis, criminals, terrorist groups, or hostile
powers may try to exploit or destabilise the situation further. Social media,
which can be used to spread disinformation (misinformation deliberately
intended to deceive), has become a well-known attack vector. Cyberattacks are
another possibility, for example to interfere with critical computer-
controlled infrastructures, to hi-jack or cut off sensors and actuators, or to
compromise the emergency-computing infrastructure itself.

Other challenges are less specific to emergency management. High-velocity data
must be collected in real time from different data sources, of different
types, in different modalities (audio, written text, images, structured data,
etc.), using different formats and access methods (social media, the web, FTP,
web APIs, etc.). Widely heterogeneous data sets must be recombined and
corroborated to create richer situational overviews and facilitate more
reliable actionable insights. The data, in particular from social media, must
be filtered to clear large amounts of noise. Trustworthiness and other quality
features (timeliness, completeness, etc.) must be assessed.

The many ethical issues of big data will be discussed in a later section.

##  4 Big Data Techniques and Tools

Although it builds on theories and techniques that are much older, the big-
data wave gained momentum in the mid 2000s, when data-driven businesses and
big internet companies like Amazon, Facebook, and Google needed new ways to
store and process the rapidly growing data sets they had amassed. The result
was a new generation of techniques and tools for big-data processing that
includes: cloud and grid computing technologies, distributed file systems, new
types of database management systems, and new distributed computing engines.
Many of the ideas they build on are old, but the tools themselves are new, and
big data have made their use much more widespread.

Big data is made possible by improvements in computing power, storage
capacity, and network bandwidth (Kitchin, 2014). In addition, new sources of
large data sets have emerged, such as social media, the Cloud/Internet of
Things (IoT/ClouT), and ubiquitous and pervasive computing. Important enablers
on the computing side are cloud and grid techniques. Grid computing lets many
loosely-coupled computers distributed across the net perform large computing
tasks together. Cloud computing leverages grids to offer highly scalable
services to end-users, such as massive data storage, powerful virtual and
remote servers, big-data analysis services, and much more.

For example, Amazon Web Services (AWS999https://aws.amazon.com/) uses large
grids to offer a wide range of scalable storage, computation and analysis
services in the cloud. AWS’ Elastic Compute Cloud (Amazon
EC2101010https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)
servers appear to their users as regular computers accessible over the net,
but they are virtual: each of them may be running on only a small part of a
physical machine, or it can run on a large grid of machines. Virtual servers
can be quickly and easily created, started, stopped, restarted, resized,
replicated, and even moved between data centres on different continents as
computing demands change. A new cloud server can be instantiated in minutes,
either as a clean Linux or Windows computer or by instantiating an existing
Amazon Machine Image (AMI) that represents a predefined computer
configuration, such as a big-data set-up designed specifically for emergency
computing. There are two common approaches to create an AMI in Linux. The
first approach is to start from an existing public AMI and modify it according
to the users’ requirements. The second approach is to build a fresh
installation, either on a standalone machine or on an empty file system
mounted by loopback (Huang et al, 2010). Amazon also offers a choice between
two types of storage services: Elastic Block Store (EBS) and Simple Storage
Service (S3), along with management services such as checkpointing and
security policies.

New file systems such as the Google File System (GFS, later renamed Colossus)
(Ghemawat et al, 2003) and Apache’s open-source HDFS (Hadoop Distributed File
System111111See https://hadoop.apache.org/.) are able to handle big-data
volumes by distributing data storage across many computers, possibly in the
tens of thousands. On these scales, data storage (and computing) must be
fault-tolerant because failing components become the norm rather than the
exception. Each big-data file (possibly of tera- or petabyte size) is
therefore split into blocks (e.g., 128Mb each) that are stored on different
computers, called data nodes in HDFS. To achieve fault tolerance, the same
block is replicated on several data nodes (sharding). Inside a data centre,
the nodes are grouped into racks that correspond to physically co-located sub-
networks of computing nodes served by the same router. HDFS attempts to shard
each block across nodes that belong to different racks so that, if a rack
becomes unavailable due to router failure or power outage, other copies of the
blocks it stores will be available from other racks. A single name node
handles client requests and keeps track of where the blocks in each file are
stored. The name node thus makes HDFS appear as a single logical file store to
client programs, although data is transmitted directly between clients and
data nodes. Communication with clients and between HDFS nodes use TCP/IP,
making it easy to include heterogeneous computing nodes in the same cluster
(which is then often called a grid). To avoid making the name node a single-
point of failure, other data nodes are continuously monitoring their name node
and are always ready to step up should it lose connection. As with many big-
data technologies, HDFS is optimised for mostly immutable files: the initial
write and the subsequent reads of a file are much faster and use less
resources than updating the file after it has been created.

The new distributed file systems quickly inspired similarly distributed
database management systems (DDBMS), designed to accommodate big-data
collections (tera- and petabytes) in a flexible way. In addition to supporting
higher numbers of data items of the same type (vertical scaling in volume),
new big-database systems also emphasise supporting rapidly evolving
information needs of different types (horizontal scaling in variety). To
achieve this, they deviate in several ways from traditional relational and
SQL-based data models, giving them the name Not Only SQL (NOSQL) databases.
MongoDB uses the JavaScript Object Model (JSON) as its data model for both
storage and interaction. Google’s Bigtable (Chang et al, 2008) organises data
as sparsely populated tables, called wide-column stores, and has inspired both
Apache HBase, which runs on top of HDFS, and Apache Cassandra (Lakshman and
Malik, 2010). The latter has become one of the most widely used big-data
stores. Initially developed to support Facebook’s messaging system, Cassandra
combines features from key-value pairs and wide-column stores. Like most NOSQL
databases, Cassandra is designed to support data replication, resilience
towards failure, and ease of adding more machines to the cluster/grid. It
offers flexibility, scalability and read-orientation: like HDFS, it is
optimised for writing new data once and reading it many times, whereas
updating existing data is more costly. Unlike HDFS, however, all Cassandra
nodes are equal: they can both store data and answer client requests.

Like data storage, processing has become distributed and duplicated across
computing nodes and centres too. The original Google MapReduce (Dean and
Ghemawat, 2008) and Apache’s open-source
Hadoop121212https://hadoop.apache.org/ support a massively parallel three-step
model of computation called map-reduce. In the first step (map), each
computer, called a worker (or slave) node in Hadoop, sorts the input data into
local files according to a key. In the second step (shuffle), the nodes
transfer temporary files between them, so that all data items with the same
key end up in the same worker node. In the third and final step (reduce), each
worker node processes the data for its keys, possibly combining its own
results with results from its neighbour nodes. For example, to rapidly
identify duplicates in a set of merged library catalogues, the map step sorts
each item locally by title, the shuffle step moves all items with the same
title to the same worker, and the reduce step decides whether pairs of items
that happen to have the same title are actually duplicates. A Hadoop worker
node can be the same computer that is also a data node in HDFS or database
node in Cassandra, so that the node works on locally stored input data in the
initial map step. Otherwise, a costly input split has to be carried out before
first.

A Hadoop master node handles client requests and distributes tasks to the
workers, ensuring that redundantly stored blocks are only processed by one
worker each. Hence, in Hadoop, as in most other big-data processing
frameworks, the tasks are moved to the data. This is a shift from conventional
(“small-data”) computing, where the data was moved to the task processor. In
addition, the master node is responsible for balancing tasks between workers,
taking into account their varying processing capacities, and for reallocating
tasks when a worker is slow or becomes unavailable. Many extensions and
variations of the basic map-shuffle-reduce model have been proposed, and
multiple Hadoop computations are often chained. Because it has been so
successful, Hadoop’s subsystem for resource management and job scheduling and
monitoring has been turned into a separate framework, called YARN (Yet Another
Resource Negotiator) that can be used by other big-data processing tools as
well.

These tools and their successors share a model of computing that is both
highly distributed and highly redundant, so that each computation is carried
out and each piece of data stored in several places simultaneously. On top of
node-level replication, whole data centres can be replicated (or mirrored)
across continents. Data-centre replication improves service availability and
can also be used as a content delivery network (CDN) that improves
responsiveness and communication cost by distributing services geospatially
according to user locations: requests from Chinese users can be served by a
replicated data centre in Guangzhou, European requests can be routed to
Frankfurt, and so on.

In recent years, more specialised big-data technologies and tools have
emerged, many of them growing out of the HDFS/YARN/Hadoop stack. Apache Hive
is a data warehousing tool that offers an SQL-like query language on top of
HDFS and converts the queries to Hadoop, Spark (see below), or other types of
big-data jobs. Apache Kafka and Amazon Kinesis specialise in processing and
storing big streams of data, which can be produced internally in an
organisation or harvested externally from the social web or the Internet of
Things. Google’s Pregel (Malewicz et al, 2010) and Apache
Giraph131313http://giraph.apache.org/ specialise in processing and storing big
graph-structured data. They have been used, respectively, to drive Google’s
PageRank algorithm (Page et al, 1999) and Facebook’s social network analyses.
And many very large-scale applications still use good-old SQL databases.
Alongside these and many other specialised technologies, a preferred tool for
general big-data processing has emerged: Apache Spark, which we will present
in the next section.

##  5 General Engine for Big Data Processing: Spark

The usefulness and power of Google’s MapReduce and its successors surpassed
many expectations. But this first generation of big-data processing engines
also had severe limitations. They were batch-oriented, with jobs that could
take days because they were heavily disk-based, copying their intermediate
results repeatedly to and from disks. Their computation model was also rigid,
restricted to chaining jobs that were composed of minor variants of the map,
shuffle, and reduce operations.

In the early 2010s researchers therefore sought to develop big-data processing
tools that were more interactive; that reduced disk load by relying on in-
memory data storage; and that offered a broader variety of computing
primitives. The most widely used among them is Spark (Zaharia et al, 2016),
which is part of Apache’s big-data ecosystem. In addition to Hadoop’s map,
shuffle, and reduce operations and their variants, Spark offers more than 80
different high-level processing operations, which can be detailed with
functions written in standard programming languages such as Python, Java,
Scala, and R. There are also Spark libraries for: connecting to Cassandra and
SQL databases; analysing large graphs (GraphX); processing live data streams
(DStream); and machine learning (MLib). Like in Hadoop, worker nodes do most
of the computing. A driver node communicates with the client and distributes
tasks to workers, whereas a cluster manager (either Spark’s own built-in one,
YARN, or another) allocates processing capacity.

A Spark computation is organised as a dataflow (or pipeline). The dataflow can
be thought of as a directed acyclic graph (DAG) where each node represents
data at some stage of processing and each edge represents a processing
operation. The data in each node is treated as a Resilient Distributed Dataset
(RDD) (Zaharia et al, 2012), which may contain anything from a single boolean
variable to a petabyte collection of videos: the data in an RDD can be
structured like key-value pairs (maps), tables, and graphs or unstructured
like text and multimedia. But all data items in the same RDD must have the
same type, which is written RDD[type]. Because of its size, an RDD is usually
split into partitions that can be distributed across thousands of computing
nodes, where they are stored in memory and normally not copied to disk, unless
memory fills up or the user specifically requests a checkpoint to be saved.
Importantly, RDDs are immutable meaning, that once they have been created by a
computing operation, they never change (more about that below).

Spark operations take input from one or more nodes and may produce output to a
single node. They are divided into transformations, which take one or more
RDDs and generate a new RDD, and actions, which take one or more input RDDs
and produce either an output (that is not an RDD) or a side effect. For
example, Spark _transformations_ are available for mapping, filtering,
reducing, sampling, and sorting RDDs in various ways, and for combining
multiple RDDs using operations such as intersection, union, and join. After
each transformation, the result is always a new RDD. Spark _actions_ are
available for counting, sampling, looping through, or otherwise reducing large
RDDs into outputs that are easier for humans to interpret and for simpler
software tools to process. Other actions are used for their side effects, for
example to cache or checkpoint an RDD or save it to a (distributed) file
system. Spark evaluation is lazy, so that a transformation in a dataflow will
not be executed until the RDDs they produce are needed, either directly or
indirectly, as input to an action.

Spark processing is resilient because both data storage and processing is
highly redundant: each part of an RDD and of a computation can be stored and
processed on several cluster nodes simultaneously. Whenever a node fails
during computation, and that part of the computation is duplicated, the
computation can just go on. Whenever a node fails that is not redundantly
processed, the Spark engine instead relies on _lineage_. It automatically
enforces recomputation of the necessary data from the last available
checkpoints, perhaps even going back to the original inputs. Recomputation is
possible exactly because the RDDs are immutable: once created they never
change, so each later processing step can be recomputed safely.

To program using Spark, we can use languages like Python, Java, Scala, and R
along with libraries that make Spark operations and RDDs available from inside
these languages. We can also program interactively using Spark’s built-in
shells for Python and Scala. The following example is written in Scala using
the spark-shell, but the code in other languages would not be much different.

To filter Twitter data with Spark in an emergency, we first import Spark’s
DStream library and its Twitter extensions141414See the Apache Spark DStream
and Bahir-Twitter projects. The Twitter4j library is also needed.:

    Ψimport org.apache.spark._
    Ψimport org.apache.spark.streaming._
    Ψimport org.apache.spark.streaming.twitter._

We also need to specify the credentials for our Twitter account and app, with
lines like151515To register and get credentials for a Twitter App, go to
apps.twitter.com .:

    ΨSystem.setProperty( "twitter4j.oauth.consumerKey", "..." )
    ΨSystem.setProperty( "twitter4j.oauth.consumerSecret", "..." )
    ΨSystem.setProperty( "twitter4j.oauth.accessToken", "..." )
    ΨSystem.setProperty( "twitter4j.oauth.accessTokenSecret", "..." )

We are now ready to define a dataflow that harvests tweets from Spark
(although nothing will be executed until we start the stream and specify an
action):

    Ψsc.setLogLevel( "ERROR" )
    Ψval ssc = new StreamingContext( sc, Seconds( 5 ))
    Ψval stream = TwitterUtils.createStream( ssc, None )

The first line states that the running Spark engine, represented by the built-
in Spark Context (sc) object, should only report serious errors. The second
line states that Spark should run in streaming mode, collecting a new batch of
input data every five seconds. The third line states that this data should
come from the Twitter account we have already specified.

The stream variable represents the series of RDDs that are input to our
pipeline, one every five seconds. Each RDD in it has the Scala type
RDD[Status], meaning that it is an RDD that contains Status objects. The
Status class is defined in the Twitter4j library to represent and process a
single tweet along with its (quite extensive) metadata161616See the
introduction to Tweet JSON at developer.twitter.com and the twitter4j.Status
interface in the Twitter4j API, which Bahir-Twitter wraps around..

We can easily add more operations to our dataflow. First, we use a map
transformation to pick out the message texts from each tweet:

    Ψval texts = stream.map( status => status.getText )

This creates a new stream of RDDs of strings (type RDD[String]), which we can
loop through and output (an action):

    Ψtexts.foreachRDD( _.foreach( text => println( text )))

or split (a transformation) into a stream of RDDs of single words (again of
RDD[String]):

    Ψval words = texts.flatMap( text => text.split(   ))

which we then filter (another transformation) for hashtags:

    Ψval hashtags = words.filter( _.startsWith( "#" ))

We can easily add further operations that may extend, split or merge
processing paths. When we are finished, we can start the flow of tweets and
inspect the outputs:

    Ψssc.start

In the example, this will start extracting message texts from live Twitter
messages and output them to the console. But it will not start splitting texts
into words and filter out the hashtags, because Spark evaluation is lazy and
we have not yet used the hashtags in an action.

Finally, we stop the Spark streaming pipeline, making it clear that we want to
wait until all data in the pipeline has been processed and that we do not want
to close the Spark context permanently:

    Ψssc.stop( stopSparkContext=false, stopGracefully=true )

Of course, this small example barely scratches the surface of what a powerful
big-data framework like Spark can do. But it illustrates how just a few lines
of Spark code is enough to process social media data in ways that are
potentially useful in emergency situations. In addition to its high-level
processing operations, much of the power of Spark lies in its scaling: the
above example can be run both on a single computer on a filtered stream of
tweets and, without modifications, on a cluster of hundreds or thousands of
nodes processing a fire hose of data. Of course, the Spark configuration would
have to be changed, but there are many abstract machine images for distributed
Spark freely available in the cloud, and instantiating one of them only takes
minutes.

##  6 Ethical and Societal Issues

The previous sections have shown that big-data analytics offer many benefits
in all phases of emergency management. New possibilities for large-scale yet
precise surveillance on demand can save lives and property in emergency
situations. But if the same surveillance is misused in everyday life, it can
pose threats to individual privacy and to society in general. Use of big data
during emergencies must therefore be carefully conducted and monitored, and a
fine line must be tread between specific emergency needs and wider ethical and
societal concerns (Kitchin, 2014).

Among the ethical concerns, privacy is central. Personal information refers to
information that can be attributed to a physical person. This includes data
that contains unambiguous identifiers such as personal id numbers, names,
addresses, and birth dates, but also data that is sufficiently detailed to be
indirectly attributable to a person. A study of mobile phone-users (De
Montjoye et al, 2013) showed that knowing only four spatio-temporal data
points was enough to identify 95% of the users uniquely, and coarser datasets
did not offer much stronger anonymity. Hence, when data sets about individuals
are recombined in an emergency situation, the combined data items can become
attributable to individuals, even when the original data were not. Privacy
concerns are accentuated when the personal information is also sensitive
because it covers: age, criminal records, ethnicity, gender, health, marital
status, political opinions, race, religion, sexuality, or trade-union
membership. The many dangers of personal data in the wrong hands are well
known: it can be used for blackmail, coercion, social-engineering scams,
personality theft, or sold to advertising and insurance companies. Live
personal data can even be used by organised criminals who want to commit theft
or kidnapping or by terrorist organisations for targetted attacks.

Personal information is not the only type of information that can be
sensitive. Information about critical infrastructures is also likely to be
collected and recombined as part of emergency computation. Such information
can be valuable to criminals, potential terrorists, and foreign powers.
Although many of the data sets used will be in the open, their potential value
for adversaries increase when they are recombined and augmented with temporal
information that can be used, for example, by criminals or terrorists to
estimate police and other response times.

Finding the right balance between emergency needs and ethical/societal
concerns requires an appropriate combination of organisational, informational,
and technical measures. On the organisational side, sensitive data should only
be made accessible to trusted agencies with clear procedures in place for
screening personnel etc. For every data set that includes sensitive
information, a steward should be appointed with clearly-defined
responsibilities. As much as possible, data should be collected only from
trusted sources, but this is not always an option — and certainly not in the
case of socially generated data. And, of course, data should only be shared
with trusted partners.

On the informational side, sensitive data should only be collected and
recombined in response to concrete and carefully prioritised operational and
tactical needs, even when it goes against the opportunistic tendency of big-
data practice, which stores data opportunistically — exhaustively,
historically, and in full detail — because it can potentially become valuable
in the future. Data tables should be projected to remove unneeded attributes
whenever they are shared. Whenever possible, anonymisation and
pseudonymisation should be used to increase privacy, although they cannot be
considered sufficient privacy measures in their own right.

On the technical side, only screened and trusted data processing organisations
should be allowed to store and process the data. This applies in particular to
cloud computing providers. The processing organisations should be transparent
when it comes to where in the world — and thus under which jurisdiction — the
data is stored and processed. Techniques such as secret sharing and
watermarking should be considered to make the data more difficult to obtain
and leave it traceable should it come into the wrong hands.

## Exercises

  1. 1.

What are the three V’s of big data?

  2. 2.

Some people talk about two more V’s in addition to the three. Which ones?

  3. 3.

What does it mean that big data are: exhaustive, fine grained, indexical,
relational, extendible, historical, and opportunistic.

  4. 4.

What is a data-driven organisation (or business)? Give examples?

  5. 5.

Explain the four phases of emergency management. How can big data help in each
of them?

  6. 6.

Which big data sources can be leveraged in each phase of emergency management
and how?

  7. 7.

Name the most central big-data technologies for: file management, database
management, and data processing.

  8. 8.

What are the main improvements of Spark over Google’s MapReduce and Apache
Hadoop?

  9. 9.

What is an RDD and what is lineage in Spark?

  10. 10.

What are the most pressing ethical and societal dangers of big data?

  11. 11.

In the Spark example, change the code to output Named Entities (names of
individual things like people, places, organisations, and works) instead of
hashtags, assuming that named entities are always written as a sequence of
words with capital initial letters.

## References

  * Atzori et al (2010) Atzori L, Iera A, Morabito G (2010) The Internet of Things: A survey. Computer Networks 54(15):2787–2805, DOI 10.1016/j.comnet.2010.05.010, URL http://linkinghub.elsevier.com/retrieve/pii/S1389128610001568
  * Berners-Lee et al (2001) Berners-Lee T, Hendler J, Lassila O (2001) The semantic web. Scientific american 284(5):34–43
  * Castillo (2016) Castillo C (2016) Big crisis data: Social media in disasters and time-critical situations. Cambridge University Press
  * Chang et al (2008) Chang F, Dean J, Ghemawat S, Hsieh WC, Wallach DA, Burrows M, Chandra T, Fikes A, Gruber RE (2008) Bigtable: A distributed storage system for structured data. ACM Transactions on Computer Systems (TOCS) 26(2):4
  * De Montjoye et al (2013) De Montjoye YA, Hidalgo CA, Verleysen M, Blondel VD (2013) Unique in the crowd: The privacy bounds of human mobility. Scientific reports 3:1376
  * Dean and Ghemawat (2008) Dean J, Ghemawat S (2008) MapReduce: simplified data processing on large clusters. Communications of the ACM 51(1):107, DOI 10.1145/1327452.1327492, URL http://portal.acm.org/citation.cfm?doid=1327452.1327492
  * Ghemawat et al (2003) Ghemawat S, Gobioff H, Leung ST (2003) The Google file system, vol 37. ACM
  * Huang et al (2010) Huang Q, Yang C, Nebert D, Liu K, Wu H (2010) Cloud computing for geosciences: Deployment of geoss clearinghouse on amazon’s ec2. In: Proceedings of the ACM SIGSPATIAL International Workshop on High Performance and Distributed Geographic Information Systems, ACM, New York, NY, USA, HPDGIS ’10, pp 35–38, DOI 10.1145/1869692.1869699, URL http://doi.acm.org/10.1145/1869692.1869699
  * Kitchin (2014) Kitchin R (2014) The data revolution: Big data, open data, data infrastructures and their consequences. Sage
  * Lakshman and Malik (2010) Lakshman A, Malik P (2010) Cassandra: a decentralized structured storage system. ACM SIGOPS Operating Systems Review 44(2):35–40
  * Malewicz et al (2010) Malewicz G, Austern MH, Bik AJ, Dehnert JC, Horn I, Leiser N, Czajkowski G (2010) Pregel: a system for large-scale graph processing. In: Proceedings of the 2010 ACM SIGMOD International Conference on Management of data, ACM, pp 135–146
  * Page et al (1999) Page L, Brin S, Motwani R, Winograd T (1999) The pagerank citation ranking: Bringing order to the web. Tech. rep., Stanford InfoLab
  * Zaharia et al (2012) Zaharia M, Chowdhury M, Das T, Dave A, Ma J, McCauley M, Franklin MJ, Shenker S, Stoica I (2012) Resilient distributed datasets: A fault-tolerant abstraction for in-memory cluster computing. In: Proceedings of the 9th USENIX conference on Networked Systems Design and Implementation, USENIX Association, p 14
  * Zaharia et al (2016) Zaharia M, Xin RS, Wendell P, Das T, Armbrust M, Dave A, Meng X, Rosen J, Venkataraman S, Franklin MJ (2016) Apache spark: a unified engine for big data processing. Communications of the ACM 59(11):56–65

## Acknowledgement

This is a pre-print of the following chapter: Opdahl, A. L. and Nunavath, V.,
“Big Data”, published in Big Data in Emergency Management: Exploitation
Techniques for Social and Mobile Data, edited by Rajendra Akerkar, 2020,
Springer International Publishing reproduced with permission of Springer
International Publishing. The final authenticated version is available online
at: http://dx.doi.org/10.1007/978-3-030-48099-8.

Opdahl, A. L., and Nunavath, V. (2020). Big Data. Big Data in Emergency
Management: Exploitation Techniques for Social and Mobile Data, 15-29.