Skip to content

Commit 10de1ab

Browse files
authored
Merge pull request #398 from gyorokpeter/flip_splayed
add more details about flip-splayed
2 parents 5a2b659 + 2363517 commit 10de1ab

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

docs/ref/flip-splayed.md

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,80 @@ keywords: flip, flip splayed, kdb+, partitioned, q, splayed, table
1313
x!y ![x;y]
1414
```
1515

16-
Where `x` is a symbol list and `y` is
16+
This operation is used internally by kdb+ to represent the flip of a memory-mapped splayed table. When loading a database with [`\l`](../basics/syscmds.md#l-load-file-or-directory), the tables in the database are added to the root namespace in this representation.
1717

18-
- an **hsym symbol atom** denoting a **splayed** table
19-
- a **non-hsym symbol atom** denoting a **partitioned** table
18+
Where `x` is a symbol list containing the names of the table columns and `y` is
2019

21-
returns the flip of `y`.
20+
- an **hsym symbol atom** denoting the path to a **splayed** table
21+
- a **non-hsym symbol atom** denoting the name of a **partitioned** table
22+
23+
returns an object that must be [flipped](flip.md) in order to use it as a table. After flipping, queries will use the memory-mapped on-disk table. Certain operations (including the extra-argument overloads of [`select`](select.md)) will throw a `par` or `nyi` error when used on a partitioned table.
24+
25+
```q
26+
q)`:db/t/ set ([]a:1 2)
27+
`:db/t/
28+
q)\l db
29+
q).Q.s1 t
30+
"+(,`a)!`:./t/"
31+
q)t
32+
a
33+
-
34+
1
35+
2
36+
```
37+
38+
It is possible to manually create this representation:
39+
40+
```q
41+
q)enlist[`a]!`:./t/
42+
(,`a)!`:./t/
43+
q)flip enlist[`a]!`:./t/
44+
a
45+
-
46+
1
47+
2
48+
```
49+
50+
The equivalent for a partitioned table:
51+
52+
```q
53+
q)`:db/2001.01.01/t/ set ([]a:1 2)
54+
`:db/2001.01.01/t/
55+
q)`:db/2001.01.02/t/ set ([]a:3 4)
56+
`:db/2001.01.02/t/
57+
q)\l db
58+
q).Q.s1 t
59+
"+(,`a)!`t"
60+
q)enlist[`a]!`t
61+
(,`a)!`t
62+
q)flip enlist[`a]!`t
63+
date a
64+
------------
65+
2001.01.01 1
66+
2001.01.01 2
67+
2001.01.02 3
68+
2001.01.02 4
69+
q)select[1] from flip enlist[`a]!`t
70+
'nyi
71+
[0] select[1] from flip enlist[`a]!`t
72+
^
73+
```
74+
75+
If the specified table does not exist on disk, the expression remains unresolved and any attempt to query it fails:
76+
77+
```q
78+
q)flip enlist[`a]!`:./s/
79+
+(,`a)!`:./s/
80+
q)select from flip enlist[`a]!`:./s/
81+
'./s/a. OS reports: No such file or directory
82+
[0] select from flip enlist[`a]!`:./s/
83+
q)flip enlist[`a]!`s
84+
+(,`a)!`s
85+
q)select from flip enlist[`a]!`s
86+
's
87+
[0] select from flip enlist[`a]!`s
88+
^
89+
```
2290

2391
---
2492
:fontawesome-solid-book-open:

0 commit comments

Comments
 (0)