Skip to content

Commit 579e46f

Browse files
authored
Replace BitVector by BitSet and remove legacy library (#258)
* Replace BitVector by BitSet and remove legacy library * Performance optimisation with bitset operations * Update README * Add some defensive checks when elements are removed
1 parent 911d0a5 commit 579e46f

File tree

8 files changed

+1110
-155
lines changed

8 files changed

+1110
-155
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ compile 'org.gephi:graphstore:0.8.0'
5353

5454
## Dependencies
5555

56-
GraphStore is built for JRE 17+ and depends on FastUtil and Colt.
56+
GraphStore is built for JRE 17+ and depends on FastUtil.
5757

5858
For a complete list of dependencies, consult the `pom.xml` file.
5959

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@
6767
<artifactId>fastutil</artifactId>
6868
<version>8.5.16</version>
6969
</dependency>
70-
<dependency>
71-
<groupId>colt</groupId>
72-
<artifactId>colt</artifactId>
73-
<version>1.2.0</version>
74-
</dependency>
7570
</dependencies>
7671

7772
<build>

src/main/java/org/gephi/graph/impl/ColumnObserverImpl.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
*/
1616
package org.gephi.graph.impl;
1717

18-
import cern.colt.bitvector.BitVector;
19-
import cern.colt.bitvector.QuickBitVector;
18+
import java.util.BitSet;
2019
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
2120
import it.unimi.dsi.fastutil.objects.ObjectList;
2221
import it.unimi.dsi.fastutil.objects.ObjectLists;
@@ -40,7 +39,7 @@ public class ColumnObserverImpl implements ColumnObserver {
4039
protected boolean destroyed;
4140
// Config
4241
protected final boolean withDiff;
43-
protected BitVector bitVector;
42+
protected BitSet bitVector;
4443
// Cache
4544
protected ColumnDiffImpl columnDiff;
4645

@@ -109,7 +108,7 @@ private void refreshDiff() {
109108
boolean node = AttributeUtils.isNodeColumn(column);
110109
columnDiff = node ? new NodeColumnDiffImpl() : new EdgeColumnDiffImpl();
111110

112-
int size = bitVector.size();
111+
int size = bitVector.length();
113112

114113
for (int i = 0; i < size; i++) {
115114
boolean t = bitVector.get(i);
@@ -179,19 +178,11 @@ public EdgeIterable getTouchedElements() {
179178
private void ensureVectorSize(ElementImpl element) {
180179
int sid = element.getStoreId();
181180
if (bitVector == null) {
182-
bitVector = new BitVector(sid + 1);
183-
} else if (sid >= bitVector.size()) {
184-
int newSize = Math.min(Math
181+
int initialSize = Math.min(Math
185182
.max(sid + 1, (int) (sid * GraphStoreConfiguration.COLUMNDIFF_GROWING_FACTOR)), Integer.MAX_VALUE);
186-
bitVector = growBitVector(bitVector, newSize);
183+
bitVector = new BitSet(initialSize);
187184
}
188-
}
189-
190-
private BitVector growBitVector(BitVector bitVector, int size) {
191-
long[] elements = bitVector.elements();
192-
long[] newElements = QuickBitVector.makeBitVector(size, 1);
193-
System.arraycopy(elements, 0, newElements, 0, elements.length);
194-
return new BitVector(newElements, size);
185+
// BitSet grows automatically when setting bits, no need to manually grow
195186
}
196187

197188
private void readLock() {

0 commit comments

Comments
 (0)