-
Notifications
You must be signed in to change notification settings - Fork 18
type.q
The functions in this namespace provide type checking and type normalistion functions
These functions all check if the specified argument matches the specified type in the function name.
At the simplest level, there is a is*Type*
and is*Type*List
function for each standard type. There is also:
-
.type.isFilePath
: A valid file reference forget
,set
,read0
etc. -
.type.isHostPort
: A valid host/port reference forhopen
-
.type.isString
: Friendly reference to.type.isCharacterList
-
.type.isInfinite
: Any positive or negative infinite value -
.type.isNamespace
: A kdb namespace -
.type.isAtom
: Any atomic value -
.type.isList
: Any list -
.type.isTypedList
: A list of single type -
.type.isGenericList
: A list of multiple types (i.e.0h
type) -
.type.isAnymap
: An persisted anymap file
These functions provide type checking across a number of different kdb types:
-
.type.isNumber
: Any whole or decimal number -
.type.isWholeNumber
: Any whole number type -
.type.isDecimal
: Either decimal type -
.type.isDateOrTime
: Any date or time format -
.type.isFunction
: Any function type -
.type.isEnumeration
: Any enumeration type
-
.type.isKeyedTable
: Any table with one or more keys -
.type.isSplayedTable
: A table that is splayed on disk (can check a folder path) -
.type.isPartedTable
: A table that is partitioned on disk -
.type.isEnumeratedTable
: A table that has one or more enumerated columns
-
.type.isFile
: A valid file on disk -
.type.isFolder
: A valid folder on disk
-
.type.isDistinct
: Checks if the specified parameter anddistinct
of the same parameter match
Ensures that the function result is a symbol representation of the input.
q) .type.ensureSymbol `a
`a
q) .type.ensureSymbol 123
`123
q) .type.ensureSymbol "abc"
`abc
q) .type.ensureSymbol .z.p
`2020.02.23D16:30:01.926509000
Ensures that the function result is a string representation of the input. Typed lists will have each element comma-separated; generic lists will defer to .Q.s1
for printing.
q) .type.ensureString "abc"
"abc"
q) .type.ensureString 123
"123"
q) .type.ensureString `a
,"a"
q) .type.ensureString `a`b`c!1 2 3
"`a`b`c!1 2 3"
q) .type.ensureString 1 2 3
"1, 2, 3"
q) .type.ensureString (1;`a)
"(1;`a)"
Normalises the integer port into a host/port symbol equivalent.
q) .type.ensureHostPortSymbol `:localhost:12345
`:localhost:12345
q) .type.ensureHostPortSymbol 12345
`::12345
Copyright (C) Sport Trades Ltd 2017 - 2020, John Keys and Jaskirat Rajasansir 2020 - 2024