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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:29:18+00:00 2026-06-12T00:29:18+00:00

I have a problem to solve involving reading large files, and I have a

  • 0

I have a problem to solve involving reading large files, and I have a general idea how to approach it, but would like to see it there might be a better way.

The problem is following: I have several huge disk files (64GB each) filled with records of 2.5KB each (around 25,000,000 of records total). Each record has, among other fields, a timestamp, and a isValid flag indicating whether the timestamp is valid or not. When the user enters a timespan, I need to return all records for which the timestamp is withing the specified range.

The layout of the data is such that, for all records marked as “Valid”, timestamp monotonically increases. Invalid records should not be considered at all. So, this is how the file generally looks like (although ranges are far larger):

a[0]  = { Time=11, IsValid = true };
a[1]  = { Time=12, IsValid = true };
a[2]  = { Time=13, IsValid = true };
a[3]  = { Time=401, IsValid = false }; // <-- should be ignored
a[4]  = { Time=570, IsValid = false }; // <-- should be ignored
a[5]  = { Time=16, IsValid = true }; 

a[6]  = { Time=23, IsValid = true };  // <-- time-to-index offset changed 
a[7]  = { Time=24, IsValid = true };
a[8]  = { Time=25, IsValid = true };
a[9]  = { Time=26, IsValid = true };

a[10] = { Time=40, IsValid = true };  // <-- time-to-index offset changed 
a[11] = { Time=41, IsValid = true };
a[12] = { Time=700, IsValid = false };  // <-- should be ignored 
a[13] = { Time=43, IsValid = true };

If the offset between a timestamp and a counter was constant, seeking the first record would be an O(1) operation (I would simply jump to the index). Since it isn’t, I am looking for a different way to (quickly) find this information.

One way might be a modified binary search, but I am not completely sure how to handle larger blocks of invalid records. I suppose I could also create an “index” to speed up lookup, but since there will be many large files like this, and extracted data size will be much smaller than the entire file, I don’t want to traverse each of these files, record by record, to generate the index. I am thinking if a binary search would also help while building the index.

Not to mention that I’m not sure what would be the best structure for the index. Balanced binary tree?

  • 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-12T00:29:19+00:00Added an answer on June 12, 2026 at 12:29 am

    You can use modified binary search. The idea is to do usual binary search to figure out lower bound and upper bound and then return the in between entries which are valid.

    The modification lies in the part where if current entry is invalid. In that case you have to figure out two end points where you have a valid entry.
    e.g if mid point is 3,

    a[0]  = { Time=11, IsValid = true };
    a[1]  = { Time=12, IsValid = true };
    a[2]  = { Time=401, IsValid = false };
    a[3]  = { Time=570, IsValid = false }; // <-- Mid point.
    a[4]  = { Time=571, IsValid = false };
    a[5]  = { Time=16, IsValid = true }; 
    a[6]  = { Time=23, IsValid = true };
    

    In above case the algorithm will return two points a[1] and a[5]. Now algo will decide to binary search lower half or upper half.

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

Sidebar

Related Questions

I have a problem to solve. I research some day but i cant solve
XML is cool in flex, but I have an annoying problem to solve, caused
i have a problem that i can't solve ! (sqlite3, but i think it
I do have following problem to solve: I have a simple but big gridmap
I have a problem I'm trying to solve involving interfaceing a C++ program with
I have been trying to solve a problem involving thread communication using wait() and
I'm trying to solve an algorithm problem involving chess. Suppose I have a king
I have a conceptually simple problem involving Google Analytics and Tomcat, but I cannot
I have problem to solve. there is vt100 telnet connected device which i have
I have a problem to solve, There is a simple supermarket program where all

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.