(library (sph storage dg relation path-find base) (export default-read-count get-relations-invert get-relations-proc negative-combinator? negative-expression? result-get-relations result-get-relations-invert unary-combinator?) (import (sph) (sph storage dg) (sph storage dg relation record-list) (sph storage dg stream) (srfi srfi-41)) (define default-read-count 20) (define (negative-combinator? a) (eq? (q not) a)) (define unary-combinator? negative-combinator?) (define (negative-expression? a) (or (not a) (and (list? a) (not (null? a)) (negative-combinator? (first a))))) (define (get-relations-invert proc) "procedure -> procedure returns a get-relations procedure where the order of source and target is reversed. (s t) -> (t s)" (l (s t r) (proc t s r))) (define (result-get-relations-invert proc) "procedure -> procedure" (l (result s t) (proc result t s))) (define (get-relations-proc txn label) "dg-txn list -> procedure:{list:source list:target symbol/false:retrieve-field-name -> relation-record-stream} wraps txn and label and returns the main procedure used in path-find to get relations from the database" (l (s t r) (dg-selection->element-stream (dg-relation-select txn s t label r) dg-relation-read default-read-count))) (define (result-get-relations record-stream left right) "stream:(vector ...) (integer ...):left (integer ...):right -> (vector ...) like dg-relation-select-read but on a list of result records and with less features" (stream-filter (dg-relation-record-list-filter-lr-proc left right) record-stream)))