Skip to content

Commit 930c554

Browse files
authored
Merge pull request #362 from sshanks-kx/qen
update .Q.en ref with short example
2 parents 2dd9f1c + e9597a0 commit 930c554

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/ref/dotq.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,30 @@ When `dir` is a symbol handle, the function
538538

539539
!!! warning "Locking ensures two processes do not write to the sym file at the same time"
540540

541+
The following example uses `.Q.en` to enumerate to both the in-memory and disk `sym` domain, while
542+
saving the table output using [`set`](get.md#set):
543+
```q
544+
q)t1:([]col1:`a`b`c;col2:1 2 3)
545+
q)`:/tmp/db/t1/ set .Q.en[`:/tmp/db;t1];
546+
q)sym / contents of in-memory sym populated from symbols in table
547+
`a`b`c
548+
q)get `:/tmp/db/sym / on-disk sym same as in-memory sym
549+
`a`b`c
550+
q)get `:/tmp/db/t1/col1 / col1 enumerated against sym domain
551+
`sym$`a`b`c
552+
```
553+
Providing a new or updated table against an existing `sym` domain will read the existing on-disk sym domain before updating.
554+
Both the in-memory and on-disk version are updated to reflect the new state. Continuing with the same example shows the
555+
existing `sym` domain being altered:
556+
```q
557+
q)t2:([]col1:`a`d`e;col2:1 2 3)
558+
q)`:/tmp/db/t2/ set .Q.en[`:/tmp/db;t2]; / enumerate additional table against existing sym domain
559+
q)sym / in-memory sym now contains additional symbols
560+
`a`b`c`d`e
561+
q)get `:/tmp/db/sym / on-disk sym same as in-memory sym
562+
`a`b`c`d`e
563+
```
564+
541565
When `dir` is a generic null (since 4.1 2025.01.17), the function
542566
543567
- does not read/write/lock the `sym` file

0 commit comments

Comments
 (0)