0

I want to make changes to some EDBs and then find out how the IDBs changed as a result.

The docs say that the query stage comes after the final stage and "has access to the effects of stage FINAL". But if I run

query '_(id) <- ^level(id; _).'

(where level is an IDB) I get

block block_1Z7PZ61E: line 2: error: predicate level is an IDB, therefore deltas for it will not be available until stage final. (code: STAGE_INITIAL_IDB_DELTA)
    ^level(id; _).
    ^^^^^^^^^^^^^

1 ERROR
BloxCompiler reported 1 error in block 'block_1Z7PZ61E'

I also tried following the diff predicate example. But this

query '_(id) <- (level\level@prev)(id; _).'

causes a syntax error:

block block_1Z80EFSZ: line 2: error: illegal character 'U+005C' (code: ILLEGAL_CHARACTER)
    (level\level@prev)(id; _).
          ^

block block_1Z80EFSZ: line 2: error: unexpected token 'level' (code: UNEXPECTED_TOKEN)
    (level\level@prev)(id; _).
           ^^^^^

block block_1Z80EFSZ: line 2: error: unexpected token ')' (code: UNEXPECTED_TOKEN)
    (level\level@prev)(id; _).
                     ^

block block_1Z80EFSZ: line 2: error: unexpected token ';' (code: UNEXPECTED_TOKEN)
    (level\level@prev)(id; _).
                         ^

4 ERRORS
BloxCompiler reported 4 errors in block 'block_1Z80EFSZ'

1 Answers1

0

Unfortunately the diff predicate functionality is not yet released (as of Dec 2016). We've noted that as a documentation bug to fix. The feature is expected in LB 4.4 in Q1 2017.

Here's a simple example for printing or querying the values in the IDB predicate after changes to the EDB. You don't need to use delta logic in this case.

[dan@glycerine Fri Dec 30 09:55:54 ~/Temp]
$ cat foo.logic
foo(x), foo_id(x: y) -> int(y).
edb[x] = y -> foo(x), int(y).
idb[x] = y -> foo(x), int(y).
idb[x] = y <- edb[x] + 10 = y.
[dan@glycerine Fri Dec 30 09:56:33 ~/Temp]
$ lb create --overwrite foo && lb addblock foo --name foo --file foo.logic && lb exec foo '+foo(x), +foo_id[x] = 1, +edb[x] = 5.'
created workspace 'foo'
added block 'foo'
[dan@glycerine Fri Dec 30 09:57:23 ~/Temp]
$ lb print foo edb
[10000000005] 1 5
[dan@glycerine Fri Dec 30 09:57:28 ~/Temp]
$ lb print foo idb
[10000000005] 1 15
[dan@glycerine Fri Dec 30 09:57:32 ~/Temp]
$ lb exec foo '^edb[x] = 15 <- foo_id[x] = 1.'
[dan@glycerine Fri Dec 30 09:57:54 ~/Temp]
$ lb print foo idb
[10000000005] 1 25
[dan@glycerine Fri Dec 30 09:57:55 ~/Temp]
$ lb query foo '_[x] = edb[x].'
/--------------- _ ---------------\
[10000000005] 1 15
\--------------- _ ---------------/

I can think of a couple options for watching changes more as they happen. In once case you could create a watcher predicate and add values to it like this.

watcher(x, y) -> int(x), int(y).
^watcher(x, y) <- foo_id[x] = id, ^idb[id] = y.

That could be enhanced to have its own entity and timestamp...

Another way, if you are using web services to make the EDB updates, is to use

lb web-server monitor -w foo idb

to watch a list of predicates.

  • I have a really large IDB and another program that wants to subscribe to changes, so I'm specifically looking for a diff and not just a printout of the whole thing. `monitor` sounds promising but what do I do with it? It's not mentioned in the reference manual and the help string is not enlightening - https://gist.github.com/jamii/64f3beaec9e6027f38b630b85e133ae4 – Jamie Brandon Dec 31 '16 at 16:26