1. FWIW, DBF indexing in Euphoria
Dear List,
I'm still lurking around out here. It's cold and lonely but I don't have time to
get heavily involved in the discussions. Here's a few notes scribbled down over
the weekend re the DBMS problem (a problem which I for one would like very much
to see solved!)
Implement a pseudoISAM.
function INDEX( sequence fileName, integer indexRoutine )
-- steps through the database passing {field_name, value} to
-- the indexRoutine (identified by routine_id()).
-- returns a sequence of {indexKey, recordNumber}
-- assumes a lot about the DBF routines. Haven't used them for ages.
-- e.g.
-- function CustomerById( sequence field_value )
-- function AddressByID( sequence field_value )
-- etc.
-- Customers = INDEX( "CUSTOMER.DBF", routine_id( "CustomerByID" ) )
-- Addresses = INDEX( "ADDRESS.DBF", routine_id( "AddressByID" ) )
function RELATE( sequence idxSeq1, sequence idxSeq2 )
-- receives the output from two INDEX() calls.
-- returns a sequence of
-- { indexKey, recno_of_first_index, { recnos_of_second_index } }
-- based on the match in index keys.
then ...
sequence relation
relation = RELATE( Customers, Addresses )
for i = 1 to length( relation ) do
ID = relation[ 1 ]
CustomerRecNo = relation[ 2 ]
MatchingAddresses = relation[ 3 ]
...
...
As it stands, the index is sequential. Possibly one could reimplement the
index as a hash or a tree (deriving from Junko's stuff in the demo folder).
Saving the indexes should be fairly simple as one doesn't need to be able
to read them with the eyes so storing them to disk as an Euphoria sequence
should work.
Problems:
-- keeping indexes updated
-- keeping relations updated
XBase apps do a lot of this stuff behind the scenes but I suppose if
we write enough wrappers then we end up with something similar.
Other thoughts:
-- INDEXSEQ( sequence dataBlock, ... )
-- does the same as INDEX except on an entirely inhaled database.
That's it.
Zaph.