Rewritable lookups using an in-process database
The tHash
components are great for storing intermediate data in memory and are very efficient, but do not allow updates. Database tables allow updates, but aren't as efficient when writing and reading data on a row-by-row basis, especially when there are large numbers of rows to be processed.
This recipe shows how we can get the best of both worlds using a feature of the HSQL database that allows us to define databases that only reside in memory for the given process.
Due to this job being fairly complex, there are a few techniques used that can be found in other chapters of the book, but aren't explained in detail in this chapter. In addition, it will aid understanding if we provide a background for this scenario.
Background
In this recipe we are presented with a list of customers with their countries of residence. We wish to cross-reference their residence country with our list of countries held in our MySQL database and:
if the country is found...