Help with file comparison



 DEVELOP > c-Plus-Plus > Help with file comparison

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "chris"
Date: 22 Nov 2003 12:34:14 PM
Object: Help with file comparison
Does anyone have any tips for comparing large amounts of data?
The data in question is around 1000 lines of up to 400 delimited key value
pairs. Each line has a unique identifier stored in one of the fields. Each
field needs to be compared to the corresponding line/field in a "master file".
In addition, each field has formatting rules, such as trimming spaces and
zeroes, ignore capitalization, etc., which are stored in a database. I have
done similar things in Java using a HashMap of HashMaps approach, but the
performance was awful.
Would using the STL hash_map in C++ result in the same performace problems?
Would it be better to read the file into memory with mmap() or fopen/fread
and work with individually malloc'ed pieces of data, using memcmp() to
compare, and just store the pointers in an array or map? Also, any hints
for divided up all those pairs? Is strtok() my best bet?
Thanks for any help or feedback.
--
-chris
*address above may be munged
.

User: "Chris \ Val "

Title: Re: Help with file comparison 22 Nov 2003 08:58:01 PM
"chris" <muley@spamfree.midsouth.rr.com> wrote in message
news:G_Nvb.31012$oC5.29668@clmboh1-nws5.columbus.rr.com...
| Does anyone have any tips for comparing large amounts of data?
|
| The data in question is around 1000 lines of up to 400 delimited key value
| pairs. Each line has a unique identifier stored in one of the fields. Each
| field needs to be compared to the corresponding line/field in a "master file".
| In addition, each field has formatting rules, such as trimming spaces and
| zeroes, ignore capitalization, etc., which are stored in a database. I have
| done similar things in Java using a HashMap of HashMaps approach, but the
| performance was awful.
|
| Would using the STL hash_map in C++ result in the same performace problems?
| Would it be better to read the file into memory with mmap() or fopen/fread
| and work with individually malloc'ed pieces of data, using memcmp() to
| compare, and just store the pointers in an array or map? Also, any hints
| for divided up all those pairs? Is strtok() my best bet?
- Read the key-values pairs into 'std::map<>' accossiative container(s).
- Write a simple trim function
- Write a simple function to ignore case
Once you have done that, you're almost finished :-).
Note howerver, that 'C++' knows nothing of databses.
Cheers.
Chris Val
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER