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 6067989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:40:04+00:00 2026-05-23T09:40:04+00:00

I have a case where in I need to read a flat file with

  • 0

I have a case where in I need to read a flat file with close to 100000 logical records. Each logical record is comprised of nx128 character parts. ie, Type A: 3×128, Type B : 4-5 X 128 etc where maximum possible n is 6.

Application has to read the file and process the records. The problem is ‘n’ can be determined only when we read the first 52 characters of each nx128 partition.

Could you please suggest any design paterns which I can re-use or any efficient algorithms to perform this ?

Note : 1. Performance is an important criteria as application need to process thousands of file like this everyday. 2. The data is not separated by lines. Its a long string like pattern

  • 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-05-23T09:40:04+00:00Added an answer on May 23, 2026 at 9:40 am

    You could adopt a master-worker (or master-slave) pattern where in a master thread would be responsible for reading the first 52 characters of data to determine the length of the record. The master may then defer the actual work of reading and processing the records to a worker thread, and move on to the next record again to read only the first 52 characters. Each worker would be responsible for (re)opening the file and processing a particular range of characters; the worker needs to be provided with this information.

    Since, I haven’t seen the structure of the file, I can only post a few possible limitations or concerns for an implementer to think about:

    • An effective and performant implementation would rely on the ability to provide a worker thread with file pointers and the length of the data that the worker should deal with. In simpler words, the worker thread is expected to actually read the file in a random-access mode, instead of having the master do the reading (which is serial). If you cannot perform random-access, there isn’t a lot you can do to optimize the master-worker pattern.
    • Spawning of new worker threads is not recommended. Use a thread pool. This would also mean that you can limit the number of open file descriptors based on the size of the pool.
    • Queue up further requests to process the character ranges in case the pool is exhausted. That way, the master can continue doing its work until the last record has been read.
    • Dependencies across records will require you to serialize processing the records. If each record can be processed on it’s own thread, without requiring results from other threads to be made available, then you should not encounter any difficult in adopting this approach.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a flat CSV file which I need read from to end up
I have a case where I need geographically distributed read models. They are supposed
I have a file whatever_files_123456.ext . I need to read just the number after
I have this file which I need to read the first bytes to check
Have a use case wherein need to maintain a connection open to a database
I have a case where I need to translate (lookup) several values from the
I have a case where I need to serve raw swf files to the
I have a case where I need to select a random item, but I
I have a case where I need to load bitmap from a resource dll
I have a case where I need to update a jqgrid based on some

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.