bloom-filter-scala
bloom-filter-scala copied to clipboard
Fix bitCount is 0 after intersect or union
use the fact that after i & (i - 1), the right most of set bit of "i" will be unset ref: https://www.quora.com/How-do-you-count-the-number-of-1-bits-in-a-number-using-only-bitwise-operations
@alexandrnikitin I cannot figure out why "java.lang.NoClassDefFoundError: sbt/inc/Analysis" happens, any advice?
@SidWeng I've created a PR #41 with code that uses java.lang.Long.bitCount() instead. But it crashes JVM for some reason I don't quite understand 😞 Also don't know about Scala 2.12 NoClassDefFoundError issue.
@alexandrnikitin Could you post the JVM crash log or reproduce step?
Sure, I posted logs to this gist. To reproduce I run sbt "project tests" "testOnly *UnsafeBitArraysSpec" on #41. Surprisingly it's green on travis-ci
I try to reproduce it and looks like something wrong with unsafe.getLong() in UnsafeBitArray.set() but still cannot find out the root cause(I guess the index is too big and cause the offset is beyond the allocated memory). Here's my reproduce log
I add some debug log in UnsafeBitArray.scala then run sbt "project tests" "testOnly *UnsafeBitArraysSpec"
following is the debug log just before crash(unsafe.getLong(offset) in UnsafeBitArray.set()):
numberOfBits: 2147483647
indices: 33554432
ptr: 4805672960
end: 5074108416
index: 4294967294
offset: 5342543864
looks like the memory is not big enough or the index is too big @alexandrnikitin any advice for fixing this error? what should we do if the index is too big, just throw an exception?