Skip to content
Jaskirat Rajasansir edited this page Feb 23, 2020 · 4 revisions

Type Checking and Normalisation

The functions in this namespace provide type checking and type normalistion functions

.type.is*

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 for get, set, read0 etc.
  • .type.isHostPort: A valid host/port reference for hopen
  • .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 Grouping

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

Tables

  • .type.isKeyedTable: Any table with one or more keys
  • .type.isSplayedTable: A table that is splayed on disk
  • .type.isPartedTable: A table that is partitioned on disk
  • .type.isEnumeratedTable: A table that has one or more enumerated columns

Files and Folders

  • .type.isFile: A valid file on disk
  • .type.isFolder: A valid folder on disk

Distinct

  • .type.isDistinct: Checks if the specified parameter and distinct of the same parameter match

.type.ensureSymbol

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

.type.ensureString

Ensures that the function result is a string representation of the input.

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"

.type.ensureHostPortSymbol

Normalises the integer port into a host/port symbol equivalent.

q) .type.ensureHostPortSymbol `:localhost:12345
`:localhost:12345

q) .type.ensureHostPortSymbol 12345
`::12345
Clone this wiki locally