{"action":"created","issue":{"url":"https://api.github.com/repos/lemire/javaewah/issues/56","labels_url":"https://api.github.com/repos/lemire/javaewah/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/lemire/javaewah/issues/56/comments","events_url":"https://api.github.com/repos/lemire/javaewah/issues/56/events","html_url":"https://github.com/lemire/javaewah/issues/56","id":102698344,"number":56,"title":"EWAHCompressedBitmap.set is slow when more than 1 million elements are inserted","user":{"login":"sxpujs","id":1668699,"avatar_url":"https://avatars.githubusercontent.com/u/1668699?v=3","gravatar_id":"","url":"https://api.github.com/users/sxpujs","html_url":"https://github.com/sxpujs","followers_url":"https://api.github.com/users/sxpujs/followers","following_url":"https://api.github.com/users/sxpujs/following{/other_user}","gists_url":"https://api.github.com/users/sxpujs/gists{/gist_id}","starred_url":"https://api.github.com/users/sxpujs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sxpujs/subscriptions","organizations_url":"https://api.github.com/users/sxpujs/orgs","repos_url":"https://api.github.com/users/sxpujs/repos","events_url":"https://api.github.com/users/sxpujs/events{/privacy}","received_events_url":"https://api.github.com/users/sxpujs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-24T03:56:53Z","updated_at":"2015-08-24T07:31:18Z","closed_at":null,"body":"Is there a quick method to add a lot of elements to EWAHCompressedBitmap? for example:\r\n\r\n    EWAHCompressedBitmap bitmap = new EWAHCompressedBitmap();\r\n    Random ran = new Random();\r\n    for (int index = 0; index < 1_000_000; index++) {\r\n      bitmap.set(ran.nextInt(5_000_000));\r\n    }\r\n    System.out.println(\"complete!\");"},"comment":{"url":"https://api.github.com/repos/lemire/javaewah/issues/comments/134072253","html_url":"https://github.com/lemire/javaewah/issues/56#issuecomment-134072253","issue_url":"https://api.github.com/repos/lemire/javaewah/issues/56","id":134072253,"user":{"login":"lemire","id":391987,"avatar_url":"https://avatars.githubusercontent.com/u/391987?v=3","gravatar_id":"","url":"https://api.github.com/users/lemire","html_url":"https://github.com/lemire","followers_url":"https://api.github.com/users/lemire/followers","following_url":"https://api.github.com/users/lemire/following{/other_user}","gists_url":"https://api.github.com/users/lemire/gists{/gist_id}","starred_url":"https://api.github.com/users/lemire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lemire/subscriptions","organizations_url":"https://api.github.com/users/lemire/orgs","repos_url":"https://api.github.com/users/lemire/repos","events_url":"https://api.github.com/users/lemire/events{/privacy}","received_events_url":"https://api.github.com/users/lemire/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T07:31:18Z","updated_at":"2015-08-24T07:31:18Z","body":"Here is what the documentation states:\r\n\r\nThough you can set the bits in any order (e.g., set(100), set(10), set(1), you will typically get better performance if you set the bits in increasing order (e.g., set(1), set(10), set(100)). Setting a bit that is larger than any of the current set bit is a constant time operation. Setting a bit that is smaller than an already set bit can require time proportional to the compressed size of the bitmap, as the bitmap may need to be rewritten. \r\n\r\nReference:\r\n\r\nhttp://lemire.me/docs/javaewah/com/googlecode/javaewah/EWAHCompressedBitmap.html#set-int-\r\n\r\nHave you tried setting the bits in order, as recommended?\r\n\r\nOtherwise, if you must use random order, have you considered competitive alternatives like Roaring?\r\n\r\nhttps://github.com/lemire/RoaringBitmap/\r\n\r\n"}}