bloom-filter-scala icon indicating copy to clipboard operation
bloom-filter-scala copied to clipboard

Fix bitCount is 0 after intersect or union

Open SidWeng opened this issue 7 years ago • 6 comments
trafficstars

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

SidWeng avatar Aug 29 '18 06:08 SidWeng

@alexandrnikitin I cannot figure out why "java.lang.NoClassDefFoundError: sbt/inc/Analysis" happens, any advice?

SidWeng avatar Sep 04 '18 04:09 SidWeng

@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 avatar Sep 13 '18 08:09 alexandrnikitin

@alexandrnikitin Could you post the JVM crash log or reproduce step?

SidWeng avatar Sep 14 '18 02:09 SidWeng

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

alexandrnikitin avatar Sep 14 '18 06:09 alexandrnikitin

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

SidWeng avatar Sep 20 '18 03:09 SidWeng

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?

SidWeng avatar Nov 16 '18 09:11 SidWeng