15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#f ;; the main db (contains runs, test_meta etc.) NOT CACHED IN MEM
(make-hash-table) ;; run-id => [ rundb inmemdb last-mod last-read last-sync ]
#f ;; the global string db (use for state, status etc.)
path ;; path to database files/megatest area
local)) ;; read-only local access
;; get and set main db
(define-inline (dbr:dbstruct-get-main vec) (vector-ref vec 0))
(define-inline (dbr:dbstruct-set-main! vec db)(vector-set! vec 0 db))
;; get a rundb vector
(define (dbr:dbstruct-get-rundb-rec vec run-id)
(let* ((dbhash (vector-ref vec 1))
(runvec (hash-table-ref/default dbhash run-id)))
(if runvec
runvec
(begin
(hash-table-set! dbhash run-id (vector #f #f -1 -1 -1 #f))
(dbr:dbstruct-get-rundb-rec vec run-id)))))
;; [ rundb inmemdb last-mod last-read last-sync ]
|
|
|
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#f ;; the main db (contains runs, test_meta etc.) NOT CACHED IN MEM
(make-hash-table) ;; run-id => [ rundb inmemdb last-mod last-read last-sync ]
#f ;; the global string db (use for state, status etc.)
path ;; path to database files/megatest area
local)) ;; read-only local access
;; get and set main db
(define-inline (dbr:dbstruct-get-main vec) (vector-ref vec 0))
(define-inline (dbr:dbstruct-set-main! vec db)(vector-set! vec 0 db))
;; get a rundb vector
(define (dbr:dbstruct-get-rundb-rec vec run-id)
(let* ((dbhash (vector-ref vec 1))
(runvec (hash-table-ref/default dbhash run-id #f)))
(if runvec
runvec
(begin
(hash-table-set! dbhash run-id (vector #f #f -1 -1 -1 #f))
(dbr:dbstruct-get-rundb-rec vec run-id)))))
;; [ rundb inmemdb last-mod last-read last-sync ]
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
(let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id))
(fieldnum (dbr:dbstruct-field-name->num field-name)))
;; (vector-set! runvec (dbr:dbstruct-field-name->num 'inuse) #t)
(vector-ref runvec fieldnum)))
(define (dbr:dbstruct-set-runvec! vec run-id field-name val)
(let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
(vector-set! runvec (dbr:dbstruct-field-name->num field-name) rundb)))
;; get/set inmemdb
(define (dbr:dbstruct-get-inmemdb vec run-id)
(let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
(vector-ref runvec 1)))
(define (dbr:dbstruct-set-inmemdb! vec run-id inmemdb)
|
|
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
(let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id))
(fieldnum (dbr:dbstruct-field-name->num field-name)))
;; (vector-set! runvec (dbr:dbstruct-field-name->num 'inuse) #t)
(vector-ref runvec fieldnum)))
(define (dbr:dbstruct-set-runvec! vec run-id field-name val)
(let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
(vector-set! runvec (dbr:dbstruct-field-name->num field-name) runvec)))
;; get/set inmemdb
(define (dbr:dbstruct-get-inmemdb vec run-id)
(let ((runvec (dbr:dbstruct-get-rundb-rec vec run-id)))
(vector-ref runvec 1)))
(define (dbr:dbstruct-set-inmemdb! vec run-id inmemdb)
|