Page 1 of 1

Constructing a Hash Table

Posted: Fri Oct 05, 2007 11:18 pm
by legend986
I have two columns in my table. Both of them contains strings whose maximum length can be 16 characters. The number of records are close to a million. I need to make some comparisons between the two columns. To do this, I'm thinking of constructing a Hash Table. How would I do it? Never worked with hashes before, so can someone please guide me?

Posted: Sat Oct 06, 2007 8:46 am
by feyd
What kind of comparisons? If they're basic, like matching, there's no need for hashing.

Posted: Sat Oct 06, 2007 8:49 am
by VladSun
Internals and Portability

Written in C and C++.
Uses GNU Automake (1.4), Autoconf (Version 2.52 or newer), and Libtool for portability.
Works on many different platforms; APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl.
Fully multi-threaded using kernel threads, this means it can easily use multiple CPUs if available.
Very fast B-tree disk tables with index compression and thread-based memory allocation system.
Very fast joins using an optimised one-sweep multi-join, can mix tables from different databases in the same query.
In-memory hash tables which are used as temporary tables.
SQL functions are implemented through a highly optimised class library and should be as fast as possible!
Usually there isn't any memory allocation at all after query initialisation.

Re: Constructing a Hash Table

Posted: Mon Oct 08, 2007 9:34 am
by ev0l
legend986 wrote:I have two columns in my table. Both of them contains strings whose maximum length can be 16 characters. The number of records are close to a million. I need to make some comparisons between the two columns. To do this, I'm thinking of constructing a Hash Table. How would I do it? Never worked with hashes before, so can someone please guide me?
I don't see why you think you need a hash table. You are using a database let the database do the indexing for you.

Hash tables are great at in-memory retrieval. PHP arrays are implemented as hash tables (basically) so in fact you have worked with hashes. If you are interested in learning more on hash tables the [http://en.wikipedia.org/wiki/Hash_tables]article[/url] on Wikipedia is pretty good.

If your data is small enough to fit in memory you might benefit from a MySQL heap table (assuming you are using MySQL) but I would suggest against it in most cases.

Please submit more details on the problem you are having and maybe we could be of more help.