Codebase list libjavaewah-java / 309715c
New upstream version 1.1.4 Emmanuel Bourg 3 years ago
6 changed file(s) with 97 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
0 version 1.1.4 (December 17th 2015)
1 - Fixed issue 60: bitmap shift then or
2
03 version 1.1.3 (December 3rd 2015)
1 - Fixed issue 59
4 - Fixed issue 59: ChunkIterator not iterating correctly
25
36 version 1.1.2 (November 11th 2015)
47 - Fixed issue 58: ChunkIterator not iterating correctly?
11 <modelVersion>4.0.0</modelVersion>
22 <groupId>com.googlecode.javaewah</groupId>
33 <artifactId>JavaEWAH</artifactId>
4 <version>1.1.3</version>
4 <version>1.1.4</version>
55 <packaging>bundle</packaging>
66 <properties>
77 <maven.compiler.source>1.6</maven.compiler.source>
20822082 }
20832083 }
20842084 } else {
2085 // whether the shift should justify a new word
2086 final boolean shiftextension = ((this.sizeInBits + WORD_IN_BITS - 1) % WORD_IN_BITS) + shift >= WORD_IN_BITS;
20852087 long w = 0;
20862088 while (true) {
20872089 long rl = i.getRunningLength();
21062108 w = neww >>> (WORD_IN_BITS - shift);
21072109 }
21082110 if (!i.next()) {
2109 answer.addWord(w);
2111 if(shiftextension) answer.addWord(w);
21102112 break;
21112113 }
21122114 }
20912091 int w = 0;
20922092 while (true) {
20932093 int rl = i.getRunningLength();
2094 // whether the shift should justify a new word
2095 final boolean shiftextension = ((this.sizeInBits + WORD_IN_BITS - 1) % WORD_IN_BITS) + shift >= WORD_IN_BITS;
20942096 if (rl > 0) {
20952097 if (i.getRunningBit()) {
20962098 int sw = w | (-1 << shift);
21122114 w = neww >>> (WORD_IN_BITS - shift);
21132115 }
21142116 if (!i.next()) {
2115 answer.addWord(w);
2117 if(shiftextension) answer.addWord(w);
21162118 break;
21172119 }
21182120 }
2020 */
2121 @SuppressWarnings("javadoc")
2222 public class EWAHCompressedBitmapTest {
23
23
24 @Test
25 public void shiftbug001() {
26 EWAHCompressedBitmap bm1 = EWAHCompressedBitmap.bitmapOf(10, 11, 12, 13);
27 EWAHCompressedBitmap bm2 = bm1.shift(1);
28
29 EWAHCompressedBitmap bm3 = bm1.or(bm2);
30 EWAHCompressedBitmap bm4 = EWAHCompressedBitmap.bitmapOf(10,11,12,13,14);
31 Assert.assertEquals(bm3, bm4);
32 }
33
34 @Test
35 public void shiftbug002() {
36 EWAHCompressedBitmap bm1 = EWAHCompressedBitmap.bitmapOf(10, 11, 12, 13, 63);
37 EWAHCompressedBitmap bm2 = bm1.shift(1);
38
39 EWAHCompressedBitmap bm3 = bm1.or(bm2);
40 EWAHCompressedBitmap bm4 = EWAHCompressedBitmap.bitmapOf(10,11,12,13,14, 63, 64);
41 Assert.assertEquals(bm3, bm4);
42 }
43
44 @Test
45 public void shiftbug003() {
46 EWAHCompressedBitmap bm1 = EWAHCompressedBitmap.bitmapOf(10, 11, 12, 13, 62);
47 EWAHCompressedBitmap bm2 = bm1.shift(1);
48
49 EWAHCompressedBitmap bm3 = bm1.or(bm2);
50 EWAHCompressedBitmap bm4 = EWAHCompressedBitmap.bitmapOf(10,11,12,13,14, 62, 63);
51 Assert.assertEquals(bm3, bm4);
52 }
53
54 @Test
55 public void shiftbug004() {
56 EWAHCompressedBitmap bm1 = EWAHCompressedBitmap.bitmapOf(10, 11, 12, 13, 64);
57 EWAHCompressedBitmap bm2 = bm1.shift(1);
58
59 EWAHCompressedBitmap bm3 = bm1.or(bm2);
60 EWAHCompressedBitmap bm4 = EWAHCompressedBitmap.bitmapOf(10,11,12,13,14, 64, 65);
61 Assert.assertEquals(bm3, bm4);
62 }
63
64
2465 @Test
2566 public void example() throws Exception {
2667 EWAHCompressedBitmap ewahBitmap1 = EWAHCompressedBitmap.bitmapOf(0, 2, 55, 64, 1 << 30);
2323 @SuppressWarnings("javadoc")
2424 public class EWAHCompressedBitmap32Test {
2525
26
27 @Test
28 public void shiftbug001() {
29 EWAHCompressedBitmap32 bm1 = EWAHCompressedBitmap32.bitmapOf(10, 11, 12, 13);
30 EWAHCompressedBitmap32 bm2 = bm1.shift(1);
31
32 EWAHCompressedBitmap32 bm3 = bm1.or(bm2);
33 EWAHCompressedBitmap32 bm4 = EWAHCompressedBitmap32.bitmapOf(10,11,12,13,14);
34 Assert.assertEquals(bm3, bm4);
35 }
36
37
38 @Test
39 public void shiftbug002() {
40 EWAHCompressedBitmap32 bm1 = EWAHCompressedBitmap32.bitmapOf(10, 11, 12, 13, 31);
41 EWAHCompressedBitmap32 bm2 = bm1.shift(1);
42
43 EWAHCompressedBitmap32 bm3 = bm1.or(bm2);
44 EWAHCompressedBitmap32 bm4 = EWAHCompressedBitmap32.bitmapOf(10,11,12,13,14, 31, 32);
45 Assert.assertEquals(bm3, bm4);
46 }
47
48
49 @Test
50 public void shiftbug003() {
51 EWAHCompressedBitmap32 bm1 = EWAHCompressedBitmap32.bitmapOf(10, 11, 12, 13, 30);
52 EWAHCompressedBitmap32 bm2 = bm1.shift(1);
53
54 EWAHCompressedBitmap32 bm3 = bm1.or(bm2);
55 EWAHCompressedBitmap32 bm4 = EWAHCompressedBitmap32.bitmapOf(10,11,12,13,14, 30, 31);
56 Assert.assertEquals(bm3, bm4);
57 }
58
59 @Test
60 public void shiftbug004() {
61 EWAHCompressedBitmap32 bm1 = EWAHCompressedBitmap32.bitmapOf(10, 11, 12, 13, 32);
62 EWAHCompressedBitmap32 bm2 = bm1.shift(1);
63
64 EWAHCompressedBitmap32 bm3 = bm1.or(bm2);
65 EWAHCompressedBitmap32 bm4 = EWAHCompressedBitmap32.bitmapOf(10,11,12,13,14, 32, 33);
66 Assert.assertEquals(bm3, bm4);
67 }
68
69
2670 @Test
2771 public void issue54() {
2872 EWAHCompressedBitmap32 bm = new EWAHCompressedBitmap32();