Creating a dictionary with BDB -
09-25-2006
, 01:04 PM
Hi all!
The "problem" is the following: I've to create a dictionary of some
values stored in a file. It means read the file line by line and assign
a progressive number to each different seen value. When the value is
assigned I've to use it for other things, so I need to know the
assigned number.
I've used the BDB. The values read from the value are the keys of the
eventually new records, the corresponding data is the assigned number.
If I read an already seen line I have already a recod with that key,
and so the corresponding number. Else I insert a new record with the
read line as key and the actual value of a counter as data. In the
latter case I'll know the assigned value while in the former case I
will have to perform a new search over the DB (get method) to get the
already assigned value.
It would be nice if the putNoOverwrite method would returns the
corresponding value in case of an already present key avoiding the
second search. If this is possible, I'll use the search performed by
the putNoOverwrite method optimizing the task.
Is there a way to do this?
I guess that this will improve the performance of my loop (I've to
build the dictionary over millions of value).
Thanks! |