Skip to content

Commit

Permalink
Move checks for bitmap size == 0 to isEmpty (apache#4820)
Browse files Browse the repository at this point in the history
  • Loading branch information
drcrallen authored and nishantmonu51 committed Sep 19, 2017
1 parent edd9c76 commit 00d39ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public Object2IntRBTreeMap<SearchHit> execute(int limit)
if (timeFilteredBitmap != null) {
bitmap = bitmapFactory.intersection(Arrays.asList(timeFilteredBitmap, bitmap));
}
if (bitmap.size() > 0) {
if (!bitmap.isEmpty()) {
retVal.addTo(new SearchHit(dimension.getOutputName(), dimVal), bitmap.size());
if (retVal.size() >= limit) {
return retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public int compare(
ImmutableBitmap set, ImmutableBitmap set1
)
{
if (set.size() == 0 && set1.size() == 0) {
if (set.isEmpty() && set1.isEmpty()) {
return 0;
}
if (set.size() == 0) {
if (set.isEmpty()) {
return -1;
}
if (set1.size() == 0) {
if (set1.isEmpty()) {
return 1;
}
return set.compareTo(set1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ public BitmapFactory getBitmapFactory()
return bitmapFactory;
}

private static Ordering<WrappedImmutableConciseBitmap> conciseComparator = new Ordering<WrappedImmutableConciseBitmap>()
private static final Ordering<WrappedImmutableConciseBitmap> CONCISE_COMPARATOR = new Ordering<WrappedImmutableConciseBitmap>()
{
@Override
public int compare(
WrappedImmutableConciseBitmap conciseSet, WrappedImmutableConciseBitmap conciseSet1
)
{
if (conciseSet.size() == 0 && conciseSet1.size() == 0) {
if (conciseSet.isEmpty() && conciseSet1.isEmpty()) {
return 0;
}
if (conciseSet.size() == 0) {
if (conciseSet.isEmpty()) {
return -1;
}
if (conciseSet1.size() == 0) {
if (conciseSet1.isEmpty()) {
return 1;
}
return conciseSet.compareTo(conciseSet1);
Expand All @@ -87,7 +87,7 @@ public WrappedImmutableConciseBitmap fromByteBuffer(ByteBuffer buffer, int numBy
@Override
public byte[] toBytes(ImmutableBitmap val)
{
if (val == null || val.size() == 0) {
if (val == null || val.isEmpty()) {
return new byte[]{};
}
return val.toBytes();
Expand All @@ -96,7 +96,7 @@ public byte[] toBytes(ImmutableBitmap val)
@Override
public int compare(ImmutableBitmap o1, ImmutableBitmap o2)
{
return conciseComparator.compare((WrappedImmutableConciseBitmap) o1, (WrappedImmutableConciseBitmap) o2);
return CONCISE_COMPARATOR.compare((WrappedImmutableConciseBitmap) o1, (WrappedImmutableConciseBitmap) o2);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ public BitmapFactory getBitmapFactory()
return bitmapFactory;
}

private static Ordering<WrappedImmutableRoaringBitmap> roaringComparator = new Ordering<WrappedImmutableRoaringBitmap>()
private static final Ordering<WrappedImmutableRoaringBitmap> RORING_COMPARATOR = new Ordering<WrappedImmutableRoaringBitmap>()
{
@Override
public int compare(
WrappedImmutableRoaringBitmap set1, WrappedImmutableRoaringBitmap set2
)
{
if (set1.size() == 0 && set2.size() == 0) {
if (set1.isEmpty() && set2.isEmpty()) {
return 0;
}
if (set1.size() == 0) {
if (set1.isEmpty()) {
return -1;
}
if (set2.size() == 0) {
if (set2.isEmpty()) {
return 1;
}

Expand Down Expand Up @@ -118,7 +118,7 @@ public byte[] toBytes(ImmutableBitmap val)
@Override
public int compare(ImmutableBitmap o1, ImmutableBitmap o2)
{
return roaringComparator.compare((WrappedImmutableRoaringBitmap) o1, (WrappedImmutableRoaringBitmap) o2);
return RORING_COMPARATOR.compare((WrappedImmutableRoaringBitmap) o1, (WrappedImmutableRoaringBitmap) o2);
}
}

Expand Down

0 comments on commit 00d39ce

Please sign in to comment.