You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/01/09 01:18:43 UTC
[GitHub] clintropolis closed pull request #6764: Consider using
RoaringBitmapWriter for bitmap construction
clintropolis closed pull request #6764: Consider using RoaringBitmapWriter for bitmap construction
URL: https://github.com/apache/incubator-druid/pull/6764
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pom.xml b/pom.xml
index d9c1387e50f..928fd58eba8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -681,7 +681,7 @@
<dependency>
<groupId>org.roaringbitmap</groupId>
<artifactId>RoaringBitmap</artifactId>
- <version>0.7.30</version>
+ <version>0.7.36</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
@@ -982,7 +982,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
- <version>1.15</version>
+ <version>1.17</version>
<executions>
<execution>
<id>check-java-api</id>
diff --git a/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedRoaringBitmap.java b/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedRoaringBitmap.java
index bf20138c718..8690af38bb8 100644
--- a/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedRoaringBitmap.java
+++ b/processing/src/main/java/org/apache/druid/collections/bitmap/WrappedRoaringBitmap.java
@@ -22,6 +22,7 @@
import com.google.common.base.Throwables;
import org.roaringbitmap.IntIterator;
import org.roaringbitmap.RoaringBitmap;
+import org.roaringbitmap.RoaringBitmapWriter;
import org.roaringbitmap.buffer.MutableRoaringBitmap;
import java.io.ByteArrayOutputStream;
@@ -39,7 +40,7 @@
/**
* Underlying bitmap.
*/
- private MutableRoaringBitmap bitmap;
+ private RoaringBitmapWriter<MutableRoaringBitmap> writer;
/**
* Creates a new WrappedRoaringBitmap wrapping an empty MutableRoaringBitmap
@@ -56,17 +57,17 @@ public WrappedRoaringBitmap()
*/
public WrappedRoaringBitmap(boolean compressRunOnSerialization)
{
- this.bitmap = new MutableRoaringBitmap();
+ this.writer = RoaringBitmapWriter.bufferWriter().get();
this.compressRunOnSerialization = compressRunOnSerialization;
}
ImmutableBitmap toImmutableBitmap()
{
- MutableRoaringBitmap mrb = bitmap.clone();
+ MutableRoaringBitmap bitmap = writer.get().clone();
if (compressRunOnSerialization) {
- mrb.runOptimize();
+ bitmap.runOptimize();
}
- return new WrappedImmutableRoaringBitmap(mrb);
+ return new WrappedImmutableRoaringBitmap(bitmap.toImmutableRoaringBitmap());
}
@Override
@@ -74,6 +75,7 @@ ImmutableBitmap toImmutableBitmap()
{
try {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ MutableRoaringBitmap bitmap = writer.get();
if (compressRunOnSerialization) {
bitmap.runOptimize();
}
@@ -88,21 +90,22 @@ ImmutableBitmap toImmutableBitmap()
@Override
public void clear()
{
- this.bitmap.clear();
+ this.writer.reset();
}
@Override
public void or(MutableBitmap mutableBitmap)
{
WrappedRoaringBitmap other = (WrappedRoaringBitmap) mutableBitmap;
- MutableRoaringBitmap unwrappedOtherBitmap = other.bitmap;
- bitmap.or(unwrappedOtherBitmap);
+ MutableRoaringBitmap unwrappedOtherBitmap = other.writer.get();
+ writer.get().or(unwrappedOtherBitmap);
}
@Override
public int getSizeInBytes()
{
+ MutableRoaringBitmap bitmap = writer.get();
if (compressRunOnSerialization) {
bitmap.runOptimize();
}
@@ -112,21 +115,22 @@ public int getSizeInBytes()
@Override
public void add(int entry)
{
- bitmap.add(entry);
+ writer.add(entry);
}
@Override
public int size()
{
- return bitmap.getCardinality();
+ return writer.get().getCardinality();
}
public void serialize(ByteBuffer buffer)
{
- if (compressRunOnSerialization) {
- bitmap.runOptimize();
- }
try {
+ MutableRoaringBitmap bitmap = writer.get();
+ if (compressRunOnSerialization) {
+ bitmap.runOptimize();
+ }
bitmap.serialize(
new DataOutputStream(
new OutputStream()
@@ -180,38 +184,38 @@ public void write(byte[] b, int off, int l)
@Override
public String toString()
{
- return getClass().getSimpleName() + bitmap;
+ return getClass().getSimpleName() + writer.getUnderlying();
}
@Override
public void remove(int entry)
{
- bitmap.remove(entry);
+ writer.get().remove(entry);
}
@Override
public IntIterator iterator()
{
- return bitmap.getIntIterator();
+ return writer.get().getIntIterator();
}
@Override
public boolean isEmpty()
{
- return bitmap.isEmpty();
+ return writer.get().isEmpty();
}
@Override
public ImmutableBitmap intersection(ImmutableBitmap otherBitmap)
{
WrappedRoaringBitmap other = (WrappedRoaringBitmap) otherBitmap;
- MutableRoaringBitmap unwrappedOtherBitmap = other.bitmap;
- return new WrappedImmutableRoaringBitmap(MutableRoaringBitmap.and(bitmap, unwrappedOtherBitmap));
+ MutableRoaringBitmap unwrappedOtherBitmap = other.writer.get();
+ return new WrappedImmutableRoaringBitmap(MutableRoaringBitmap.and(writer.get(), unwrappedOtherBitmap));
}
@Override
public boolean get(int value)
{
- return bitmap.contains(value);
+ return writer.get().contains(value);
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org