+%Get tid of transaction\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Get tid of transaction:}\r
+\begin{algorithmic}[1]\r
+\Function{GetTid}{$transaction_s$}\r
+ \State $\tuple{ssn_s,\{c_{mid_1}, c_{mid_2}, ... , c_{mid_k}\}, \{kv_1, kv_2,...kv_n\}, guard_s} \gets record_s$\r
+ \State \Return {$\tuple{mid_s, c_{mid_s}}$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+%Key Value Live\r
+%\noindent\fbox{%\r
+%\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Key Value Live:}\r
+\begin{algorithmic}[1]\r
+\Function{KeyValueLive}{$keyName_s, transaction_s$}\r
+ \State $API \gets \emptyset$ \Comment{Set of all Payload Items}\r
+ \State $AT \gets \emptyset$ \Comment{Set of all Payload Items that are transactions}\r
+ \State $AC \gets \emptyset$ \Comment{Set of all Payload Items that are commits}\r
+ \State $AA \gets \emptyset$ \Comment{Set of all Payload Items that are aborts}\r
+ \State $commitTrans = NULL$\r
+ \State $tid \gets $ \Call{GetTid}{$transaction_s$}\\\r
+\r
+ \ForAll{$record$ in $R$}\r
+ \State $API \gets API \cup$ \Call{GetPayloadItemsWithSSN}{record}\r
+ \EndFor\\\r
+ \r
+ \ForAll{$\tuple{ssn, payload}$ in $API$}\r
+ \If{$payload$ is a $transaction$}\r
+ \State $AT \gets AT \cup \{payload\}$\r
+ \ElsIf{$payload$ is a $commit$}\r
+ \State $AC \gets AC \cup \{payload\}$\r
+ \ElsIf{$payload$ is a $abort$}\r
+ \State $AA \gets AA \cup \{payload\}$\r
+ \EndIf\r
+ \EndFor\\\r
+ \r
+ \ForAll{$\tuple{tid',mid',vc'}$ in $AA$} \Comment{Has an abort}\r
+ \If{$tid' = tid$}\r
+ \State \Return{False}\r
+ \EndIf\r
+ \EndFor\\\r
+\r
+ \ForAll{$\tuple{tid',vc'}$ in $AC$} \Comment{Has a commit}\r
+ \If{$tid' = tid$}\r
+ \State $commitTrans \gets \tuple{tid',vc'}$\r
+ \State Break\r
+ \EndIf\r
+ \EndFor\\\r
+ \r
+ \If{$commitTrans = NULL$} \r
+ \State \Return{True} \Comment{If transaction not yet committed then alive}\r
+ \EndIf\\\r
+ \r
+ \State $\tuple{tid_c, vc_c} \gets commitTrans$\r
+ \ForAll{$trans$ in $AT$}\r
+ \State $\{mid_t,vc_t ,\{\tuple{k_1, v_1}, \tuple{k_2, v_2},..., \tuple{k_k, v_k}\},guard_t\} \gets trans$\r
+ \If{$(trans \neq transaction_s) \land (keyName_s = k_n)$}\r
+ \ForAll{$\tuple{tid_c',vc_c'}$ in $AC$}\r
+ \If{$(tid_c = $ \Call{GetTid}{$trans$} $) \land (vc_c' > vc_c)$}\r
+ \State \Return{False}\r
+ \EndIf\r
+ \EndFor\r
+ \EndIf\r
+ \EndFor\\\r
+ \r
+ \State \Return{True}\r
+ \r
+\EndFunction\r
+\end{algorithmic}\r
+%\end{varwidth}% \r
+%}\r
+\r