Documentation
¶
Index ¶
- Variables
- func Aligner[ChLeft, ChRight any | int32 | int64 | float32 | float64 | string | time.Time](left []ChLeft, right []ChRight, pad int) []string
- func Any2Date(inVal any) (*time.Time, error)
- func Any2Float32(inVal any) (*float32, error)
- func Any2Float64(inVal any) (*float64, error)
- func Any2Int(inVal any) (*int, error)
- func Any2Int32(inVal any) (*int32, error)
- func Any2Int64(inVal any) (*int64, error)
- func Any2Kind(inVal any, kind reflect.Kind) (any, error)
- func Any2String(inVal any) string
- func AnySlice2Float64(inVal []any) ([]float64, error)
- func BuildQuery(srcQry string, replacers keyval.KeyVal) (qry string)
- func Comparer(xa, xb any, comp string) (truth bool, err error)
- func CopyFile(sourceFile, destFile string) error
- func CopyFiles(fromDir, toDir string) error
- func DBExists(db string, conn *chutils.Connect) error
- func DeDupeSlice(inSlc []string, sortReturn bool) (outSlc []string)
- func DropTable(table string, conn *chutils.Connect) error
- func Fig2File(fig *grob.Fig, plotType PlotlyImage, outDir, outFile string) error
- func FileExists(file string) error
- func GTAny(xa, xb any) (truth bool, err error)
- func GetTTYecho(prompt string) string
- func GetTTYnoecho(prompt string) string
- func HTML2File(htmlFile string, plotType PlotlyImage, outDir, outFile string) error
- func Has(needle, delim string, haystack ...string) bool
- func LTAny(x, y any) (bool, error)
- func MakeConnection(host, user, password string, maxMemory, maxGroupBy int64, maxThreads int) (conn *chutils.Connect, err error)
- func Matched(inStr, startChar, endChar string) (string, error)
- func MaxInt(ints ...int) int
- func MinInt(ints ...int) int
- func Pad(inTable [][]string, pad int) string
- func Plotter(fig *grob.Fig, lay *grob.Layout, pd *PlotDef) error
- func Position(needle, delim string, haystack ...string) int
- func PrettyDur(startTime time.Time) string
- func PrettyString(x any) string
- func QueryToCSV(qry, csvFile string, quoteStrings, header bool, conn *chutils.Connect) error
- func RandNorm(n int) ([]float64, error)
- func RandUnifFlt(n int) ([]float64, error)
- func RandUnifInt(n, upper int) ([]int64, error)
- func RandomLetters(length int) string
- func ReplaceSmart(source, oldChar, newChar, delim string) string
- func Slash(inStr string) string
- func String2Kind(str string) reflect.Kind
- func TableExists(table string, conn *chutils.Connect) error
- func TableOrQuery(table string) string
- func TempFile(ext string, length int) string
- func TempTable(tmpDB string, length int) string
- func ToClickHouse(inVal any) string
- func ToFile(fileName, text string) error
- func ToLastDay(dt time.Time) (eom time.Time)
- func YesNo(inStr string) (bool, error)
- type HistData
- type PlotDef
- type PlotlyImage
- type QuantileData
- type Table
- type XYData
Constants ¶
This section is empty.
Variables ¶
var Browser = "xdg-open"
Browser is the browser in which to show plots. This starts as the system default, but can be changed. For instance, Browser="vivaldi" will place the plot in Vivaldi.
Functions ¶
func Aligner ¶ added in v0.1.20
func Aligner[ChLeft, ChRight any | int32 | int64 | float32 | float64 | string | time.Time](left []ChLeft, right []ChRight, pad int) []string
Aligner returns a slice of strings suitable for printing the two input slices
func Any2Date ¶ added in v0.0.9
Any2Date attempts to convert inVal to a date (time.Time). Returns nil if this fails.
func Any2Float32 ¶ added in v0.0.9
Any2Float32 attempts to convert inVal to float32. Returns nil if this fails.
func Any2Float64 ¶ added in v0.0.9
Any2Float64 attempts to convert inVal to float64. Returns nil if this fails.
func Any2Int32 ¶ added in v0.0.9
Any2Int32 attempts to convert inVal to int32. Returns nil if this fails.
func Any2Int64 ¶ added in v0.0.9
Any2Int64 attempts to convert inVal to int64. Returns nil if this fails.
func Any2String ¶ added in v0.0.9
func AnySlice2Float64 ¶ added in v0.0.12
func BuildQuery ¶
BuildQuery replaces the placeholders with values placeholders have the form "?key". BuildQuery prepends a "?" to the keys in replacers.
func Comparer ¶ added in v0.0.9
Comparer compares xa and xb. Comparisons available are: ==, !=, >, <, >=, <=
func DeDupeSlice ¶ added in v0.1.31
DeDupeSlice removes duplicate entries of inSlc, sorting if sortReturn
func Fig2File ¶ added in v0.1.16
func Fig2File(fig *grob.Fig, plotType PlotlyImage, outDir, outFile string) error
Fig2File outputs a plotly figure to a graphics file (png, jpg, etc.) This func requires that orca be installed. Inputs:
- fig. plotly figure
- plotType. graph type. One of: png, jpeg, webp, svg, pdf, eps, emf
- outDir. Output directory.
- outFile. Filename of output, with NO extension.
func FileExists ¶
FileExists returns an error if "file" does not exist.
func GetTTYecho ¶ added in v0.1.33
GetTTYecho reads a response from the TTY while echoing the user's typing
func GetTTYnoecho ¶ added in v0.1.33
GetTTYnoecho reads a response from the TTYgit without echoing the user's typing
func HTML2File ¶ added in v0.1.18
func HTML2File(htmlFile string, plotType PlotlyImage, outDir, outFile string) error
HTML2File produces an image file from a plotly html file This func requires that orca be installed. Inputs
- htmlFile. plotly html file
- plotType. graph type. One of: png, jpeg, webp, svg, pdf, eps, emf
- outDir. Output directory.
- outFile. Filename of output, with NO extension.
func MakeConnection ¶ added in v0.1.36
func MakeConnection(host, user, password string, maxMemory, maxGroupBy int64, maxThreads int) (conn *chutils.Connect, err error)
MakeConnection establishes the connection to ClickHouse, supplying common options - host, user, password are what you think - maxMemory: maximum memory (bytes) for a query - maxGroupBy: maximum memory to use in a GROUP BY - maxThreads: maximum # of threads for a query
func Matched ¶ added in v0.1.18
Matched returns a substring that is between the outermost set of startChar/endChar
func Pad ¶ added in v0.1.31
Pad pads each element of inTable so the columns line up with pad spaces separating them
func Plotter ¶ added in v0.1.19
Plotter plots the Plotly Figure fig with Layout lay. The layout is augmented by features I commonly use.
fig plotly figure lay plotly layout (nil is OK) pd PlotDef structure with plot options.
lay can be initialized with any additional layout options needed.
func Position ¶
Position returns the index of needle in the haystack. It returns -1 if needle is not found. If haystack has length 1, then it is split into a slice with delimiter ",".
func PrettyString ¶ added in v0.1.31
PrettyString returns a string version of x suitable for printing
func QueryToCSV ¶ added in v0.1.37
QueryToCSV writes the output of the query to a CSV. - qry: query to run - csvFile: output file - quoteStings: if true, places strings in double quotes - header: if true, include header row of field names - conn: ClickHouse connection
func RandUnifFlt ¶ added in v0.0.6
RandUnifFlt generates a slice whose elements are random U(0, 1) floats
func RandUnifInt ¶ added in v0.0.6
RandUnifInt generates a slice whose elements are random U[0,upper) int64's
func RandomLetters ¶ added in v0.0.7
RandomLetters generates a string of length "length" by randomly choosing from a-z
func ReplaceSmart ¶ added in v0.0.12
ReplaceSmart replaces old with new except when it occurs within delim
func String2Kind ¶ added in v0.0.9
String2Kind converts a string specifying a type to the reflect.Kind
func TableExists ¶
TableExists returns an error if "table" does not exist. conn is the DB connector.
func TableOrQuery ¶ added in v0.0.5
TableOrQuery takes table and returns a query. If it is already a query (has "select"), just returns the original value.
func TempFile ¶
TempFile produces a random temp file name in the system's tmp location. The file has extension "ext". The file name begins with "tmp" has length 3 + length.
func TempTable ¶
TempTable produces a random table name. The table name begins with "tmp". The table's name has length 3 +length. tmpDB is the database name.
func ToClickHouse ¶ added in v0.1.21
ToClickHouse returns a string suitable for a ClickHouse constant value
Types ¶
type HistData ¶ added in v0.1.20
type HistData struct { Levels []any // levels of the field Counts []int64 // counts Prop []float32 // proportions Total int64 // total counts Qry string // query used to pull the data FieldDef *chutils.FieldDef // field defs of returns Fig *grob.Fig // histogram }
HistData represents a histogram constructed from querying ClickHouse
func NewHistData ¶ added in v0.1.20
NewHistData pulls the data from ClickHouse and creates a plotly histogram
type PlotDef ¶ added in v0.1.19
type PlotDef struct { Show bool // Show - true = show graph in browser Title string // Title - plot title XTitle string // XTitle - x-axis title YTitle string // Ytitle - y-axis title STitle string // STitle - sub-title (under the x-axis) Legend bool // Legend - true = show legend Height float64 // Height - height of graph, in pixels Width float64 // Width - width of graph, in pixels FileName string // FileName - output file for (no suffix, no path) OutDir string // Outdir - output directory ImageTypes []PlotlyImage // image type(s) to create (e.g. png, jpg...) }
PlotDef specifies Plotly Layout features I commonly use.
type PlotlyImage ¶ added in v0.1.20
type PlotlyImage int
PlotlyImage is the type of image file to create
const ( PlotlyJPEG PlotlyImage = 0 + iota PlotlyPNG PlotlyHTML PlotlyPDF PlotlyWEBP PlotlySVG PlotlyEPS PlotlyEMF )
func (PlotlyImage) String ¶ added in v0.1.20
func (pi PlotlyImage) String() string
type QuantileData ¶ added in v0.1.21
type QuantileData struct { Q []float32 // quantiles at u U []float32 // u values (0-1) Total int64 // total sample size Qry string // query used to pull the data FieldDef *chutils.FieldDef // field defs of fields pulled Fig *grob.Fig // quantile plot }
QuantileData represents a quantile plot constructed from querying ClickHouse
func NewQuantileData ¶ added in v0.1.21
func NewQuantileData(rootQry, field, where string, conn *chutils.Connect) (*QuantileData, error)
NewQuantileData pulls the data from ClickHouse and creates a plotly quantile plot
type Table ¶ added in v0.1.31
type Table struct { RowNames []string ColNames []string Data [][]any // stored by columns // contains filtered or unexported fields }
Table holds a table