forked from kraison/vivace-graph
-
Notifications
You must be signed in to change notification settings - Fork 1
/
graph.lisp
37 lines (32 loc) · 1.34 KB
/
graph.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(in-package #:vivace-graph)
(setq *graph-table* (make-uuid-table :synchronized t))
(defstruct (graph
(:predicate graph?)
(:conc-name nil)
(:print-function print-graph))
(graph-uuid (make-uuid))
(graph-name nil)
(shutdown? nil)
(graph-location #P".")
(triple-db nil)
(functor-db nil)
(rule-db nil)
(full-text-idx nil)
(rule-idx (make-hash-table :synchronized t :test 'equal))
(templates (make-hash-table :synchronized t))
(functors (make-hash-table :synchronized t))
(rule-cache (make-hash-table :synchronized t))
(predicate-cache (make-hash-table :synchronized t))
(node-cache (make-hash-table :test 'equal :synchronized t)) ;:weakness :key-or-value))
(triple-cache (make-hash-table :test 'equal :synchronized t)) ;:weakness :key-or-value))
(production-pq (make-skip-pq :key-equal #'timestamp= :comparison #'timestamp>
:head-value (make-timestamp :day -1000000 :sec 0 :nsec 0)))
(delete-queue (sb-concurrency:make-queue))
(needs-indexing-q (sb-concurrency:make-queue)))
(defun print-graph (graph stream depth)
(declare (ignore depth))
(format stream "#<GRAPH #~A: ~A>" (graph-uuid graph) (graph-name graph)))
(defgeneric needs-indexing? (graph))
(defgeneric shutdown-graph (graph &key waitp))
(defmethod needs-indexing? ((graph graph))
(not (sb-concurrency:queue-empty-p (needs-indexing-q graph))))