Alexander Burger wrote:
>
> Hi Cle,

Hi Alex,

> let me first correct some errors:
>
>> (pool test)
>
> This is a funny one. As the value of 'test' is a function
> definition, you get a rather strange database file ;-)

Ahhh ... this was a copy/paste error from the console into the mail. My
DB file was named "test" :-)

> The name "test", on the other hand, will give a conflict as there is
> a directory with that name. I take "x.db" for now:

Ahhh not for me ... as I am working within another directory parallel to
picoLisp ;-)

> (pool "x.db")

Ok, I agree :-)

>> (class +Test +Entity) (rel id (+Ref +String)) (rel src (+Ref
>> +String)) (rel tgt (+Ref +String))
>>
>> (new '(+Test) 'id "1"  'src A  'tgt B) (new '(+Test) 'id "11"  'src
>> B  'tgt "C") (new '(+Test) 'id "111"  'src C  'tgt "D")
>
> If 'new' is called this way, it will not create database objects but
> memory-resident symbols. You should call either

:-O But ... but ... but ... URGHS! :-( I had looked especially into the
"x.db" file and found my keys "1", "11" and "111" there. So I thought
.. now I feel stupid again :-(

No! I am stupid ... in my real program I used 'new!' and *not* 'new'. So
in my real slower program the DB was filled but only by accident :-}

(...)

> This would actually return no result at all, as you pass a _number_
> '1' while the key is a _string_. I suppose the double quotes got lost
> when copy/pasting the expression from the console?

Yes you are right! Those missing "" were not the problem. Only the
missing 'T' was a real problem in this made-up example so far! Thanks
for pointing this out!

(...)

> Yes, the Pilog queries 'select' and its small brother 'db' are
> intended to return result _sets_, useful in GUI search components.
> For simple direct DB accesses Pilog is rather overkill. You typically
> use the Lisp function 'db' for that:
>
> : (db 'id '+Test "1") -> {2}
>
> The Pilog 'db' is actually a misnomer. It behaves more like the Lisp
> 'collect' function.

Ok, perhaps I could use the Lisp 'db' function when I have a direct
access :-) But anyway I will also need the Pilog 'db' clause. But I
would need it with a functionality like SQL

   select ID, SRC, TGT
     from +Test
   where ID = "1"'

an *not*

   select ID, SRC, TGT
      from +Test
    where ID like "1%"

is there any way to achieve my goal?

(...)

> True. Pilog is a powerful search mechanism, but you have to
> understand that for a simple indexed access the overhead of setting
> up the query and communicating environments from Lisp to Pilog and
> back is much larger than the actual db access.
>
> So it is not recommended, and was never intended, to use Pilog to
> retrieve a single value from the DB.

Ok! So perhaps I cannot use the DB for my purposes :-(

(...)

> Perhaps you should try with the corrected version (see above). Also,
> when using DB _plus_ Pilog, you get the overhead from both worlds.
> You could also try a DB version without Pilog. Is this possible?

I do not know for sure. I originally want to use Java + Prolog for my
application. Then I detected your picoLisp ...

(...)

> There are many ways to tune the performance. Perhaps you can
> elaborate a little more on the details?

Ok, here comes my story! Currently there is an application/tool written
in  C++, which is very hard to maintain. The task is, to read-in some
XML formatted description of a rail infrastructure. To let our main
application deal with the original rail infrastructure (points, tracks,
signals ...) a team has to take the original planning sketches and
describe them into XML. There are a lot of rules to obey to describe the
infrastructure properly. To help the team with that task, a check tool
was written, that read in said XML description and check them according
the rules of our projection handbook/guide.

My idea now is that I can write a new check tool that will have the
rules formulated in Pilog (formerly Prolog). All in all I would think,
that the resulting tool will be much more friendlier to maintain as the
said C++ one.

For that I need to formulate the edges of the tracknet somehow (for
instance) as Pilog facts like this:

   #  (Edge id fromNode toNode)
   (be edge ("ts1" "end#1" "points#1"))
   (be edge ("ts2" "points#1" "points#2"))
   (be edge ("ts3" "points#1" "points#2"))
   (be edge ("ts4" "points#2" "end#2"))

Would describe a graph like this (better look with a fixed size font):

                          ts2
                  ___________________
           ts1   /                   \   ts4
End#1  |<-------o Points#1   Points#2 o------->| End#2
                 \___________________/

                          ts3

Then I have a Pilog clause like this:

   (be walk (@Begin @Way)
     (edge @Begin @From @To)
     (walk @To (@Begin) @Way)
   )

   (be walk (@Node @Way @Way))

   (be walk (@FromNode @AuxWay @Way)
     (edge @Edge @FromNode @ToNode)
     (walk @ToNode (@Edge . @AuxWay) @Way)
   )

Which would allow me to iterate from a certain edge thru all reachable
edges until no other way can be found anymore. This clause would form a
base of my future rules I have to formulate.

I feel that Pilog (or Prolog) is perfect for that task. I only tried to
convert my Pilog facts above to a database to take advantage of indices
to find the necessary edges faster. But I really would like to use Pilog
to implement my checks. I would be more willing to dispense the database
than to abstain from Pilog ...

> Cheers, - Alex

Ciao,
cle.

-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to