From 009ff687b2e696f7457c48793663f9dfef97a06f Mon Sep 17 00:00:00 2001 From: Bart Hanssens Date: Thu, 2 Apr 2020 21:02:35 +0200 Subject: [PATCH 1/5] GH-2061 mapdb upgrade Signed-off-by:Bart Hanssens --- .../evaluation/iterator/GroupIterator.java | 15 +++------------ pom.xml | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java index 9bb0d51dfdf..c34553f2288 100644 --- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java +++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java @@ -7,8 +7,6 @@ *******************************************************************************/ package org.eclipse.rdf4j.query.algebra.evaluation.iterator; -import java.io.File; -import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.HashSet; @@ -49,6 +47,7 @@ import org.eclipse.rdf4j.query.algebra.evaluation.util.MathUtil; import org.eclipse.rdf4j.query.algebra.evaluation.util.ValueComparator; import org.eclipse.rdf4j.query.impl.EmptyBindingSet; + import org.mapdb.DB; import org.mapdb.DBMaker; @@ -76,8 +75,6 @@ public class GroupIterator extends CloseableIteratorIteration 0) { - try { - this.tempFile = File.createTempFile("group-eval", null); - } catch (IOException e) { - throw new QueryEvaluationException("could not initialize temp db", e); - } - this.db = DBMaker.newFileDB(tempFile).deleteFilesAfterClose().closeOnJvmShutdown().make(); + this.db = DBMaker.tempFileDB().fileMmapEnableIfSupported().fileDeleteAfterClose().closeOnJvmShutdown().make(); } else { - this.tempFile = null; this.db = null; } } @@ -158,7 +149,7 @@ protected void handleClose() throws QueryEvaluationException { private Set createSet(String setName) { if (db != null) { - return db.getHashSet(setName); + return (Set ) db.hashSet(setName).create(); } else { return new HashSet<>(); } diff --git a/pom.xml b/pom.xml index ddbee47b31b..dc93aed594a 100644 --- a/pom.xml +++ b/pom.xml @@ -637,7 +637,7 @@ org.mapdb mapdb - 1.0.8 + 3.0.8 From 2f6758fbdb6802d96d72402c5ae97a215c1ad548 Mon Sep 17 00:00:00 2001 From: Bart Hanssens Date: Thu, 2 Apr 2020 21:51:53 +0200 Subject: [PATCH 2/5] GH-2061 code formatting Signed-off-by:Bart Hanssens --- .../query/algebra/evaluation/iterator/GroupIterator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java index c34553f2288..22762d7da45 100644 --- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java +++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java @@ -100,7 +100,11 @@ public GroupIterator(EvaluationStrategy strategy, Group group, BindingSet parent this.iterationCacheSyncThreshold = iterationCacheSyncThreshold; if (this.iterationCacheSyncThreshold > 0) { - this.db = DBMaker.tempFileDB().fileMmapEnableIfSupported().fileDeleteAfterClose().closeOnJvmShutdown().make(); + this.db = DBMaker.tempFileDB() + .fileMmapEnableIfSupported() + .fileDeleteAfterClose() + .closeOnJvmShutdown() + .make(); } else { this.db = null; } @@ -149,7 +153,7 @@ protected void handleClose() throws QueryEvaluationException { private Set createSet(String setName) { if (db != null) { - return (Set ) db.hashSet(setName).create(); + return (Set) db.hashSet(setName).create(); } else { return new HashSet<>(); } From f8588beca5e029a50a463ddf776cda4a423f1b68 Mon Sep 17 00:00:00 2001 From: Bart Hanssens Date: Fri, 3 Apr 2020 14:19:38 +0200 Subject: [PATCH 3/5] GH-2061 don't use mmap since it has issues (no releasing descriptors) Signed-off-by:Bart Hanssens --- .../rdf4j/query/algebra/evaluation/iterator/GroupIterator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java index 22762d7da45..83c80ef83aa 100644 --- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java +++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java @@ -101,7 +101,6 @@ public GroupIterator(EvaluationStrategy strategy, Group group, BindingSet parent if (this.iterationCacheSyncThreshold > 0) { this.db = DBMaker.tempFileDB() - .fileMmapEnableIfSupported() .fileDeleteAfterClose() .closeOnJvmShutdown() .make(); From 77b6e6000ee5e553215e27baf8de92e303951a5b Mon Sep 17 00:00:00 2001 From: Bart Hanssens Date: Wed, 15 Apr 2020 22:56:49 +0200 Subject: [PATCH 4/5] GH-2061 use filechannel and faster serialization Signed-off-by:Bart Hanssens --- .../query/algebra/evaluation/iterator/GroupIterator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java index 83c80ef83aa..bb3fb775393 100644 --- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java +++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java @@ -50,6 +50,7 @@ import org.mapdb.DB; import org.mapdb.DBMaker; +import org.mapdb.Serializer; /** * @author David Huynh @@ -102,6 +103,7 @@ public GroupIterator(EvaluationStrategy strategy, Group group, BindingSet parent if (this.iterationCacheSyncThreshold > 0) { this.db = DBMaker.tempFileDB() .fileDeleteAfterClose() + .fileChannelEnable() .closeOnJvmShutdown() .make(); } else { @@ -152,7 +154,7 @@ protected void handleClose() throws QueryEvaluationException { private Set createSet(String setName) { if (db != null) { - return (Set) db.hashSet(setName).create(); + return (Set) db.hashSet(setName).serializer(Serializer.JAVA).create(); } else { return new HashSet<>(); } From 981b5ccc0e39d0fd9ea2a3027682d23e8b51ecaf Mon Sep 17 00:00:00 2001 From: Jeen Broekstra Date: Fri, 16 Apr 2021 10:21:07 +1000 Subject: [PATCH 5/5] GH-2061 formatting fixed --- .../rdf4j/query/algebra/evaluation/iterator/GroupIterator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java index bb3fb775393..943dde243fd 100644 --- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java +++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/GroupIterator.java @@ -47,7 +47,6 @@ import org.eclipse.rdf4j.query.algebra.evaluation.util.MathUtil; import org.eclipse.rdf4j.query.algebra.evaluation.util.ValueComparator; import org.eclipse.rdf4j.query.impl.EmptyBindingSet; - import org.mapdb.DB; import org.mapdb.DBMaker; import org.mapdb.Serializer;