-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjd.ijs
More file actions
312 lines (262 loc) · 8.47 KB
/
jd.ijs
File metadata and controls
312 lines (262 loc) · 8.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
NB. Copyright 2026, Jsoftware Inc. All rights reserved.
0 : 0
package manager Jd library is ~addons/data/jd
load'data/jd' NB. 'data/jd/jd.ijs'
production Jd application should run from dedicated folder to avoid pacman updates
load'~/production/jd/jd.ijs'
git developer Jd library is ~Jddev (~config/folders.cfg)
load'~Jddev/jd.ijs'
all use is through JDP_z_ (set when the library is loaded)
)
coclass'jd'
jdversion=: '4.48'
jdwelcome=: 0 : 0
Jd is Copyright 2026 by Jsoftware Inc. All Rights Reserved.
Jd is provided "AS IS" without warranty or liability of any kind.
License required: https://code.jsoftware.com/wiki/Jd/License
*** 4.48 (jd'list version')
4.48 is a major upgrade - most changes are upward compatible.
But proceed with caution!
*** server-client support in 4.48 is completely new
jdrt'server-client' NB. list server-client tutorials
tutorials relevant to server performance:
jdrt'each' NB. list of s to perform in one request
jdrt'custom' NB. custom op to perform transaction
*** man system
Jd wiki pages have not been updated yet for 4.48.
The latest is documented in the tutorials and with man.
Man docs are at your fingertips and are in same script as the code.
man'' NB. list mans that cover a topic
man'jd' NB. doc that preceeds jd=:
man'jdserver' NB. doc that preceeds jdserver=:
*** import csv/parquet/... files to J or Jd
jdrt'csv_load' NB. load csv file
jdrt'pandas_load' NB. load parquet or other formats
*** Jd wiki
Wiki documentation is at:
https://code.jsoftware.com/wiki/Jd/Index
*** get started
jdrt '' NB. tutorials
)
man_jd=:jdwelcome_jd_
man_jd_users=: 0 : 0
direct access users do not have passwords
jdaccess dan;user
sets the user and then each jd op
validates the user and op against the dan admin.ijs
server requires logon with user and a pswd
)
doin=: 4 : '(<x)(4 : ''do__y x'')each<"0 y' NB. run sentence in each locale
'Jd requires J807 or later'assert (807<:0".}.4{.9!:14'')+.3=4!:0<'revinfo_j_'
'Jd requires J64'assert IF64=1
('Jd not supported on UNAME: ',UNAME) assert (<UNAME)e.'Win';'Linux';'FreeBSD';'OpenBSD';'Darwin'
'Jd requires addon jfiles'assert fexist '~addons/data/jfiles/jfiles.ijs'
require'jfiles'
require'data/jmf'
require'convert/pjson'
missingkey=: '!!! Jd key: non-commercial key automatically installed'
noncomkey=: '!!! Jd key: non-commercial use only!'
invalidkey=: '!!! Jd key: invalid'
updatekey=: '!!! Jd key: expired - restore earlier version or get new key'
fkey=: '~config/jdkey.txt'
noncom=: 'a11544796265500412' NB. old free key
3 : 0''
if. IFWIN do.
'Jd requires Windows version > XP'assert 5<{:,(8#256)#:;'kernel32.dll GetVersion x' cd ''
NB. try. 'msvcr120.dll foo x'cd'' catch. end.
NB. t=. 'Jd requires msvcr120.dll',LF,'http://www.microsoft.com/en-ca/download/details.aspx?id=40784',LF,'download vcredist_x64.exe and run to install msvcr110.dll'
NB. t assert 2 0=cder''
end.
NB. ensure different (production vs development) Jd libraries are not both loaded
n=. '/jd.ijs'
d=. jpath each 4!:3''
f=. (;(<n)-:each (-#n){.each d)#d
'can not mix different Jd libraries' assert 1=#f
JDP_z_=: _6}.;f
NB. sever requires setsid so jds and node task will not end when the start task ends
NB. setsid is not in mac so we provide our own universal binary from github
SETSID=: ;(UNAME-:'Darwin'){'setsid';jpath JDP,'/cd/setsid/setsid'
t=. jpath JDP,'cd/'
if. (<UNAME)e.'Linux';'FreeBSD';'OpenBSD' do.
t=. t,IFRASPI{::'libjd.so';'rpi/libjd.so'
elseif. UNAME-:'Darwin' do.
t=. t,'libjd.dylib'
elseif. 1 do.
if. _1=nc<'DLLDEBUG__' do.
t=. t,('arm64'-:9!:56'cpu'){::'jd.dll';'jd-arm64.dll'
else.
t=. jpath'~/git/jd-cdsrc/makevs/x64/debug64/jddll.dll' NB. visual studio debug
echo t
end.
end.
'Jd share library missing'assert fexist t
NB. Jd must continue to use pcre library - work is required to make use of the new pcre2 library
select. UNAME
case. 'Linux';'FreeBSD';'OpenBSD' do. q=. (IFRASPI#'rpi/'),'libjpcre.so'
case. 'Darwin' do. q=. 'libjpcre.dylib'
case. do. q=. ('arm64'-:9!:56'cpu'){::'jpcre.dll';'jpcre-arm64.dll'
end.
q=. q,~JDP,'cd/'
'Jd pcre library missing'assert fexist q
LIBJD=: '"',t,'"'
JDT=: (LIBJD,' jdinit >x') cd '' NB. get jdt
k=. fread fkey
NB. no key or old free key map to JDP,'jdkey.txt'
if. (_1-:k)+.noncom-:(#noncom){.k do.
pk=. }:JDP
echo noncomkey
else.
pk=. '~config'
echo '!!! Jd key:',(k i.' ')}.k
end.
r=. (LIBJD,' jdlicense >x x *c') cd JDT;<jpath pk
if. _1=r do. assert 0[echo invalidkey end.
NB. if. _2=r do. assert 0[echo evalkey end.
if. _3=r do. assert 0[echo updatekey end.
'Jd binary and J code mismatch - bad install'assert r=8 NB. 7 - jd3 and 8 -jd4
'Jd regexinit failed'assert 0=(LIBJD,' regexinit >x x *c') cd JDT;<q
)
load@:(JDP&,);._2 ]0 :0
base/util_epoch.ijs
base/util_ptable.ijs
base/util.ijs
base/zutil.ijs
base/pm.ijs
base/common.ijs
base/folder.ijs
base/database.ijs
base/table.ijs
base/fixpairs.ijs
base/parse.ijs
base/column.ijs
base/constants.ijs
base/keyindex.ijs
base/read.ijs
base/where.ijs
base/jmfx.ijs
base/lock.ijs
base/log.ijs
base/validate.ijs
tools/setscriptlists.ijs
tools/csv_load.ijs
tools/python3.ijs
api/api.ijs
api/api_adm.ijs
api/api_blob.ijs
api/api_change.ijs
api/api_create.ijs
api/api_csv.ijs
api/api_csvcdefs.ijs
api/api_drop.ijs
api/api_gen.ijs
api/api_info.ijs
api/api_misc.ijs
api/api_read.ijs
api/api_rename.ijs
api/api_replicate.ijs
api/api_sort.ijs
api/api_table.ijs
csv/csv.ijs
csv/csvinstall.ijs
dynamic/base.ijs
dynamic/ref.ijs
server/manager.ijs
server/client/jclient.ijs
server/jds/jds_server.ijs
server/jds/jds_tools.ijs
server/jds/jdup.ijs
server/node/node_tools.ijs
tools/tests.ijs
types/base.ijs
types/numeric.ijs
types/autoindex.ijs
types/byte.ijs
types/datetimes.ijs
types/epoch.ijs
types/varbyte.ijs
)
require'~addons/ide/jhs/extra/man.ijs'
require'~addons/ide/jhs/port.ijs'
require'~addons/net/jcs/jcs.ijs'
repair=: 3 : 0
load JDP,'tools/repair.ijs'
repair''
)
get_handle_limits=: 3 : 0
LIBC=: unxlib'c'
RLIMIT_NOFILE=: ('Darwin'-:UNAME){7,8 NB. assume rpi has linux value
MAX_OPEN=: 10240*>:-.'Darwin'-:UNAME NB. macos hardwired 10420, linux higher
;{:(LIBC,' getrlimit i i *x') cd RLIMIT_NOFILE;0 0
)
set_handle_limit=: 3 : 0
r=. get_handle_limits''
;{.(LIBC,' setrlimit i i *x') cd RLIMIT_NOFILE;y,{:r
)
3 : 0''
if. _1=nc<'jdscpath' do. jdscpath=: 'jdscpath/' end. NB. path to all server/client files
IFTESTS=: 0
if. _1=nc<'OP' do. NB. one time inits
IFJDS_z_=: 0
oplogdata=: '' NB. performance data
jdaccess '';''
JDMT=: MTRW_jmf_
JDMTMRO=: 0 NB. not an mtm ro task
FEOP=: OP=: 'none'
TEMPCOLS=: i.0 2
LOGOPS=: 0 NB. do not log ops
log_size_limit=: 16e6 NB. applies to all logs (logtxt abd jdslog)
cntsclear''
FORCEVALIDATEAFTER=: 0
FORCEREVERT=: 0
FORCELEFT=: 0 NB. force all refs to be /left for testing
PMON=: 0 NB. performance monitor not recording
PMN=: PMT=: '' NB. no records
PMMR=: 100 NB. max records kept
end.
if. -.UNAME-:'Win' do.
r=. get_handle_limits''
if. MAX_OPEN>{.r do. set_handle_limit MAX_OPEN end.
r=. {.get_handle_limits''
if. r<10240 do. echo LF,~LF,~LF,'Warning: ',(":r),' for limit on number of file handles is low. See Technotes|file handles.' end.
end.
ifintel=: 'a'={.2 ic a.i.'a' NB. endian
)
NB. from JHS
seebox=: 3 : 0
1 seebox y
:
;((x+>./>#each y){.each "1 y),.<LF
)
t=. 0 : 0
casual use is OK from pacman folder (pacman can update to new code)
load'jd' NB. ~addons/data/jd is fine for casual use
serious use should have its own folder (copy ~addons/data/jd to ~/production)
load'~/production/jd/jd.ijs' NB. load production Jd
)
echo (JDP-:'/',~jpath'~addons/data/jd')#t
echo (10<#1 1 dir jdscpath_jd_,'client')#LF,LF,~LF,~'warning: folder jdscpath/client may need attention'
echo' jdwelcome_jd_ NB. run this sentence for important information'
0 : 0
release 4.48
*** load
'git/addons/data/jd/jd.ijs'fwrite 'gitjd'
load'gitjd'
*** jd server uses node/zmq - older servers killed off
*** jd result
'Jd ok' mapped to i. 0 0 and now maps to ,:'Jd OK';0
*** info /lr result forced for non jbin server users
*** jd and s1 (server)
[signal] jd 'info x' NB. 1 default
0 jd 'info x' NB. returns Jd error result
1 jd 'info x' NB. signals error
'an op' jdce 0 jd 'info x' NB. like jdae but can be used with s1
*** each
jd'each';(<...),(<...),<...
*** IFJDS_z_ set for direct vs server
*** jdi_... jd_read concerns about internal use
jdi_ killed - seemed to be a noop
custom.ijs and several others made internal jd_read/info calls
most of these have been replace by normal jd'...' calls
seems to be OK
why was jdi or jd_... ever needed (p;erhaps older style sever)?
)