-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
141 changed files
with
7,750 additions
and
1,201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...e/src/main/java/com/the_qa_company/qendpoint/core/compact/bitmap/MappedRoaringBitmap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package com.the_qa_company.qendpoint.core.compact.bitmap; | ||
|
||
import com.the_qa_company.qendpoint.core.hdt.HDTVocabulary; | ||
import com.the_qa_company.qendpoint.core.listener.ProgressListener; | ||
import com.the_qa_company.qendpoint.core.util.io.CloseMappedByteBuffer; | ||
import com.the_qa_company.qendpoint.core.util.io.IOUtil; | ||
import org.roaringbitmap.buffer.ImmutableRoaringBitmap; | ||
|
||
import java.io.Closeable; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* Mapped {@link Bitmap} wrapper for the {@link ImmutableRoaringBitmap}, not | ||
* compatible with {@link RoaringBitmap64} | ||
* | ||
* @author Antoine Willerval | ||
*/ | ||
public class MappedRoaringBitmap implements SimpleBitmap, Closeable { | ||
private final CloseMappedByteBuffer buffer; | ||
private final ImmutableRoaringBitmap rbm; | ||
|
||
public MappedRoaringBitmap(CloseMappedByteBuffer buffer) { | ||
this.buffer = buffer; | ||
this.rbm = new ImmutableRoaringBitmap(buffer.getInternalBuffer()); | ||
} | ||
|
||
public ImmutableRoaringBitmap getHandle() { | ||
return rbm; | ||
} | ||
|
||
@Override | ||
public boolean access(long position) { | ||
return rbm.contains((int) position); | ||
} | ||
|
||
@Override | ||
public long getNumBits() { | ||
return rbm.last(); | ||
} | ||
|
||
@Override | ||
public long getSizeBytes() { | ||
return rbm.serializedSizeInBytes() + 8; | ||
} | ||
|
||
@Override | ||
public void save(OutputStream output, ProgressListener listener) throws IOException { | ||
long size = rbm.serializedSizeInBytes(); | ||
IOUtil.writeLong(output, size); | ||
rbm.serialize(new DataOutputStream(output)); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return HDTVocabulary.BITMAP_TYPE_ROARING; | ||
} | ||
|
||
@Override | ||
public long select1(long n) { | ||
long position = n - 1; | ||
if (position == -1) | ||
return -1; | ||
if (position < rbm.getLongCardinality()) { | ||
return rbm.select((int) position); | ||
} else { | ||
return rbm.select((int) rbm.getLongCardinality() - 1) + 1; | ||
} | ||
} | ||
|
||
@Override | ||
public long rank1(long position) { | ||
if (position >= 0) | ||
return rbm.rankLong((int) position); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long countOnes() { | ||
return rbm.getLongCardinality(); | ||
} | ||
|
||
@Override | ||
public long selectPrev1(long start) { | ||
return select1(rank1(start)); | ||
} | ||
|
||
@Override | ||
public long selectNext1(long start) { | ||
long pos = rank1(start - 1); | ||
if (pos < rbm.getLongCardinality()) | ||
return select1(pos + 1); | ||
return -1; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
buffer.close(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ain/java/com/the_qa_company/qendpoint/core/compact/bitmap/ModifiableMultiLayerBitmap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.the_qa_company.qendpoint.core.compact.bitmap; | ||
|
||
public interface ModifiableMultiLayerBitmap extends MultiLayerBitmap { | ||
/** | ||
* Set the value of the bit at position pos | ||
* | ||
* @param layer layer | ||
* @param position pos | ||
* @param value value | ||
*/ | ||
void set(long layer, long position, boolean value); | ||
} |
Oops, something went wrong.