Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jena-benchmarks/jena-benchmarks-jmh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.jena</groupId>
<artifactId>jena-benchmarks</artifactId>
<version>6.1.0</version>
<version>6.2.0-SNAPSHOT</version>
</parent>

<name>Apache Jena - Benchmarks JMH</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static ChainedOptionsBuilder getDefaults(Class<?> c) {
.mode(Mode.AverageTime)
.timeUnit(TimeUnit.SECONDS)
.warmupTime(TimeValue.NONE)
.warmupIterations(5)
.measurementIterations(15)
.warmupIterations(4)
.measurementIterations(8)
.measurementTime(TimeValue.NONE)
.threads(1)
.forks(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ public class TestGraphAdd {

@Param({
"GraphMemFast (current)",
"GraphMemValue (current)",
// "GraphMemValue (current)",
"GraphMemIndexedSet EAGER (current)",
// "GraphMemIndexedSet LAZY (current)",
// "GraphMemIndexedSet LAZY_PARALLEL (current)",
// "GraphMemIndexedSet MINIMAL (current)",
// "GraphMemRoaring EAGER (current)",
// "GraphMemRoaring LAZY (current)",
// "GraphMemRoaring LAZY_PARALLEL (current)",
// "GraphMemRoaring MINIMAL (current)",
// "GraphMemValue (Jena 5.6.0)",
"GraphMemFast (Jena 5.6.0)",
"GraphMemValue (Jena 5.6.0)",
// "GraphMemFast (Jena 5.6.0)",
// "GraphMemValue (Jena 5.6.0)",
})
public String param1_GraphImplementation;
java.util.function.Supplier<Object> graphAdd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class TestGraphCopy {

@Param({
"GraphMemFast (current)",
"GraphMemIndexedSet EAGER (current)",
// "GraphMemIndexedSet LAZY (current)",
// "GraphMemIndexedSet LAZY_PARALLEL (current)",
// "GraphMemIndexedSet MINIMAL (current)",
// "GraphMemRoaring EAGER (current)",
// "GraphMemRoaring LAZY (current)",
// "GraphMemRoaring LAZY_PARALLEL (current)",
Expand All @@ -55,7 +59,7 @@ public class TestGraphCopy {

@Param({
"copy",
"findAndAddAll",
// "findAndAddAll",
})
public String param2_CopyOrConstruct;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ public Context(String graphImplementation) {
this.graphClass = GraphClass.GraphMemLegacy;
this.jenaVersion = JenaVersion.CURRENT;
break;
case "GraphMemIndexedSet (current)":
case "GraphMemIndexedSet EAGER (current)":
this.graphClass = GraphClass.GraphMemIndexedSetEager;
this.jenaVersion = JenaVersion.CURRENT;
break;
case "GraphMemIndexedSet LAZY (current)":
this.graphClass = GraphClass.GraphMemIndexedSetLazy;
this.jenaVersion = JenaVersion.CURRENT;
break;
case "GraphMemIndexedSet LAZY_PARALLEL (current)":
this.graphClass = GraphClass.GraphMemIndexedSetLazyParallel;
this.jenaVersion = JenaVersion.CURRENT;
break;
case "GraphMemIndexedSet MINIMAL (current)":
this.graphClass = GraphClass.GraphMemIndexedSetMinimal;
this.jenaVersion = JenaVersion.CURRENT;
break;
case "GraphMemIndexedSet MANUAL (current)":
this.graphClass = GraphClass.GraphMemIndexedSetManual;
this.jenaVersion = JenaVersion.CURRENT;
break;
case "GraphMemRoaring (current)":
case "GraphMemRoaring EAGER (current)":
this.graphClass = GraphClass.GraphMemRoaringEager;
Expand Down Expand Up @@ -96,6 +117,11 @@ public enum GraphClass {
GraphMemValue,
GraphMemFast,
GraphMemLegacy,
GraphMemIndexedSetEager,
GraphMemIndexedSetLazy,
GraphMemIndexedSetLazyParallel,
GraphMemIndexedSetMinimal,
GraphMemIndexedSetManual,
GraphMemRoaringEager,
GraphMemRoaringLazy,
GraphMemRoaringLazyParallel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public Graph createGraph(Context.GraphClass graphClass) {
case GraphMemRoaringLazyParallel -> new GraphMem2Roaring(IndexingStrategy.LAZY_PARALLEL);
case GraphMemRoaringMinimal -> new GraphMem2Roaring(IndexingStrategy.MINIMAL);
case GraphMemRoaringManual -> new GraphMem2Roaring(IndexingStrategy.MANUAL);
default -> throw new IllegalStateException("Unexpected value: " + graphClass);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;
import org.apache.jena.graph.Triple;
import org.apache.jena.mem.GraphMemFast;
import org.apache.jena.mem.GraphMemLegacy;
import org.apache.jena.mem.GraphMemRoaring;
import org.apache.jena.mem.IndexingStrategy;
import org.apache.jena.mem.*;
import org.apache.jena.memvalue.GraphMemValue;
import org.apache.jena.riot.RDFDataMgr;

public class GraphTripleNodeHelperCurrent implements GraphTripleNodeHelper<Graph, Triple, Node> {
Expand All @@ -39,9 +37,14 @@ public class GraphTripleNodeHelperCurrent implements GraphTripleNodeHelper<Graph
@Override
public Graph createGraph(Context.GraphClass graphClass) {
return switch (graphClass) {
case GraphMemValue -> new org.apache.jena.memvalue.GraphMemValue();
case GraphMemValue -> new GraphMemValue();
case GraphMemFast -> new GraphMemFast();
case GraphMemLegacy -> new GraphMemLegacy();
case GraphMemIndexedSetEager -> new GraphMemIndexedSet(IndexingStrategy.EAGER);
case GraphMemIndexedSetLazy -> new GraphMemIndexedSet(IndexingStrategy.LAZY);
case GraphMemIndexedSetLazyParallel -> new GraphMemIndexedSet(IndexingStrategy.LAZY_PARALLEL);
case GraphMemIndexedSetMinimal -> new GraphMemIndexedSet(IndexingStrategy.MINIMAL);
case GraphMemIndexedSetManual -> new GraphMemIndexedSet(IndexingStrategy.MANUAL);
case GraphMemRoaringEager -> new GraphMemRoaring(IndexingStrategy.EAGER);
case GraphMemRoaringLazy -> new GraphMemRoaring(IndexingStrategy.LAZY);
case GraphMemRoaringLazyParallel -> new GraphMemRoaring(IndexingStrategy.LAZY_PARALLEL);
Expand All @@ -54,7 +57,7 @@ public Graph createGraph(Context.GraphClass graphClass) {
public List<Triple> readTriples(String graphUri) {
var list = new ArrayList<Triple>();
@SuppressWarnings("deprecation")
var g1 = new org.apache.jena.memvalue.GraphMemValue() {
var g1 = new GraphMemValue() {
@Override
public void add(Triple t) {
list.add(t);
Expand All @@ -66,7 +69,7 @@ public void add(Triple t) {

@Override
public List<Triple> cloneTriples(List<Triple> triples) {
var list = new java.util.ArrayList<Triple>(triples.size());
var list = new ArrayList<Triple>(triples.size());
triples.forEach(triple -> list.add(cloneTriple(triple)));
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.jena.atlas.iterator.ActionCount;
import org.apache.jena.jmh.JmhDefaultOptions;

import org.apache.jena.mem.collection.Sized;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -75,12 +76,18 @@ public Spliterator<Object> createSut(Object[] arrayWithNulls, int elementsCount)
if (count != elementsCount) {
throw new RuntimeException("Concurrent modification detected");
}
} ;
final var sized = new Sized() {
@Override
public int size() {
return elementsCount;
}
};
return switch (param1_iteratorImplementation) {
case "memvalue.SparseArraySpliterator" ->
new org.apache.jena.memvalue.SparseArraySpliterator<>(arrayWithNulls, count, checkForConcurrentModification);
case "mem2.SparseArraySpliterator" ->
new SparseArraySpliterator<>(arrayWithNulls, checkForConcurrentModification);
new SparseArraySpliterator<>(arrayWithNulls, sized);
default ->
throw new IllegalArgumentException("Unknown spliterator implementation: " + param1_iteratorImplementation);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.jena.atlas.iterator.ActionCount;
import org.apache.jena.jmh.JmhDefaultOptions;

import org.apache.jena.mem.collection.Sized;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -77,11 +78,17 @@ public Spliterator<Object> createSut(Object[] arrayWithNulls, int elementsCount)
throw new RuntimeException("Concurrent modification detected");
}
};
final var sized = new Sized() {
@Override
public int size() {
return elementsCount;
}
};
return switch (param1_iteratorImplementation) {
case "memvalue.SparseArraySpliterator" ->
new org.apache.jena.memvalue.SparseArraySpliterator<>(arrayWithNulls, count, checkForConcurrentModification);
case "mem2.SparseArraySpliterator" ->
new SparseArraySpliterator<>(arrayWithNulls, checkForConcurrentModification);
new SparseArraySpliterator<>(arrayWithNulls, sized);
default ->
throw new IllegalArgumentException("Unknown spliterator implementation: " + param1_iteratorImplementation);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.jena.atlas.iterator.ActionCount;
import org.apache.jena.jmh.JmhDefaultOptions;

import org.apache.jena.mem.collection.Sized;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -78,11 +79,17 @@ public Spliterator<Object> createSut(Object[] arrayWithNulls, int elementsCount)
throw new RuntimeException("Concurrent modification detected");
}
};
final var sized = new Sized() {
@Override
public int size() {
return elementsCount;
}
};
return switch (param1_iteratorImplementation) {
case "memvalue.SparseArraySpliterator" ->
new org.apache.jena.memvalue.SparseArraySpliterator<>(arrayWithNulls, count, checkForConcurrentModification);
case "mem2.SparseArraySpliterator" ->
new SparseArraySpliterator<>(arrayWithNulls, checkForConcurrentModification);
new SparseArraySpliterator<>(arrayWithNulls, sized);
default ->
throw new IllegalArgumentException("Unknown spliterator implementation: " + param1_iteratorImplementation);
};
Expand Down
2 changes: 1 addition & 1 deletion jena-benchmarks/jena-benchmarks-shadedJena560/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.jena</groupId>
<artifactId>jena-benchmarks</artifactId>
<version>6.1.0</version>
<version>6.2.0-SNAPSHOT</version>
</parent>

<name>Apache Jena - Benchmarks Shaded Jena 5.6.0</name>
Expand Down
2 changes: 1 addition & 1 deletion jena-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.jena</groupId>
<artifactId>jena</artifactId>
<version>6.1.0</version>
<version>6.2.0-SNAPSHOT</version>
</parent>

<name>Apache Jena - Benchmark Suite</name>
Expand Down
17 changes: 17 additions & 0 deletions jena-core/src/main/java/org/apache/jena/graph/GraphMemFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.apache.jena.graph.impl.GraphBase ;
import org.apache.jena.mem.GraphMemFast;
import org.apache.jena.mem.GraphMemIndexedSet;
import org.apache.jena.mem.GraphMemLegacy;
import org.apache.jena.mem.GraphMemRoaring;
import org.apache.jena.sys.JenaSystem;
Expand Down Expand Up @@ -143,6 +144,22 @@ public static Graph createGraphMem2() {
public static Graph createGraphMemRoaring()
{ return new GraphMemRoaring(); }

/**
* A graph that stores triples in memory. This class is not thread-safe.
* <p>
* <ul>
* <li>This graph provides term equality.</li>
* <li>Iterator over this graph does not provide Iterator.remove</li>
* </ul>
* <p>
* {@link GraphMemIndexedSet} is supposed to replace {@link GraphMemRoaring}
* in the future.
* <p>
* See {@link GraphMemIndexedSet} for details.
*/
public static Graph createGraphMemIndexedSet()
{ return new GraphMemIndexedSet(); }

private final static Graph emptyGraph = new GraphBase() {
@Override
protected ExtendedIterator<Triple> graphBaseFind(Triple triplePattern) {
Expand Down
Loading