Skip to content
Snippets Groups Projects
Commit 62097dd5 authored by Emmanuel Bourg's avatar Emmanuel Bourg
Browse files

New upstream version 1.0.1

parent 511cc96a
No related branches found
No related tags found
No related merge requests found
version 1.0.1 (March 23rd 2015)
- Fixed: Some bug about EWAHCompressedBitmap.reverseIntIterator() (#53)
version 1.0.0 (January 6th 2015)
- Both EWAHCompressedBitmap and BitSet can now support memory-file mapping. For best performance, we recommend the very latest OpenJDK.
......
No preview for this file type
......@@ -185,7 +185,7 @@ You can also specify the dependency in the Maven "pom.xml" file:
<dependency>
<groupId>com.googlecode.javaewah</groupId>
<artifactId>JavaEWAH</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>
......
......@@ -3,7 +3,7 @@
<groupId>com.googlecode.javaewah</groupId>
<artifactId>JavaEWAH</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>bundle</packaging>
<properties>
......
......@@ -32,8 +32,7 @@ final class ReverseIntIterator implements IntIterator {
this.ewahIter = ewahIter;
this.sizeInBits = sizeInBits;
this.buffer = ewahIter.buffer();
this.position = sizeInBits;
this.runningLength = Integer.MAX_VALUE;
this.runningLength = sizeInBits - 1;
this.hasNext = this.moveToPreviousRLW();
}
......@@ -69,26 +68,33 @@ final class ReverseIntIterator implements IntIterator {
private void setRLW(RunningLengthWord rlw) {
this.wordLength = rlw.getNumberOfLiteralWords();
this.wordPosition = this.ewahIter.position();
this.runningLength = this.position - WORD_IN_BITS * (int) (rlw.getRunningLength() + this.wordLength);
this.position = this.runningLength;
this.runningLength -= WORD_IN_BITS * (rlw.getRunningLength() + this.wordLength);
if (this.position == this.sizeInBits - 1) {
final int usedBitsInLast = this.sizeInBits % WORD_IN_BITS;
if(usedBitsInLast > 0) {
this.runningLength += WORD_IN_BITS - usedBitsInLast;
}
}
this.runningBit = rlw.getRunningBit();
this.position--;
}
private boolean runningHasNext() {
return this.runningBit && this.runningLength <= this.position;
return this.runningBit && this.runningLength < this.position;
}
private boolean literalHasNext() {
while (this.word == 0 && this.wordLength > 0) {
this.word = Long.reverse(this.buffer.getWord(this.wordPosition + this.wordLength--));
int usedBits = WORD_IN_BITS;
if (this.position == this.sizeInBits - 1) {
final int usedBitsInLast = this.sizeInBits % WORD_IN_BITS;
if (usedBitsInLast > 0) {
this.word = (this.word >>> (WORD_IN_BITS - usedBitsInLast));
usedBits = this.sizeInBits % WORD_IN_BITS;
if (usedBits > 0) {
this.word = (this.word >>> (WORD_IN_BITS - usedBits));
}
}
this.literalPosition = this.position;
this.position -= WORD_IN_BITS;
this.position -= usedBits;
}
return this.word != 0;
}
......
......@@ -34,8 +34,7 @@ final class ReverseIntIterator32 implements IntIterator {
this.ewahIter = ewahIter;
this.sizeInBits = sizeInBits;
this.buffer = ewahIter.buffer();
this.position = sizeInBits;
this.runningLength = Integer.MAX_VALUE;
this.runningLength = sizeInBits - 1;
this.hasNext = this.moveToPreviousRLW();
}
......@@ -71,26 +70,33 @@ final class ReverseIntIterator32 implements IntIterator {
private void setRLW(RunningLengthWord32 rlw) {
this.wordLength = rlw.getNumberOfLiteralWords();
this.wordPosition = this.ewahIter.position();
this.runningLength = this.position - WORD_IN_BITS * (rlw.getRunningLength() + this.wordLength);
this.position = this.runningLength;
this.runningLength -= WORD_IN_BITS * (rlw.getRunningLength() + this.wordLength);
if (this.position == this.sizeInBits - 1) {
final int usedBitsInLast = this.sizeInBits % WORD_IN_BITS;
if(usedBitsInLast > 0) {
this.runningLength += WORD_IN_BITS - usedBitsInLast;
}
}
this.runningBit = rlw.getRunningBit();
this.position--;
}
private boolean runningHasNext() {
return this.runningBit && this.runningLength <= this.position;
return this.runningBit && this.runningLength < this.position;
}
private boolean literalHasNext() {
while (this.word == 0 && this.wordLength > 0) {
this.word = Integer.reverse(this.buffer.getWord(this.wordPosition + this.wordLength--));
int usedBits = WORD_IN_BITS;
if (this.position == this.sizeInBits - 1) {
final int usedBitsInLast = this.sizeInBits % WORD_IN_BITS;
if (usedBitsInLast > 0) {
this.word = (this.word >>> (WORD_IN_BITS - usedBitsInLast));
usedBits = this.sizeInBits % WORD_IN_BITS;
if (usedBits > 0) {
this.word = (this.word >>> (WORD_IN_BITS - usedBits));
}
}
this.literalPosition = this.position;
this.position -= WORD_IN_BITS;
this.position -= usedBits;
}
return this.word != 0;
}
......
......@@ -767,6 +767,19 @@ public class EWAHCompressedBitmapTest {
Assert.assertFalse(iterator.hasNext());
}
@Test
public void reverseIntIteratorOverMultipleRLWs() {
EWAHCompressedBitmap b = EWAHCompressedBitmap.bitmapOf(1000, 100000, 100000 + WORD_IN_BITS);
IntIterator iterator = b.reverseIntIterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(100000 + WORD_IN_BITS, iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(100000, iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(1000, iterator.next());
Assert.assertFalse(iterator.hasNext());
}
@Test
public void isEmpty() {
EWAHCompressedBitmap bitmap = EWAHCompressedBitmap.bitmapOf();
......
......@@ -681,6 +681,19 @@ public class EWAHCompressedBitmap32Test {
}
Assert.assertFalse(iterator.hasNext());
}
@Test
public void reverseIntIteratorOverMultipleRLWs() {
EWAHCompressedBitmap32 b = EWAHCompressedBitmap32.bitmapOf(1000, 100000, 100000 + WORD_IN_BITS);
IntIterator iterator = b.reverseIntIterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(100000 + WORD_IN_BITS, iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(100000, iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(1000, iterator.next());
Assert.assertFalse(iterator.hasNext());
}
@Test
public void isEmpty() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment