roaringbitmap / swiftroaring Goto Github PK
View Code? Open in Web Editor NEWA better compressed bitset in Swift http://roaringbitmap.org/
License: BSD 3-Clause "New" or "Revised" License
A better compressed bitset in Swift http://roaringbitmap.org/
License: BSD 3-Clause "New" or "Revised" License
Hello, did you consider adding support for base64 encoding to roaring? I imagine that fastbase64 would do the trick.
This is probably more of a croaring issue that SwiftRoaring but we discussed base64 encoding here.
Hello, I am trying to serialise a bloom filter generated in a roaring bitmap format to a base64 string, so that I can save it in MongoDB. But the function portableSerialize
is a bit tricky for me.
I am so far just testing how it works and I generate a random bloom filter values that I later try to convert to buffer -> to data -> to base64:
func generateBloomFilterData(){
let bitmap = RoaringBitmap()
for i in 0..<50 {
let random = arc4random_uniform(2)
if random == 0 {
bitmap.add(UInt32(i))
}
}
let count = (Int(bitmap.count) * MemoryLayout<Int8>.size)
var buffer = [Int8](repeating: 0, count: count)
_ = bitmap.portableSerialize(buffer: &buffer)
let uintBuffer = buffer.map { UInt8(bitPattern: $0) }
let bufferData = Data(uintBuffer)
let base64String = bufferData()
print("buffer size: \(buffer.count), \(uintBuffer.count), base64: \(bufferData.base64EncodedString())")
//-> send base64 string to database
}
This generates an error:
malloc: MallocStackLogging: attempting to release an index out of
bounds
The console shows:
buffer size: 20, 20, base64: OjAAAAEAAAAAABMAEAAAAAMABQA=
Is there a way how to simply generate a base64 string out of the above generated RoaringBitmap() ?
I'm confused by the intended semantics of max. In the following example, we have two sets, one which contains a zero and one which is empty. However max returns 0 in both cases. How can I distinguish these cases? Am I supposed to be checking if the set is empty?
func testFirst() {
// empty
let a: RoaringBitmap = []
print("empty")
for e in a {
print(e)
}
print("a max", a.max())
// empty
print("has 0")
let b: RoaringBitmap = [0]
for e in b {
print(e)
}
print("b max", b.max())
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.