What happened to this site? And what's that frog about?

Multiple Hash Maps

F141 - Failure Feedback Forum 

Status: Severity: enhance Category: Metakit OOMK Created: 2007-02-11 Updated: 2007-02-11

I have a Tcl metakit that tracks file names along with other meta information for each file. The File property contains the file name which is the first entry in the metakit row. I have a hash map view on the File property to allow me to access the file name with a find operation, and this is very fast. I would also like to add a Key field for each row that allows me to give each filename a unique key.

Is there a way (alternate views...) this Key can also be mapped via a hash or some very fast method to find and retrieve the corresponding file row without rolling my own memory based lookup? Find operations on the Key are slow since it isn't hashed.

[email protected]



2007-02-11 Tom Wilkason

Imported

2007-02-11 jcw

You could create a second view with "Key" as key, and "rownum" as second property, and then hash that view on Key. This does mean you need to manage the second view manually, i.e. keep it in sync as you add new rows to the original view.

Deletion is more work, because then rownum's change and have to all be adjusted in that new Key view. There is a trick to simplify that, if the order of rows in the view is not important: instead of moving all rows down after a deletion, copy the last row over the deleted slot, and delete the last row instead. Then only one row needs to be adjusted in the key view.

It all sounds a bit manual, and in a way it is, but the result is very much the same as what a more extended database does when using extra lookup indexes.

Add a comment:

Tip: add empty lines between paragraphs and indent lines to prevent reformatting.

Your name or initials:  

Powered by Mavrig