︙ | | |
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-
+
+
|
;;======================================================================
;;======================================================================
;; A hash of hashes that can be kept in sync by sending minial deltas
;;======================================================================
(use format)
(use srfi-1 srfi-69)
(use srfi-1 srfi-69 sqlite3)
(import (prefix sqlite3 sqlite3:))
(declare (unit synchash))
(declare (uses db))
(declare (uses server))
(include "db_records.scm")
(define (synchash:make)
|
︙ | | |
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
-
-
+
+
|
;; (cdb:remote-run db:get-keys #f)
;; (cdb:remote-run db:get-num-runs #f "%")
;; (cdb:remote-run db:get-runs #f runnamepatt numruns *start-run-offset* keypatts)
;;
;; keynum => the field to use as the unique key (usually 0 but can be other field)
;;
(define (synchash:client-get proc synckey keynum synchash . params)
(let* ((data (apply cdb:remote-run synchash:server-get #f proc synckey keynum params))
(define (synchash:client-get proc synckey keynum synchash run-id . params)
(let* ((data (rmt:synchash-get run-id proc synckey keynum params))
(newdat (car data))
(removs (cadr data))
(myhash (hash-table-ref/default synchash synckey #f)))
(if (not myhash)
(begin
(set! myhash (make-hash-table))
(hash-table-set! synchash synckey myhash)))
|
︙ | | |
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
-
+
+
+
-
+
-
+
|
removs)
;; WHICH ONE!?
;; data)) ;; return the changed and deleted list
(list newdat removs))) ;; synchash))
(define *synchashes* (make-hash-table))
(define (synchash:server-get db proc synckey keynum . params)
(define (synchash:server-get dbstruct run-id proc synckey keynum params)
;; (debug:print-info 2 "synckey: " synckey ", keynum: " keynum ", params: " params)
(let* ((dbdat (db:get-db dbstruct run-id))
(db (db:dbdat-get-db dbdat))
(let* ((synchash (hash-table-ref/default *synchashes* synckey #f))
(synchash (hash-table-ref/default *synchashes* synckey #f))
(newdat (apply (case proc
((db:get-runs) db:get-runs)
((db:get-tests-for-runs-mindata) db:get-tests-for-runs-mindata)
((db:get-tests-for-run-mindata) db:get-tests-for-run-mindata)
((db:get-test-info-by-ids) db:get-test-info-by-ids)
(else
(print "ERROR: sync for hash " proc " not setup! Edits needed in synchash.scm")
print))
db params))
(postdat #f)
(make-indexed (lambda (x)
|
︙ | | |
112
113
114
115
116
117
118
119
120
121
122
123
124
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
+
|
;; (debug:print-info 2 "header: " header ", data: " data)
(cons (list "header" header) ;; add the header keyed by the word "header"
(map make-indexed data)))) ;; add each element keyed by the keynum'th val
(else
;; (debug:print-info 2 "Non-get runs call")
(map make-indexed newdat))))
;; (debug:print-info 2 "postdat: " postdat)
;; (if (not indb)(sqlite3:finalize! db))
(if (not synchash)
(begin
(set! synchash (make-hash-table))
(hash-table-set! *synchashes* synckey synchash)))
(synchash:get-delta postdat synchash)))
|