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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:29:19+00:00 2026-05-13T07:29:19+00:00

I have a hash table that I want to store to disk. The list

  • 0

I have a hash table that I want to store to disk. The list looks like this:

<16-byte key                   > <1-byte result>
a7b4903def8764941bac7485d97e4f76 04
b859de04f2f2ff76496879bda875aecf 03
etc...

There are 1-5 million entries. Currently I’m just storing them in one file, 17-bytes per entry times the number of entries. That file is tens of megabytes. My goal is to store them in a way that optimizes first for space on the disk and then for lookup time. Insertion time is unimportant.

What is the best way to do this? I’d like the file to be as small as possible. Multiple files would be okay, too. Patricia trie? Radix trie?

Whatever good suggestions I get, I’ll be implementing and testing. I’ll post the results here for all to see.

  • 1 1 Answer
  • 2 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-13T07:29:19+00:00Added an answer on May 13, 2026 at 7:29 am

    You could just sort entries by key and do a binary search.

    Fixed size keys and data entries means you can very quickly jump from row to row, and storing only the key and data means you’re not wasting any space on meta data.

    I don’t think you’ll do any better on disk space, and lookup times are O(log(n)). Insertion times are crazy long, but you said that didn’t matter.

    If you’re really willing to tolerate long access times, do sort the table but then chunk it into blocks of some size and compress them. Store the offset* and start/end keys of each block in a section of the file at the start. Using this scheme, you can find the block containing the key you need in linear time and then perform a binary search within the decompressed block. Choose the block sized based on how much of the file you’re willing to loading into memory at once.

    Using an off the shelf compression scheme (like GZIP) you can tune the compression ratio as needed; larger files will presumably have quicker lookup times.

    I have doubts that the space savings will be all that great, as your structure seems to be mostly hashes. If they are actually hashes, they’re random and won’t compress terribly well. Sorting will help increase the compression ratio, but not by a ton.

    *Use the header to lookup the offset of a block to decompress and use.

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

Sidebar

Related Questions

I have three Hash Table like that, HashTable ht1 = { (1, 100), (2,
I have a hash table that contains values of a^j. j is the key
I have a table which looks a bit like this: <table> <thead> <tr> <th></th>
I have a list of string values that I want add to a hashtable
Lets say that I have only DHT (distributed hash table) implemented (in Python), and
What I can think of is: Algo: Have a hash table which will store
I have a list of n strings (names of people) that I want to
I have a table in SQL Server like this : Users : int ID
Greetings, I have some mysql tables that are currently using an md5 hash as
I have one key but different values for that key. I tried HashTable but

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.