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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:03:34+00:00 2026-06-12T01:03:34+00:00

I need a library which would help me to save and query data in

  • 0

I need a library which would help me to save and query data in a condensed format (a mini DSL in essence) here’s a sample of what I want:

Update 1 – Please note, figures in the samples above are made small just to make is easier to follow the logic, the real figures are limited with c# long type capacity, ex:
1,18,28,29,39,18456789,18456790,18456792,184567896.

Sample Raw Data set: 1,2,3,8,11,12,13,14

Condensed Sample Data set:
1..3,8,11..14

What would be absolute nice to have is to be able to present 1,2,4,5,6,7,8,9,10 as 1..10-3.

Querying Sample Data set:

Query 1 (get range):
1..5 -> 1..3

Query 2 (check if the value exists)
?2 -> true

Query 3 (get multiple ranges and scalar values):
1..5,11..12,14 -> 1..3,11..12,14

I don’t want to develop it from scratch and would highly prefer to use something which already exists.

  • 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-12T01:03:36+00:00Added an answer on June 12, 2026 at 1:03 am

    Here are some ideas I’ve had over the days since I read your question. I can’t be sure any of them really apply to your use case but I hope you’ll find something useful here.

    Storing your data compressed

    Steps you can take to reduce the amount of space your numbers take up on disk:

    • If your values are between 1 and ~10M, don’t use a long, use a uint. (4 bytes per number.)
    • Actually, don’t use a uint. Store your numbers 7 bits to a byte, with the remaining bit used to say “there are more bytes in this number”. (Then 1-127 will fit in 1 byte, 128-~16k in 2 bytes, ~16k-~2M in 3 bytes, ~2M-~270M in 4 bytes.)

    This should reduce your storage from 8 bytes per number (if you were originally storing them as longs) to, say, on average 3 bytes. Also, if you end up needing bigger numbers, the variable-byte storage will be able to hold them.

    Then I can think of a couple of ways to reduce it further, given you know the numbers are always increasing and may contain lots of runs. Which works best for you only you can know by trying it on your actual data.

    • For each of your actual numbers, store two numbers: the number itself, followed by the number of numbers contiguous after it (e.g. 2,3,4,5,6 => 2,4). You’ll have to store lone numbers as e.g. 8,0 so will increase storage for those, but if your data has lots of runs (especially long ones) this should reduce storage on average. You could further store “single gaps” in runs as e.g. 1,2,3,5,6,7 => 1,6,4 (unambiguous as 4 is too small to be the start of the next run) but this will make processing more complex and won’t save much space so I wouldn’t bother.
    • Or, rather than storing the numbers themselves, store the deltas (so 3,4,5,7,8,9 => 3,1,1,2,1,1. This will reduce the number of bytes used for storing larger numbers (e.g. 15000,15005 (4 bytes) => 15000,5 (3 bytes)). Further, if the data contains a lot of runs (e.g. lots of 1 bytes), it will then compress (e.g. zip) nicely.

    Handling in code

    I’d simply advise you to write a couple of methods that stream a file from disk into an IEnumerable<uint> (or ulong if you end up with bigger numbers), and do the reverse, while handling whatever you’ve implemented from the above.

    If you do this in a lazy fashion – using yield return to return the numbers as you read them from disk and calculate them, and streaming numbers to disk rather than holding them in memory and returning them at once, you can keep your memory usage down whatever the size of the stored data.

    (I think, but I’m not sure, that even the GZipStream and other compression streams will let you stream your data without having it all in memory.)

    Querying

    If you’re comparing two of your big data sets, I wouldn’t advise using LINQ’s Intersect method as it requires reading one of the sources completely into memory. However, as you know both sequences are increasing, you can write a similar method that needs only hold an enumerator for each sequence.

    If you’re querying one of your data sets against a user-input, small list of numbers, you can happily use LINQ’s Intersect method as it is currently implemented, as it only needs the second sequence to be entirely in memory.

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

Sidebar

Related Questions

I need some library which would be able to keep my urls Indexed and
I need a code example or library which would parse Accept-Language header and return
I need OCR library(preferably in Java), which will be able to determine digit visualized
I need suggestion about YAMI library . I have a system which receives Json
I'm developing a library to IOS, which at some point need to create a
I have a problem I would like some help at. I need to create
All, Need some help here. I am from a purely Java background and don't
I need a library to handle JSON objects in Ruby. There are two gems
I need a library to read 2D barcode (datamatrix) from images on C# project
I need a Java library to convert PDFs to TIFF images. The PDFs are

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.