Admin names have a jd
prefix and are defined in the z
or jd
locales. See tutorial admin_tut.
admin/general utilities in the jd locale
'new' jdadmin 'ab' NB. create and open new db ~temp/jd/ab
'new' jdadmin '.../ab' NB. create and open new db .../ab
jdadmin 'ab' [;mt] NB. open db ~temp/jd/ab
jdadmin '.../ab' [;mt] NB. open db .../ab
jdadmin '' NB. admin report
jdadmin 0 NB. close all
Left arg 'new' creates and opens a new database in the folder. It fails if the folder:
mt parameter is map type and is used in mapping files.
0 - MTRW - [w] - write and read - default
1 - MTRO - [r] - read only
2 - MTCW - [c] - copy on write
A Jd task can have more than 1 db open as MTRW. A Jd task can have only 1 db open if it is MTRO or MTCW.
An exclusive lock prevents more than one task mapping a db as MTRW.
Multiple tasks can map a db as MTRO or MTCW while another task has the same db mapped MTRW. But care is required or changes by the MTRW task will cause problems or crashes in the MTRO/MTCW tasks.
MTCW allows efficiently working with what seems to be a private copy of the db. When the db is closed, all changes are discarded.
MTCW does not support file resizing. Insert works as expected as long as the data fits in space already allocated to the file. But a file resize does not work properly.
When a db is opened its admin.ijs is loaded to set the DAN (db access name) info and does jdaccess for the first DAN.
The db in a folder is accessed by a DAN. A DAN maps to folder, user/pwds, ops. Different DANs can access the same or different folders.
Set DAN (db access name), user/pwd, and server for jd ops:
server intask - op runs in the current J task
server localhost:x - op runs in the J JHS task at port x
server ipaddress:x - op runs in the J JHS task at ipaddress port x
server hostname:x - op runs in the J JHS task at hostname t port x
A SSH tunnel can securely connect localhost:x to a J task on a server:
jdaccess 'test me/xx intask' NB. DAN test, user/pswd u/p
jdaccess 'foo' NB. same as 'foo u/p intask'
jdaccess 'zz me/xx localhost:65002'
jdaccess '' NB. report
jdaccess 0 NB. clear access
admin.ijs is a script in the db folder, and is loaded by jdadmin.
The default contents are:
'ab' jdadminfp '' NB. DAN ab maps to ~temp/jd/ab
'ab' jdadminup 'u/p' NB. requires default user/pwd
'ab' jdadminop '*' NB. allow all ops
Other examples:
'test' jdadminfp '' NB. DAN test maps to this db folder
'test' jdadminup 'u/p' NB. requires this user/pswd
'test' jdadminop '*' NB. allow all ops
'testro' jdadminfp '' NB. DAN testro maps to this db folder
'testro' jdadminup 'ab/de gh/jk' NB. requires these user/pwds
'testro' jdadminop 'read reads' NB. allow only read and reads
The verbs jdadminfp/jdadminup/jdadminop are usually run only in admin.ijs, and are used directly for temp changes or tests.
This is an optional script in the db folder. If present, it is loaded into the db locale when the db is opened.
It defines:
jd_xxx
- a jd opSee tutorials custom and aggregation.
Set DAN file path:
'test' jdadminfp_jd_ ''
jdadminfp_jd_ '' NB. report
Set lock on DAN db folder:
'test' jdadminlk_jd_ ''
jdadminlk_jd_ '' NB. report
Set ops allowed with DAN:
'test' jdadminop_jd_ 'read reads insert'
jdadminop_jd_ '' NB. report
Set user/pswds allowed with DAN:
'test' jdadminup_jd_ 'fred/secret sam/birthday'
jdadminup_jd_ '' NB. report
Set column defs for createtable from labeled row data:
jdcdef d
See tutorial table_from_array.
mark db to do flush in a close
jdcloseflush_jd_ 1 NB. mark to do
jdcloseflush_jd_ 0 NB. remove mark
Get column locales:
jdclocs t;c
''
for all tables or 'tab'
for just that table''
for all cols or 'col'
for just that colThe result is sorted by table names.
Column names int a table are in created order followed by jd... names
Return normal (not jd prefix) column names and locales sorted by name:
jdcols'tab'
Same as jdcols except it includes ref cols.
Creates required folders for path:
jdcreatefolder'~temp/jd/a/b'
Writes a db jddamage
file.
jddamage_jd_'reason' NB. writes db jddamage file - prevents jd ops
jddamage_jd_'' NB. erases db jddamage file - allows jd ops
This deletes a folder, and is used internally by jd drop... ops.
jddeletefolder_jd_'~/jd/test'
It follows these rules in order:
This writes a jddeleteok file to a folder to allow jddeletefolder. Result is the arg.
jddeletefolderrok_jd_'~/jd/test'
This writes a jddropstop file to a folder:
[1] jddropstop '' NB. write jddropstop file in folder and subfolders
[1] jddropstop 'tab'
[1] jddropstop 'tab col'
0 jddropstop '' NB. erase jddropstop file in folder and subfolders
1 jddropstop 'tab'
1 jddropstop 'tab col'
dropdb/droptable/dropcol fail if there is a jddropstop file in the folder.
See tutorial dropstop.
Run insert example from User:
jdex'insert'
Make col names valid in labeled row data:
jdfixcolnames d
Performance measurement (pm) scripts use jdflush for more accurate benchmarks.
jdflush_jd_''
On Windows this is a noop.
On Linux, this calls a jdflush
shell script, which should be defined in the path as appropriate for your system. For example:
#!/bin/bash
sudo sync
sudo blockdev --flushbuf /dev/sda
sudo blockdev --flushbuf /dev/sdb
sudo sysctl vm/drop_caches=3
Brute force clean slate: unmaps all files and erases all locales. Can be useful if session state is badly messed up and things don't work properly. Similar to a complete restart. Used in jd3 to jd4 conversion if a conversion fails in order to continue with the next conversion.
Calls fread
with handle limit error assert.
Returns a column from a jd'read...'
'col' jdfrom_jd_ jd'read from f'
Returns a column from a jd'reads...'
'col' jdfroms_jd_ jd'reads from f'
Calls fwrite
with handle limit error assert.
Get locales:
jdgl_jd_'tab' NB. get locale for table
jdgl_jd_'tab col' NB. get locale for table column
Get states:
jdgs_jd_'tab' NB. get state for table
jdgs_jd_'tab col' NB. get state for table column
Move column data files:
jdlinkmove_jd_ 'tab/col ~temp/linker'
Column data files can be moved (usually to another drive). The folder structure is updated so the column folder points to the new location.
Some reasons for relocating cols:
See tutorial link.
Set (table/column path) definitions in the db folder link.txt file.
jdlinkset_jd_ 0 : 0
f/int ~temp/linker0
f/varbyte ~temp/linker1
)
jdlinkset_jd_'' NB. report db links.txt
Create column (including csvrd/csvrestore) uses link.txt to do folder links.
See tutorial link.
Report jdlinkmove/jdlinkset folder targets:
jdlinktargets_jd_''
See tutorial link.
Show log.ijf:
jdlogijfshow_jd_'' NB. log.ijf summary
jdlogijfshow_jd_ 0 NB. component 0
See tutorial log.
Show log.txt:
jdlogtxtshow_jd_ 10 NB. log.txt last 10 lines
See tutorial log.
Return path (ending in /) to db folder plus y:
jdpath_jd_''
jdpath_jd_'custom.ijs'
Same as jdpath except jpath not used to resolved ~
See repair.
List or run tutorials:
jdrt_jd_'' NB. list tutorials
jdrt_jd_'intro' NB. run tutorial
Stop Jd JHS server:
jdserverserverstop_jd_''
This sets OKURL_jhs_
to empty to stop Jd from serving clients.
This sets permissions for accessing the db from another account. This may be best done with host tools by someone who understands security, but jdshare
might be useful in simple situations.
jdshare_jd_'rwrwrw' NB. rw or r- or -- for owner/group/others
Normally the Jd task account owns the db folder.
Giving another account access to the db folder allows Jd tasks running as that account to access the db.
Lock prevents problems with multiple Jd tasks running as the owner or another account from using the db at the same time.
This randomly deletes and reinserts rows, and can be used in tests for the proper functioning of dynamic cols. The table at the end has the same number rows it started with.
jdshuffle_jd_ 'tab'
Lists table names and locales sorted by names:
jdtables_jd_'tab'
Test error formatting:
jdtesterrors_jd_''
Run tests:
[0 or 1] jdtests_jd_ y NB. 1 echos names as tests are run
The right argument is:
''
- csv-tests, build-demos, and all tests/tutorials'fast'
- skip csv-tests and build-demos'csv'
- run only csv-testsThe source folders are:
~addons/data/jd/test/core
- original non api tests (0!:3 implied assert on every line)~addons/data/jd/test
- tests with asserts~addons/data/jd/tutorial
- tutorials with asserts~addons/data/jd/demo
- scripts that build/test northwind,sandp,sed,vrReturn basic Jd type from data. Does not handle edate etc.