2017-08-27

(sph storage dg relation path-find)

path-find: find relations that match expressions like "all nodes that are right of all of some nodes".

part of sph-lib-dg

developer information

all database query features compile to calls to a single database access procedure. it would even be easy to replace it. the procedure takes two filter lists to filter for some elements in the left and some in the right part of pairs

to add custom combinators (like all/none/some), three procedures would need to be implemented: one for the case of no previous results, one for a previous result, and one for multiple previous results (these procedures are named get, consume-one, consume)

library description

path expression examples:

  (1 * 2)

  ((only 14 15) *)

  ((and 11 12) (not 24) (or 32 31))

  ((and 11 12) (not 24) (or (not (and 41)) (or 32 31) 32 31))

path expression syntax:

  path: skip/node ..1

  node: (combinator id/node ..1)

  combinator: and/or/only/not

  skip: */(* integer:max [integer:min])

  id: integer

other:

  s: source, t: target, r: retrieve/result

  get-relations :: (integer ...):source (integer ...):target symbol:retrieve-field-name

  directional-arguments: (procedure:get-relations procedure:result-get-relations symbol:target-field-name procedure:target-field-accessor)

  negative combinators (rejections): not

notes:

  path-find at first did not use streams and now uses streams in some places,

  utilised might not be utilised as effectively as they might, particularly when preparing the next "from" values of a path,

  where the whole stream is read

evaluation strategy - example:

  (and (or 1 2) (or 3 4)) (or (and 5 6) (and 7 8))

  (or 3 4) (7 8) -> stream

  stream (and 7 8) -> stream

  (and (or 1 2) (or 3 4)) (or (and 5 6) stream)

  (or 3 4) (5 6) -> stream

  stream (and 5 6) -> stream

  (and (or 1 2) (or 3 4)) (or stream stream)

  (or stream stream) -> stream

  (and (or 1 2) stream) (or (and 5 6) (and 7 8))

  (or 1 2) (7 8) -> stream

  stream (and 7 8) -> stream

  (and (or 1 2) stream) (or (and 5 6) stream)

  (or 1 2) (5 6) -> stream

  stream (and 5 6) -> stream

  (and (or 1 2) stream) (or stream stream)

  (or stream stream) -> stream

  (and stream stream) -> stream

  stream

evaluation with negation/"not" - example:

  (not (or 1 2)) (not (and 5 6))

  (or 1 2) #f -> non-targets

  #f (not (and 5 6)) -> possible-targets

  (not stream) -> stream -- possible-targets made available to not-consume

import name

(sph storage dg relation path-find)

exports

dg-path-find

procedure

signature

txn path [retrieve label direction] ->

dg-txn list [symbol list symbol] -> error/list

description

matches set relation paths like the following, and returns targets or target relations:

((and 11 12) (not 24) (or (all 41) (not 42) (or 32 31) 32 31))

(1 *)

(1 * 2)

dg-path-find-combinators

variable

dg-path-find-delete

procedure

signature

txn path [label direction] ->

dg-txn list [false/(integer ...) symbol:left/right] -> (vector ...)

description

delete target relations by path-find-path

dg-path-find-delete->targets

procedure

signature

dg-path-find-delete-arguments ... ->

symbol list -> (id ...)

description

delete target relations matching path and return the targets as retrieved with path-find


tags: programming guile documentation library scheme q1 sph-lib-dg sph-dg highlight sph-dg-guile path-find sph-storage-dg-relation-path-find