Jd/Admin
Jd | Overview | General | Docs | Ops | Admin | Server | Replicate | Guide | Technical | Release | License | Support
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
jdadmin
'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:
- is not a jd folder and is not empty
- is a jd folder but not class database
- is a jd class database folder with jddropstop
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.
jdaccess
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
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.
custom.ijs
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 op
- ... addagg ... - custom aggregation
See tutorials custom and aggregation.
jdadminfp
Set DAN file path:
'test' jdadminfp_jd_ '' jdadminfp_jd_ '' NB. report
jdadminlk
Set lock on DAN db folder:
'test' jdadminlk_jd_ '' jdadminlk_jd_ '' NB. report
jdadminop
Set ops allowed with DAN:
'test' jdadminop_jd_ 'read reads insert' jdadminop_jd_ '' NB. report
jdadminup
Set user/pswds allowed with DAN:
'test' jdadminup_jd_ 'fred/secret sam/birthday' jdadminup_jd_ '' NB. report
jdcdef
Set column defs for createtable from labeled row data:
jdcdef d
See tutorial table_from_array.
jdcloseflush
mark db to do flush in a close
jdcloseflush_jd_ 1 NB. mark to do jdcloseflush_jd_ 0 NB. remove mark
jdclocs
Get column locales:
jdclocs t;c
- t is '' for all tables or 'tab' for just that table
- c is '' for all cols or 'col' for just that col
The result is sorted by table names.
Column names int a table are in created order followed by jd... names
jdcols
Return normal (not jd prefix) column names and locales sorted by name:
jdcols'tab'
jdcolsx
Same as jdcols except it includes ref cols.
jdcreatefolder
Creates required folders for path:
jdcreatefolder'~temp/jd/a/b'
jddamage
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
jddeletefolder
This deletes a folder, and is used internally by jd drop... ops.
jddeletefolder_jd_'~/jd/test'
It follows these rules in order:
- error if locked
- error if a file
- OK if jddeletok exists
- error if jddropstop exists
- OK if empty
- OK if jdclass or in ~temp
- otherwise, not allowed
jddeletefolderok
This writes a jddeleteok file to a folder to allow jddeletefolder. Result is the arg.
jddeletefolderrok_jd_'~/jd/test'
jddropstop
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.
jdex
Run insert example from User:
jdex'insert'
jdfixcolnames
Make col names valid in labeled row data:
jdfixcolnames d
- table.col changes to table-col
- blank changes to underscore (_)
jdflush
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
jdforce_clean
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.
jdfread
Calls fread with handle limit error assert.
jdfrom
Returns a column from a jd'read...'
'col' jdfrom_jd_ jd'read from f'
jdfroms
Returns a column from a jd'reads...'
'col' jdfroms_jd_ jd'reads from f'
jdfwrite
Calls fwrite with handle limit error assert.
jdgl
Get locales:
jdgl_jd_'tab' NB. get locale for table jdgl_jd_'tab col' NB. get locale for table column
jdgs
Get states:
jdgs_jd_'tab' NB. get state for table jdgs_jd_'tab col' NB. get state for table column
jdlinkmove
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:
- improve performance by having i/o on multiple drives
- take advantage of particular drives
- ssd or slower or faster or high capacity
See tutorial link.
jdlinkset
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.
jdlinktargets
Report jdlinkmove/jdlinkset folder targets:
jdlinktargets_jd_''
See tutorial link.
jdlogijfshow
Show log.ijf:
jdlogijfshow_jd_'' NB. log.ijf summary jdlogijfshow_jd_ 0 NB. component 0
See tutorial log.
jdlogtxtshow
Show log.txt:
jdlogtxtshow_jd_ 10 NB. log.txt last 10 lines
See tutorial log.
jdpath
Return path (ending in /) to db folder plus y:
jdpath_jd_'' jdpath_jd_'custom.ijs'
jdpathx
Same as jdpath except jpath not used to resolved ~
jdrepair
See repair.
jdrt
List or run tutorials:
jdrt_jd_'' NB. list tutorials jdrt_jd_'intro' NB. run tutorial
jdserverstop
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.
jdshuffle
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'
jdtables
Lists table names and locales sorted by names:
jdtables_jd_'tab'
jdtesterrors
Test error formatting:
jdtesterrors_jd_''
jdtests
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-tests
The 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,vr
jdtypefromdata
Return basic Jd type from data. Does not handle edate etc.