From 9d69a2540d7ecda32d1dd2f9ae215ce174f9ca97 Mon Sep 17 00:00:00 2001 From: qaate47 Date: Wed, 27 Jul 2022 11:27:36 +0200 Subject: [PATCH] update JLargeArrays to 1.7-SNAPSHOT and fix #167 https://gitlab.com/visnow.org/JLargeArrays/-/packages --- hdt-java-core/pom.xml | 10 +++++++-- .../compact/sequence/SequenceLog64Big.java | 21 +++++++------------ .../java/org/rdfhdt/hdt/util/io/IOUtil.java | 2 +- .../hdt/compact/sequence/LargeArrayTest.java | 20 ++++++++++++++++++ 4 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 hdt-java-core/src/test/java/org/rdfhdt/hdt/compact/sequence/LargeArrayTest.java diff --git a/hdt-java-core/pom.xml b/hdt-java-core/pom.xml index 195a0de9..e457fead 100644 --- a/hdt-java-core/pom.xml +++ b/hdt-java-core/pom.xml @@ -49,8 +49,9 @@ jena-arq - pl.edu.icm + org.visnow JLargeArrays + 1.7-20220624.150242-7 pl.pragmatists @@ -63,7 +64,12 @@ 1.6 - + + + gitlab-maven + https://gitlab.com/api/v4/projects/375779/packages/maven + + diff --git a/hdt-java-core/src/main/java/org/rdfhdt/hdt/compact/sequence/SequenceLog64Big.java b/hdt-java-core/src/main/java/org/rdfhdt/hdt/compact/sequence/SequenceLog64Big.java index 3121ea54..db536827 100644 --- a/hdt-java-core/src/main/java/org/rdfhdt/hdt/compact/sequence/SequenceLog64Big.java +++ b/hdt-java-core/src/main/java/org/rdfhdt/hdt/compact/sequence/SequenceLog64Big.java @@ -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 @@ -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; @@ -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) { @@ -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; @@ -182,7 +177,7 @@ public void add(Iterator 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++; } @@ -208,7 +203,7 @@ public void addIntegers(ArrayList elements) { // Count and calculate number of bits needed per element. for (int i=0;imax ? val : max; + max = Math.max(val, max); numentries++; } diff --git a/hdt-java-core/src/main/java/org/rdfhdt/hdt/util/io/IOUtil.java b/hdt-java-core/src/main/java/org/rdfhdt/hdt/util/io/IOUtil.java index f4275796..bbd84658 100644 --- a/hdt-java-core/src/main/java/org/rdfhdt/hdt/util/io/IOUtil.java +++ b/hdt-java-core/src/main/java/org/rdfhdt/hdt/util/io/IOUtil.java @@ -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; diff --git a/hdt-java-core/src/test/java/org/rdfhdt/hdt/compact/sequence/LargeArrayTest.java b/hdt-java-core/src/test/java/org/rdfhdt/hdt/compact/sequence/LargeArrayTest.java new file mode 100644 index 00000000..4eeaee88 --- /dev/null +++ b/hdt-java-core/src/test/java/org/rdfhdt/hdt/compact/sequence/LargeArrayTest.java @@ -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); + } + } +}