!1059 H-index: fix bitmap getMemoryUsage function

Merge pull request !1059 from peiwangdb/bitmap-fix
This commit is contained in:
i-robot 2021-08-16 23:14:20 +00:00 committed by Gitee
commit f8be020b2d
1 changed files with 5 additions and 3 deletions

View File

@ -107,6 +107,7 @@ public class BitmapIndex
private AtomicBoolean closed = new AtomicBoolean(false); private AtomicBoolean closed = new AtomicBoolean(false);
private AtomicBoolean updateAllowed = new AtomicBoolean(true); private AtomicBoolean updateAllowed = new AtomicBoolean(true);
private final Map<Object, RoaringBitmap> cache = new HashMap<>(); private final Map<Object, RoaringBitmap> cache = new HashMap<>();
private long memoryUsage;
@Override @Override
public Set<CreateIndexMetadata.Level> getSupportedIndexLevels() public Set<CreateIndexMetadata.Level> getSupportedIndexLevels()
@ -190,11 +191,12 @@ public class BitmapIndex
if (byteArray == null) { if (byteArray == null) {
return null; return null;
} }
byte[] value = (byte[]) byteArray; byte[] value = (byte[]) byteArray;
ByteBuffer bb = ByteBuffer.wrap(value); ByteBuffer bb = ByteBuffer.wrap(value);
ImmutableRoaringBitmap bm = new ImmutableRoaringBitmap(bb); ImmutableRoaringBitmap bm = new ImmutableRoaringBitmap(bb);
return new RoaringBitmap(bm); RoaringBitmap result = new RoaringBitmap(bm);
memoryUsage += result.getSizeInBytes();
return result;
}); });
} }
@ -342,7 +344,7 @@ public class BitmapIndex
@Override @Override
public long getMemoryUsage() public long getMemoryUsage()
{ {
return 0; return memoryUsage;
} }
@Override @Override