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

  • Home
  • SEARCH
  • 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 8510073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:36:22+00:00 2026-06-11T03:36:22+00:00

I am working on a project that deals with reading and processing huge .txt

  • 0

I am working on a project that deals with reading and processing huge .txt files containing various data for certain individuals.

Multiple files are to be read and sorted by the individual ID (which is present in all files) and then merged, in terms of retrieving all the entries from all the files that are assigned to the same ID. In other words, each individual can have multiple entries (i.e., lines) in every file. I need to retrieve all info that I find regarding one ID, store it and then pass to the next one.

Until now I’ve tried FileChannel, FileInputStream and MappedFileBuffer, but apparently the best suited for my case is FileInputStream with a BufferedReader and to compare them I saw that Collection.sort() is recommended. An important issue is that I am not aware of the performance of the PCs that are going to make use of the application and the files can be bigger than 2GB. Any help would be appreciated.

  • 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-11T03:36:24+00:00Added an answer on June 11, 2026 at 3:36 am

    If you expect to be processing more data than the target environment can fit into memory then you will either have to use some form of on-disk streaming or reparse the file multiple times.

    The decision as to which option to pursue depends on the distribution of data.

    If there are relatively few lines per id (ie lots of distinct ids) then reparsing will be the slowest assuming you need the collated results for all ids.

    If there are relatively few ids (ie lots of lines) then reparsing may become more efficient.

    My guess is that reparsing for each id will be inefficient in the general case (but if you know there are maybe <10 distinct ids then I would consider a reparse based solution)

    The idea then is that you parse the file just once putting the results into a kind of map of lists…

    Map<Id,List<Record>>
    

    The problem you face is that you don’t have enough memory to hold such a map…

    So you will need to create an intermediary temporary on disk store to hold the lists for each id.

    You have two options for the on disk store:

    1. Roll your own

    2. Use a database (eg derby or hsqldb or …)

    Option 1 is more work but you can optimise for your use case (namely writing by append only, and then at the end read all the records back in and sort them)

    Option 2 will be easier and quicker to implement at the risk of performance as the database will be maintaining an index on the ids in case you want to randomly read the data while parsing (which you don’t in this use case)…

    If I had to choose I would start with option 2 and only introduce the maintenance headache on myself that option 1 will be if performance is sub-optimal. (avoid premature optimisation)

    You will need to use a buffered reader (with a really large (64k) buffer to avoid trashing the disk with competing read/write operations (disk is what will kill performance)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Flash project that deals with multiple files. There is a
I am currently working on a project that deals with a vector of objects
I am working on a research project that deals with social networks. I have
I'm working on a project that uses NetBeans to generate the ANT build files.
I am working on a project that deals with a few tasks running in
I'm working on a project that deals with cars. I need to know if
I am working on a project that deals with migration of Oracle db to
I am working on a PHP project that deals with storing a set of
I'm working in tiny project that deal with multiple file uploading. at the begining
I am working on a project that deals with analyzing a very large amount

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.