Admin names have a jd prefix and are defined in the z or jd locales. See tutorial admin_tut.
jdadmin '' NB. report all locks, DANs, and related info jdadmin 0 NB. release all locks and close all DANs jdadmin 'ab' NB. make DB ~temp/jd/ab available jdadmin '.../ab' NB. make DB .../ab available 'access'jadmin '' NB. lists jdaccess for available DANS
When a DB is made available 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.
A default admin.ijs is created if it does not exist. In the default, DAN is last path folder, and u/p is user/pwd
The lock on the db folder prevents interference by other tasks
Creates a new database, replacing any old database. It deletes any old folder, creates a new db folder, then does jdadmin.
jdadminnew 'aa' NB. create new database ~temp/jd/aa jdadminnew '.../bb' NB. create new database .../bb
A new database can be created in an empty folder. A new database overwrites an old database unless jddropstop is set.
Fails if folder:
- is a jd folder but not class database
- is a jd folder with jddropstop
- is not a jd folder and is not empty
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
Deprecated - same as jdadminnew
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
'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.
- jd_xxx - a jd op
- ... addagg ... - custom aggregation
See 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:
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:
- 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
Return normal (not jd prefix) column names and locales sorted by name:
Same as jdcols except it includes ref cols.
Creates required folders for path:
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.
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
This writes a jddeleteok file to a folder to allow jddeletefolder. Result is the arg.
This writes a jddropstop file to a folder:
 jddropstop '' NB. write jddropstop file in folder and subfolders  jddropstop 'tab'  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:
Make col names valid in labeled row data:
- table.col changes to table-col
- blank changes to underscore (_)
Performance measurement (pm) scripts use jdflush for more accurate benchmarks.
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.
jdgl_jd_'tab' NB. get locale for table jdgl_jd_'tab col' NB. get locale for table column
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:
- 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.
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:
See tutorial link.
jdlogijfshow_jd_'' NB. log.ijf summary jdlogijfshow_jd_ 0 NB. component 0
See tutorial log.
jdlogtxtshow_jd_ 10 NB. log.txt last 10 lines
See tutorial log.
Return path (ending in /) to db folder plus y:
Same as jdpath except jpath not used to resolved ~
List or run tutorials:
jdrt_jd_'' NB. list tutorials jdrt_jd_'intro' NB. run tutorial
Stop Jd JHS server:
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.
Lists table names and locales sorted by names:
Test error formatting:
[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
Return basic Jd type from data. Does not handle edate etc.