Hi Oscar,

> I've been trying make a small database server that can be accessed from
> different machines running different picolisp processes.
> Reading about it on the documentation it seems that its possible to set up
> a distributed database using ext,

That's right.

> but its not really clear to me how the setup would go

A fragmentary example is in the reference for '*Ext'


You need to specify an IP-address and an external symbol offset for each
remote machine.

What is the external symbol offset? External symbols reside in the DB in
a number of files, usually specified with 'dbs'. The demo example in
"app/er.l" has 12 files:

      (3 +Role +User +Sal (+User pw))              # 512 Prevalent objects
      (0 +Pos)                                     # A:64 Tiny objects
      (1 +Item +Ord)                               # B:128 Small objects
      (2 +CuSu)                                    # C:256 Normal objects
      (2 (+Role nm) (+User nm) (+Sal nm))          # D:256 Small indexes
      (4 (+CuSu nr plz tel mob))                   # E:1024 Normal indexes
      (4 (+CuSu nm))                               # F:1024
      (4 (+CuSu ort))                              # G:1024
      (4 (+Item nr sup pr))                        # H:1024
      (4 (+Item nm))                               # I:1024
      (4 (+Ord nr dat cus))                        # J:1024
      (4 (+Pos itm)) )                             # K:1024

This means that all objects have file numbers between 0 and 11 (@ .. K).
Files above K would give an error if accessed. A symbol like {K1} is
accessible, while {L1} is outside the local range.

Now, with 'ext' you map remote objects into the local symbol space.

Specifying offsets like (20 40 60 80) means that the objects of the
first machine can be accessed locally with an offset of 20, those of the
second with 40, and so on.

For example, the object {B7} on the first remote machine will be visible
locally as {AF7} because (hax "B") -> 2 and (hax "AF") -> 22, i.e. an
offset of 20. You can do

   : (show '{AF7}))

and see the contents of {B7} on the first machine, and

   : (show '{BJ7})

to see the contents of {B7} on the second machine.

This was an explanation the mechanisms, and sounds more complicated than
it actually is. In praxis, you don't care about these file numbers and
object names.

You basically need to do do only this:

1. Decide an offset larger than the length of your 'dbs' list. Above,
   the length was 12, so we took 20. Remember that all your files must
   be between 0 and 65535.
2. Define '*Ext' like in the reference, for your IP-addresses and
3. Start a server 'task' on each remote machine, as in the demo
   "app/main.l" in the 'go' function.
4. Done. Now you can (val '{AF7}) or (get '{AF7} 'foo) to access the
   value and properties of object '{B7} on a remote machine.

> and if it would be possible for the terminal processes to 
> make changes to the database.

Direct changes (like (put!> MyObj 'foo 7)) can be done only to local
objects. Remote objects must be changed with RPC mechanisms, by sending
this expression to a remote machine.

BTW, another example for this mechanism can be seen in "java/lib.l".
Here Java objects in the JVM are treated like a remote database, and
show up as normal external symbols in PicoLisp. See the article at


♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to