Skip to content

Commit 86d74b9

Browse files
authored
Merge pull request #333 from sshanks-kx/refactor
refactor
2 parents 40794b4 + d3c4b5a commit 86d74b9

40 files changed

+209
-722
lines changed

docs/basics/internal.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ The operator `!` with a negative integer as left argument calls an internal func
1717
[-10!x](#-10x-type-enum) type enum -5! [parse](../ref/parse.md)
1818
[-11!](#-11-streaming-execute) streaming execute -6! [eval](../ref/eval.md)
1919
[-14!x](#-14x-quote-escape) quote escape -7! [hcount](../ref/hcount.md)
20-
[-16!x](#-16x-ref-count) ref count -12! [.Q.host](../ref/dotq.md#host-hostname)
21-
[-18!x](#-18x-compress-byte) compress byte -13! [.Q.addr](../ref/dotq.md#addr-ip-address)
20+
[-16!x](#-16x-ref-count) ref count -12! [.Q.host](../ref/dotq.md#host-ip-to-hostname)
21+
[-18!x](#-18x-compress-byte) compress byte -13! [.Q.addr](../ref/dotq.md#addr-iphost-as-int)
2222
[-21!x](#-21x-compressionencryption-stats) compression/encryption stats -15! [md5](../ref/md5.md)
2323
[-22!x](#-22x-uncompressed-length) uncompressed length -19! [set](../ref/get.md#set)
2424
[-23!x](#-23x-memory-map) memory map -20! [.Q.gc](../ref/dotq.md#gc-garbage-collect)
@@ -359,7 +359,7 @@ q)-27!(3i;0 1+123456789.4567)
359359
"123456790.457"
360360
```
361361

362-
This is a more precise, built-in version of [`.Q.f`](../ref/dotq.md#f-format) but uses IEEE754 rounding:
362+
This is a more precise, built-in version of [`.Q.f`](../ref/dotq.md#f-precision-format) but uses IEEE754 rounding:
363363

364364
```q
365365
q).045

docs/basics/ipc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ The compression/decompression algorithms are proprietary and implemented as the
398398
<br>
399399
[`.z` namespace](../ref/dotz.md) for callback functions
400400
<br>
401-
[`.Q.addr`](../ref/dotq.md#addr-ip-address) (IP address),
402-
[`.Q.host`](../ref/dotq.md#host-hostname) (hostname),
401+
[`.Q.addr`](../ref/dotq.md#addr-iphost-as-int) (IP/host as int),
402+
[`.Q.host`](../ref/dotq.md#host-ip-to-hostname) (IP to hostname),
403403
<br>
404404
:fontawesome-solid-book-open:
405405
[Connection handles](handles.md)

docs/basics/syscmds.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ q)1%3
530530
```
531531

532532
:fontawesome-solid-book:
533-
[`.Q.f`](../ref/dotq.md#f-format),
534-
[`.Q.fmt`](../ref/dotq.md#fmt-format)
533+
[`.Q.f`](../ref/dotq.md#f-precision-format) (precision format),
534+
[`.Q.fmt`](../ref/dotq.md#fmt-precision-format) (precision format with length)
535535
<br>
536536
:fontawesome-solid-book-open:
537537
[Precision](precision.md),

docs/cloud/aws-lambda/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ From the response payload we see the function was successful and calculated the
335335

336336
## Stream data from Amazon S3
337337

338-
To demonstrate a q/kdb+ Lambda function processing multiple events, we detail how to stream data from AWS Simple Storage Service (S3). Using FIFO named pipes and [`.Q.fps`](../../ref/dotq.md#fps-streaming-algorithm) within q, data can be streamed in for processing. To illustrate this example, we create 100 files each containing 1 million Black-Scholes input parameters. The files are placed in a S3 bucket. This S3 bucket is the trigger for the Lambda function.
338+
To demonstrate a q/kdb+ Lambda function processing multiple events, we detail how to stream data from AWS Simple Storage Service (S3). Using FIFO named pipes and [`.Q.fps`](../../ref/dotq.md#fps-pipe-streaming) (pipe streaming) within q, data can be streamed in for processing. To illustrate this example, we create 100 files each containing 1 million Black-Scholes input parameters. The files are placed in a S3 bucket. This S3 bucket is the trigger for the Lambda function.
339339

340340
:fontawesome-brands-aws:
341341
[Configuring Amazon S3 Event Notifications](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html)
@@ -365,7 +365,7 @@ The steps in the `process_s3data.q` code are as follows.
365365
1. Call S3 function from `Stream_Data` script, initiate FIFO pipe and stream in S3 data.
366366
1. Load `blackScholes.q`.
367367
1. Create inputs table to store input parameters.
368-
1. Use [`.Q.fps`](../../ref/dotq.md#fps-streaming-algorithm) to stream in the S3 data from the FIFO `pipe_stream` to inputs table.
368+
1. Use [`.Q.fps`](../../ref/dotq.md#fps-pipe-streaming) to stream in the S3 data from the FIFO `pipe_stream` to inputs table.
369369
1. Use [`.Q.fu`](../../ref/dotq.md#fu-apply-unique) to run the inputs through the `blackScholes` formula.
370370
1. `black_scholes_data` contains the input parameters and the calculated option prices.
371371

docs/github.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ GitHub topic queries:&nbsp;&nbsp;
117117
</td>
118118
</tr>
119119
<tr markdown>
120+
<td markdown class="nowrap"><a href="https://github.com/lukebrit27/surv-cloud">surv-cloud</a></td>
121+
<td markdown>Small market surveillance application for cloud/kubernetes. <span class="author"><a href="https://github.com/lukebrit27?tab=repositories">
122+
(Luke Britton)
123+
</a></span>
124+
</td>
125+
</tr>
126+
<tr markdown>
120127
<td markdown class="nowrap"><a href="https://github.com/simongarland/tickrecover">tickrecover</a></td>
121128
<td markdown>Recover from tickerplant crash. <span class="author"><a href="https://github.com/simongarland?tab=repositories">
122129
(Simon Garland)

docs/interfaces/q-server-for-odbc3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Ensure you have `ps.k` loaded into the kdb+ process specified in your DSN:
7070
q)\l ps.k
7171
```
7272

73+
The kdb+ process should also be [listening on port](../basics/listening-port.md) which relates to the port choosen and defined in the odbc configuration.
74+
7375

7476
## Notes
7577

docs/kb/loading-from-large-files.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The [Load CSV](../ref/file-text.md#load-csv) form of the File Text operator load
1313

1414
If the data in the CSV file is too large to fit into memory, we need to break the large CSV file into manageable chunks and process them in sequence.
1515

16-
Function [`.Q.fs`](../ref/dotq.md#fs-streaming-algorithm) and its variants help automate this process. `.Q.fs` loops over a file in conveniently-sized chunks of complete records, and applies a function to each chunk. This lets you implement a _streaming algorithm_ to convert a large CSV file into an on-disk database without holding all the data in memory at once.
16+
Function [`.Q.fs`](../ref/dotq.md#fs-file-streaming) (file streaming) and its variants help automate this process. `.Q.fs` loops over a file in conveniently-sized chunks of complete records, and applies a function to each chunk. This lets you implement a _streaming algorithm_ to convert a large CSV file into an on-disk database without holding all the data in memory at once.
1717

1818

1919
## Using `.Q.fs`
@@ -96,11 +96,11 @@ date open high low close volume sym
9696
Variants of `.Q.fs` extend it to [named pipes](named-pipes.md) and control chunk size.
9797

9898
:fontawesome-solid-book:
99-
[`.Q.fsn`](../ref/dotq.md#fsn-streaming-algorithm) for chunk size
99+
[`.Q.fsn`](../ref/dotq.md#fsn-file-streaming) for chunk size
100100
<br>
101101
:fontawesome-solid-book:
102-
[`.Q.fps`](../ref/dotq.md#fps-streaming-algorithm),
103-
[`.Q.fpn`](../ref/dotq.md#fpn-streaming-algorithm) for named pipes
102+
[`.Q.fps`](../ref/dotq.md#fps-pipe-streaming),
103+
[`.Q.fpn`](../ref/dotq.md#fpn-pipe-streaming) for named pipes
104104

105105
<!--
106106
To write to a partitioned database, some utility functions generalizing [`.Q.dpft`](../ref/dotq.md#dpft-save-table) are useful.
@@ -163,7 +163,7 @@ Unfortunately it is not always possible or is too expensive to structure the inp
163163

164164
We must
165165

166-
- read data in chunks using [`.Q.fsn`](../ref/dotq.md#fsn-streaming-algorithm)
166+
- read data in chunks using [`.Q.fsn`](../ref/dotq.md#fsn-file-streaming)
167167
- append data to splayed tables using manual enumerations and [`upsert`](../basics/qsql.md#upsert)
168168
- re-sort and set attributes on disk when all the data is loaded
169169
- write a daily statistics table as a splayed table at the top level of the database
@@ -444,7 +444,7 @@ openssl enc -aes-256-cbc -d –k password -in trades.csv.dat > named_pipe &
444444

445445
:fontawesome-solid-book:
446446
[`set`](../ref/get.md#set),
447-
[`.Q.fps`](../ref/dotq.md#fps-streaming-algorithm)
447+
[`.Q.fps`](../ref/dotq.md#fps-pipe-streaming) (pipe streaming)
448448
<br>
449449
:fontawesome-solid-laptop:
450450
[Named pipes](../kb/named-pipes.md)

docs/kb/named-pipes.md

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ keywords: fifo, kdb+, named, pipe, q, unix
55
---
66
# Named pipes
77

8-
9-
8+
## Overview
109

1110
Since V3.4 it has been possible to read FIFOs/named pipes on Unix.
1211

@@ -19,24 +18,69 @@ q)/ At most, n bytes will be read, perhaps fewer
1918
q)hclose h / Close the file to clean up
2019
```
2120

22-
[`.Q.fps`](../ref/dotq.md#fps-streaming-algorithm "streaming algorithm") is [`.Q.fs`](../ref/dotq.md#fs-streaming-algorithm "streaming algorithm") for pipes.
23-
(`.Q.fpn` corresponds to [`.Q.fsn`](../ref/dotq.md#fsn-streaming-algorithm "streaming algorithm").)
21+
A `` `:fifo://`` handle is also useful for reading certain non-seekable or zero-length (therefore, unsuitable for the regular `read1`) system files or devices, e.g.
22+
23+
```q
24+
q)a:hopen`:fifo:///dev/urandom
25+
q)read1 (a;8)
26+
0x8f172b7ea00b85e6
27+
q)hclose a
28+
```
29+
30+
## Streaming
31+
32+
[`.Q.fps`](../ref/dotq.md#fps-pipe-streaming) and [`.Q.fpn`](../ref/dotq.md#fpn-pipe-streaming) provide the ability to streaming data from a fifo/named pipe.
2433

25-
The following example loads a CSV via FIFO, avoiding decompressing to disk:
34+
This can be useful for various applications, such as streaming data in from a compressed file without having to decompress the contents to disk.
35+
36+
For example, using a csv file (t.csv) with the contents
37+
```csv
38+
MSFT,12:01:10.000,A,O,300,55.60
39+
APPL,12:01:20.000,B,O,500,67.70
40+
IBM,12:01:20.100,A,O,100,61.11
41+
MSFT,12:01:10.100,A,O,300,55.60
42+
APPL,12:01:20.100,B,O,500,67.70
43+
IBM,12:01:20.200,A,O,100,61.11
44+
MSFT,12:01:10.200,A,O,300,55.60
45+
APPL,12:01:20.200,B,O,500,67.70
46+
IBM,12:01:20.200,A,O,100,61.11
47+
MSFT,12:01:10.300,A,O,300,55.60
48+
APPL,12:01:20.400,B,O,500,67.70
49+
IBM,12:01:20.500,A,O,100,61.11
50+
MSFT,12:01:10.500,A,O,300,55.60
51+
APPL,12:01:20.600,B,O,500,67.70
52+
IBM,12:01:20.600,A,O,100,61.11
53+
MSFT,12:01:10.700,A,O,300,55.60
54+
APPL,12:01:20.700,B,O,500,67.70
55+
IBM,12:01:20.800,A,O,100,61.11
56+
MSFT,12:01:10.900,A,O,300,55.60
57+
APPL,12:01:20.900,B,O,500,67.70
58+
IBM,12:01:20.990,A,O,100,61.11
59+
```
60+
61+
If the file is compressed into a ZIP archive (t.zip), the system command `unzip` has the option to uncompress to stdout, which can be combined with a `fifo`.
62+
The following loads the CSV file through a FIFO without having the intermediary step of creating the unzipped file:
2663

2764
```q
2865
q)system"rm -f fifo && mkfifo fifo"
29-
q)system"unzip -p t.zip t.csv > fifo &"
3066
q)trade:flip `sym`time`ex`cond`size`price!"STCCFF"$\:()
67+
q)system"unzip -p t.zip > fifo &"
3168
q).Q.fps[{`trade insert ("STCCFF";",")0:x}]`:fifo
69+
q)trade
3270
```
3371

34-
A `` `:fifo://`` handle is also useful for reading certain non-seekable or zero-length (therefore, unsuitable for the regular `read1`) system files or devices, e.g.
72+
Alternatively, if the file was compressed using gzip (t.gz), the system command `gunzip` can be used:
3573

3674
```q
37-
q)a:hopen`:fifo:///dev/urandom
38-
q)read1 (a;8)
39-
0x8f172b7ea00b85e6
40-
q)hclose a
75+
q)system"rm -f fifo && mkfifo fifo"
76+
q)trade:flip `sym`time`ex`cond`size`price!"STCCFF"$\:()
77+
q)system"gunzip -cf t.gz > fifo &"
78+
q).Q.fps[{`trade insert ("STCCFF";",")0:x}]`:fifo
79+
q)trade
4180
```
4281

82+
:fontawesome-regular-hand-point-right:
83+
[`0:`](../ref/file-text.md#load-csv) (load csv)<br>
84+
:fontawesome-solid-book-open:
85+
[mkfifo](https://linux.die.net/man/1/mkfifo),
86+
[unzip](https://linux.die.net/man/1/unzip), [gunzip](https://linux.die.net/man/1/unzip)

docs/kb/using-dotz.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,4 @@ q)
430430
- [Changes in V2.4](../releases/ChangesIn2.4.md)
431431
- _Q for Mortals_: [§11.6 Interprocess Communication](/q4m3/11_IO/#116-interprocess-communication)
432432
- [Authentication and Authorization](../basics/ipc.md#authentication-authorization)
433+
- [Permissions with kdb+](../wp/permissions/index.md)

docs/ref/doth.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ q).h.cd (`a`b`c;1 2 3;"xyz")
9494
Columns can be nested vectors, in which case [`.h.d`](#hd-delimiter) is used to separate subitems. (Since V4.0 2020.03.17.)
9595

9696
:fontawesome-regular-hand-point-right:
97-
[0: load csv](file-text.md#load-csv)
97+
[0: load csv](file-text.md#load-csv), [save](save.md#save) (save and format data)
9898

9999

100100
## `.h.code` (code after Tab)
@@ -161,6 +161,8 @@ q).h.ed ([]a:1 2 3;b:`x`y`z)
161161
"<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:o=\"u..
162162
```
163163

164+
:fontawesome-regular-hand-point-right:
165+
[save](save.md#save) (save and format data)
164166

165167
## `.h.edsn` (Excel from tables)
166168

@@ -203,7 +205,8 @@ q)`:/Users/sjt/tmp/excel.xls 0: .h.edsn `test1`test2!(t1;t2)
203205

204206
![excel.xls](../img/h.edsn.png "Excel spreadsheet")
205207

206-
208+
:fontawesome-regular-hand-point-right:
209+
[save](save.md#save) (save and format data)
207210

208211
## `.h.fram` (frame)
209212

@@ -819,6 +822,9 @@ q).h.xd ([]a:1 2 3;b:`x`y`z)
819822
"</R>"
820823
```
821824

825+
:fontawesome-regular-hand-point-right:
826+
[save](save.md#save) (save and format data)
827+
822828

823829
## `.h.xmp` (XMP)
824830

@@ -865,4 +871,4 @@ foo| "bar"
865871
```
866872

867873
:fontawesome-regular-hand-point-right:
868-
[`.j` namespace](dotj.md) (JSON de/serialization)
874+
[`.j` namespace](dotj.md) (JSON de/serialization), [save](save.md#save) (save and format data)

0 commit comments

Comments
 (0)