Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9107729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:38:33+00:00 2026-06-17T02:38:33+00:00

I am parsing one file which has almost 1 billion(or may be trillion) records.

  • 0

I am parsing one file which has almost 1 billion(or may be trillion) records. I m using

 struct ltstr
 {
    bool operator()(const char* s1, const char* s2) const
    {
        return strcmp(s1, s2) < 0;
    }
 };

 multimap<char*, map<char*, char*, ltsr>,ltstr > m;

Is this efficient way to use above data structure in C++?

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:38:35+00:00Added an answer on June 17, 2026 at 2:38 am

    No, it’s not. Billions, let alone trillions of records won’t fit in operating memory of today’s computer. Remember, billion records will consume 32 GB for the overhead of the map alone, further 16 GB for the pointers to the keys and values and obviously n more GB where n is average length of keys and values for the actual data (assuming 64-bit system; in 32-bit system it’s only half, but it won’t fit in the 3 GB address space limit). There are only few large servers in the world that have such amount of memory.

    The only option for working with such huge amount of data is to process them in small batches. If the processing can be done on each element separately, just load one element at a time, process it and discard it. No matter what the size of the data, streaming processing is always faster, because it only requires fixed amount of memory and thus can efficiently take advantage of CPU caches.

    If it can’t be processed like that, because specific order is needed or you need to look up entries or something, you’ll need to prepare the data to appropriate external (on-disk) structure. I.e. sort them with external merge sort (writing the partitions to temporary files), index them with B-tree or hash or such. It’s a lot of work. But fortunately there are several libraries that implement these algorithms. I would suggest either:

    • A *DMB, external hashing library, like GDBM, Berkeley DB or ndbm. These provide just external analog of map, simplest, but the API is C-based.
    • The stxxl provides external variants of several external containers and algoritms that work on them. Big advantage is that the API is the same as standard library collections.
    • For more complex data operation, just go for sqlite. It’s just as fast and more complex data processing is simply easier to express in SQL.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing one file which has some html tag and changing into latex
I'm parsing a template using linux command line using pipes which has some 1-indexed
I am parsing an xml file. One of the method is below : public
I'm working in C#/.NET and I'm parsing a file to check if one line
I'm reading this introductory book on parsing (which is pretty good btw) and one
I am parsing an XML file where one of the fields I want to
I am parsing a flat file which is working line by line and inserting
My application has one service which runs until user pressed exit button. I know
I am parsing a JSON file which contains a timestamp. I want to convert
I am using an external DLL which has an abstract baseclass Packet and subclasses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.