Conversation
| attr_reader :field, :reverse_byte, :size | ||
| include Enumerable | ||
|
|
||
| VERSION = "1.4.0" |
| include Enumerable | ||
|
|
||
| VERSION = "1.4.0" | ||
| HEADER_LENGTH = 8 + 1 # QC (@size, @reverse_byte) |
There was a problem hiding this comment.
We don't use this here, but need it for BitArrayFile.
|
|
||
| def ==(rhs) | ||
| @size == rhs.size && @reverse_byte == rhs.reverse_byte && @field == rhs.field | ||
| end |
There was a problem hiding this comment.
Added the ability to compare two BitArray objects. This makes it a bit easier to add tests.
| end | ||
|
|
||
| combined | ||
| end |
There was a problem hiding this comment.
I wrote this because it allows parallelising bloom filter creation. I don't personally need this method, but figured it might be useful for others.
| private def byte_position(position) | ||
| @reverse_byte ? position : 7 - position | ||
| end | ||
|
|
There was a problem hiding this comment.
The following two methods, dump and load, are new.
| private def seek_to(position) | ||
| @io.seek(position + HEADER_LENGTH) | ||
| end | ||
| end |
There was a problem hiding this comment.
It's actually fairly easy to implement the rest of BitArray, allowing this to be read/write instead of read-only. But it's quite a bit slower, at least for large bitarrays and nobody's likely to care for small bitarrays. Seemed to be unnecessary bloat.
| @@ -0,0 +1,65 @@ | |||
| require "minitest/autorun" | |||
There was a problem hiding this comment.
Note that I'm more familiar with rspec. Please excuse me if these tests aren't how most people would write Minitest tests.
There was a problem hiding this comment.
In a way, Minitest is to RSpec as Sinatra is to Rails. Minitest is far less opinionated and freeform which has upsides and downsides, but a big upside is pretty much any approach that works and fits into a project's own style is all good! :)
|
I've merged the previous one but this will take a little bit more review - thanks for now though! |
73f65aa to
9c070df
Compare
Rebased off of |
What
This PR allows
BitArrayto be dumped to disk and subsequently loaded from disk. It also adds the ability to union two bitarrays. And there's a new class,BitArrayFile, allowing for read-only access to a dumpedBitArray, providing a means to query the array without having to load it in to RAM.Tests
Additionally, I tested this with a bitarray consisting of a little over 2 billion bits. I was able to
dump,load, and useBitArrayFileto query the bits.