> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Brad Figler > Sent: Wednesday, August 20, 2003 9:19 AM > To: Palm Developer Forum > Subject: Re: Faking relational databases with PDBs > > > Jeff, > > I was using a method similar to yours, but I had the requirement of > populating a multi-column list (custom, of course) with data > from two different databases. The code was easy to write, > but searching for > unique ID's must do a linear search because there is no way > for the data > manager to know if the unique ID's are in any type of order.
Hey Brad. From what I gather, you can get much better efficienty than DmFindRecordByID() does when seeking out the record corresponding to a UID, and possibly this would prevent you from having to keep indices as you described in your message. This is one of the possible optimizations I noted in a previous response. Note: This is all information that you can get from reading http://www.palmos.com/dev/support/docs/palmos/FilesAndDatabases.html#998 472 -- but you really want to sign the Palm OS NDAs to get access to DataPrv.h and DataMgr.c, if you haven't already done so. The database header has a record list full of record entry structures. Note that this list may be fragmented across multiple local IDs, as indicated by the numRecords and nextRecordListID elements. Now each record entry contains the UID and attributes of the record to which it corresponds, and from what I've always assumed (though I've never seen this explicitly documented), the record entries are a parallel array to actual records. In other words, record entry #5173 contains the UID and attributes of the record at index 5173 (both are 0-based). So if you are looking for the record index corresponding to a particular UID, you can do better than a linear search of the record list with the information above. DmFindRecordByID() does a linear search. For example, you can do a binary search of the record list (accounting for its fragmentation across multiple LocalIDs, of course) for your UID. Once you've found it, you need to compute how far into the record list your search took you by doing some pointer math, and that will give you the index of the record corresponding to the UID in question. Of course, a binary search isn't always the best choice: for a small # of records, I would probably call through to DmFindRecordByID(), and for a larger # I would then enlist in the help of a binary search. Hope this helps! -Jeff Ishaq -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
