Skip to content

Commit aed6cf8

Browse files
committed
UDFs from Gary
added unit tests added to latex docs
1 parent ed8f31a commit aed6cf8

File tree

3 files changed

+579
-57
lines changed

3 files changed

+579
-57
lines changed

docs/latex/sections/addqueryfuncs.tex

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -66,62 +66,69 @@ \subsection{User Defined Functions}
6666

6767
\subsubsection{Functions available in \gufiquery and \gufisqlite}
6868

69-
\begin{table}[H]
70-
\centering
71-
\caption{General Utility Functions}
72-
\begin{tabularx}{\textwidth}{| l | X |}
73-
\hline
74-
Function & Description \\
75-
\hline
76-
\texttt{uidtouser(uid)} & Converts a UID to a user name \\
77-
\hline
78-
\texttt{gidtogroup(gid)} & Converts a GID to a group name \\
79-
\hline
80-
\texttt{modetotxt(mode)} & Converts numerical permission bits to text \\
81-
\hline
82-
\texttt{strftime(format, timestamp)} & Replaces \href{https://www.sqlite.org/lang_datefunc.html}{SQLite~3's custom \texttt{strftime}} with \texttt{strftime(3)} \\
83-
\hline
84-
\texttt{blocksize(bytes, unit)} & Converts a size to a the number of blocks of size \texttt{unit} needed to store the first argument. \texttt{unit} is the combination of at least one integer and/or a prefix and a suffix: \\
85-
& \\
86-
& Prefix: \texttt{K}, \texttt{M}, \texttt{G}, \texttt{T}, \texttt{P}, \texttt{E}\\
87-
& Suffix (multiplier): \textit{no suffix} (1024), \texttt{B} (1000), \texttt{iB} (1024) \\
88-
& \\
89-
& Return value is a string. \\
90-
& \\
91-
& Note that this function was implemented to replicate \texttt{ls} output and is meant for use with \gufils only, so use with caution. \\
92-
& \\
93-
& Examples: \\
94-
& \begin{tabular}{| l | l |}
95-
\hline
96-
Call & Output \\
97-
\hline
98-
blocksize(1024, `1000') & 2 \\
99-
\hline
100-
blocksize(1024, `1024') & 1 \\
101-
\hline
102-
blocksize(1024, `K') & 1K \\
103-
\hline
104-
blocksize(1024, `1K') & 1 \\
105-
\hline
106-
blocksize(1024, `KB') & 2KB \\
107-
\hline
108-
blocksize(1024, `1KB') & 2 \\
109-
\hline
110-
blocksize(1024, `KiB') & 1KiB \\
111-
\hline
112-
blocksize(1024, `1KiB') & 1 \\
113-
\hline
114-
\end{tabular} \\
69+
\begin{longtable}{|l|p{0.5\linewidth}|}
70+
\caption{General Utility Functions} \\
71+
\hline
72+
Function & Description \\
73+
\hline
74+
\texttt{uidtouser(uid)} & Converts a UID to a user name \\
75+
\hline
76+
\texttt{gidtogroup(gid)} & Converts a GID to a group name \\
77+
\hline
78+
\texttt{modetotxt(mode)} & Converts numerical permission bits to text \\
79+
\hline
80+
\texttt{strftime(format, timestamp)} & Replaces \href{https://www.sqlite.org/lang_datefunc.html}{SQLite~3's custom \texttt{strftime}} with \texttt{strftime(3)} \\
81+
\hline
82+
\texttt{intcat(int)} & Uses any integer. It provides the category that integer is in from Zero, O for less than 1000, K for less than 1 million, M less than billion, B for less than Trillion, T for less than quadrillion, q for less than quintillion, Q for more than Quintillion. (using 1000) \\
83+
\hline
84+
\texttt{bytecat(int)} & Uses any integer. Provides category from Zero, B for less than 1k, K for less than 1M, M for less than 1G, G for less than 1T, T for less than one P, P for less than 1E, E for more than 1E. (using 1024) \\
85+
\hline
86+
\texttt{agecat(time)} & Uses any unix epoch like mtime as input. It subtracts that from current time and categorizes into S seconds, M minutes, H hours, d days, W weeks, M months, Y years, D decades as categories. (for use in group by) \\
87+
\hline
88+
\texttt{epochtoage(time, unit)} & Provides age from now from unix epoch time fields like mtime, ctime, atime, crtime. Unit s (seconds), m (minutes), h (hours), d (days), w (weeks), M (months), y (years), D (decades). (for use in group by) \\
89+
\hline
90+
\texttt{hostname()} & Provides the hostname \gufiquery is running on (Helpful for multi-site record source) \\
91+
\hline
92+
\texttt{blocksize(bytes, unit)} & Converts a size to a the number of blocks of size \texttt{unit} needed to store the first argument. \texttt{unit} is the combination of at least one integer and/or a prefix and a suffix: \\
93+
& \\
94+
& Prefix: \texttt{K}, \texttt{M}, \texttt{G}, \texttt{T}, \texttt{P}, \texttt{E}\\
95+
& Suffix (multiplier): \textit{no suffix} (1024), \texttt{B} (1000), \texttt{iB} (1024) \\
96+
& \\
97+
& Return value is a string. \\
98+
& \\
99+
& Note that this function was implemented to replicate \texttt{ls} output and is meant for use with \gufils only, so use with caution. \\
100+
& \\
101+
& Examples: \\
102+
& \begin{tabular}{| l | l |}
103+
\hline
104+
Call & Output \\
105+
\hline
106+
blocksize(1024, `1000') & 2 \\
107+
\hline
108+
blocksize(1024, `1024') & 1 \\
109+
\hline
110+
blocksize(1024, `K') & 1K \\
111+
\hline
112+
blocksize(1024, `1K') & 1 \\
113+
\hline
114+
blocksize(1024, `KB') & 2KB \\
115+
\hline
116+
blocksize(1024, `1KB') & 2 \\
117+
\hline
118+
blocksize(1024, `KiB') & 1KiB \\
119+
\hline
120+
blocksize(1024, `1KiB') & 1 \\
121+
\hline
122+
\end{tabular} \\
115123
& \\
116-
\hline
117-
\texttt{human\_readable\_size(bytes)} & Converts a size to a human readable string \\
118-
\hline
119-
\texttt{basename(str)} & Return the basename of a path \\
120-
\hline
121-
\texttt{ext(str)} & Return the (last) extension of the input string. \\
122-
\hline
123-
\end{tabularx}
124-
\end{table}
124+
\hline
125+
\texttt{human\_readable\_size(bytes)} & Converts a size to a human readable string \\
126+
\hline
127+
\texttt{basename(str)} & Return the basename of a path \\
128+
\hline
129+
\texttt{ext(str)} & Return the (last) extension of the input string. \\
130+
\hline
131+
\end{longtable}
125132

126133
\begin{table}[H]
127134
\centering
@@ -243,5 +250,3 @@ \subsubsection{Functions available only in \gufiquery}
243250
\hline
244251
\end{tabularx}
245252
\end{table}
246-
247-
\clearpage

0 commit comments

Comments
 (0)