Skip to content

Commit

Permalink
update JLargeArrays to 1.7-SNAPSHOT and fix #167 https://gitlab.com/v…
Browse files Browse the repository at this point in the history
  • Loading branch information
ate47 committed Sep 28, 2022
1 parent fd72e30 commit 9d69a25
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
10 changes: 8 additions & 2 deletions hdt-java-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
<artifactId>jena-arq</artifactId>
</dependency>
<dependency>
<groupId>pl.edu.icm</groupId>
<groupId>org.visnow</groupId>
<artifactId>JLargeArrays</artifactId>
<version>1.7-20220624.150242-7</version>
</dependency>
<dependency>
<groupId>pl.pragmatists</groupId>
Expand All @@ -63,7 +64,12 @@
<version>1.6</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/projects/375779/packages/maven</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
import org.rdfhdt.hdt.util.crc.CRCInputStream;
import org.rdfhdt.hdt.util.crc.CRCOutputStream;
import org.rdfhdt.hdt.util.io.IOUtil;

import pl.edu.icm.jlargearrays.LongLargeArray;
import pl.edu.icm.jlargearrays.LargeArrayUtils;
import org.visnow.jlargearrays.LargeArrayUtils;
import org.visnow.jlargearrays.LongLargeArray;

/**
* @author mario.arias,Lyudmila Balakireva
Expand All @@ -55,8 +54,8 @@
public class SequenceLog64Big implements DynamicSequence {
private static final byte W = 64;
private static final int INDEX = 1073741824;
LongLargeArray data;

LongLargeArray data;
private int numbits;
private long numentries=0;
private long maxvalue;
Expand All @@ -77,7 +76,7 @@ public SequenceLog64Big(int numbits, long capacity) {
long size = numWordsFor(numbits, capacity);
LongLargeArray.setMaxSizeOf32bitArray(SequenceLog64Big.INDEX);

data = new LongLargeArray(Math.max((int)size,1));
data = new LongLargeArray(Math.max(size,1));
}

public SequenceLog64Big(int numbits, long capacity, boolean initialize) {
Expand Down Expand Up @@ -158,11 +157,7 @@ private void resizeArray(long size) {
//data = Arrays.copyOf(data, size);
if(size > 0) {
LongLargeArray a = new LongLargeArray(size);
if (size < data.length()) {
LargeArrayUtils.arraycopy(data, 0, a, 0, size);
} else {
LargeArrayUtils.arraycopy(data, 0, a, 0, data.length());
}
LargeArrayUtils.arraycopy(data, 0, a, 0, Math.min(size, data.length()));
data = a;
}else{
this.numentries = 0;
Expand All @@ -182,7 +177,7 @@ public void add(Iterator<Long> elements) {
// Count and calculate number of bits needed per element.
while(elements.hasNext()) {
long val = elements.next();
max = val>max ? val : max;
max = Math.max(val, max);
numentries++;
}

Expand All @@ -208,7 +203,7 @@ public void addIntegers(ArrayList<Integer> elements) {
// Count and calculate number of bits needed per element.
for (int i=0;i<elements.size();i++){
long val = elements.get(i).longValue();
max = val>max ? val : max;
max = Math.max(val, max);
numentries++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
import org.rdfhdt.hdt.listener.ProgressListener;
import org.rdfhdt.hdt.util.string.ByteStringUtil;
import pl.edu.icm.jlargearrays.LargeArrayUtils;
import org.visnow.jlargearrays.LargeArrayUtils;

import java.io.*;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.rdfhdt.hdt.compact.sequence;

import org.junit.Test;
import org.visnow.jlargearrays.LargeArray;
import org.visnow.jlargearrays.LongLargeArray;

public class LargeArrayTest {

@Test
public void allocationTest() {
int old = LargeArray.getMaxSizeOf32bitArray();
try {
LargeArray.setMaxSizeOf32bitArray(100);
long size = LargeArray.getMaxSizeOf32bitArray() + 2L;
new LongLargeArray(size);
} finally {
LargeArray.setMaxSizeOf32bitArray(old);
}
}
}

0 comments on commit 9d69a25

Please sign in to comment.