All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.janusgraph.graphdb.JanusGraphIterativeBenchmark Maven / Gradle / Ivy

There is a newer version: 1.2.0-20241120-125614.80ef1d9
Show newest version
// Copyright 2017 JanusGraph Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.janusgraph.graphdb;

import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Iterators;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Tag;
import org.janusgraph.TestCategory;
import org.janusgraph.core.JanusGraphEdge;
import org.janusgraph.core.JanusGraphTransaction;
import org.janusgraph.core.JanusGraphVertex;
import org.janusgraph.core.PropertyKey;
import org.janusgraph.diskstorage.Backend;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.Entry;
import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore;
import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager;
import org.janusgraph.diskstorage.keycolumnvalue.KeyIterator;
import org.janusgraph.diskstorage.keycolumnvalue.SliceQuery;
import org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction;
import org.janusgraph.diskstorage.util.BufferUtil;
import org.janusgraph.diskstorage.util.RecordIterator;
import org.janusgraph.diskstorage.util.StandardBaseTransactionConfig;
import org.janusgraph.diskstorage.util.time.TimestampProviders;
import org.janusgraph.graphdb.types.StandardEdgeLabelMaker;

import java.util.Random;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * A benchmark to test the performance of sequential row retrieval from the
 * underlying KeyColumnValueStore which is the basic operation underlying the
 * Fulgora OLAP component of JanusGraph.
 * 

* Hence, this is effectively a benchmark for {@link org.janusgraph.olap.OLAPTest} * or at least the primitive backend operations used therein. *

* * @author Matthias Broecheler ([email protected]) */ @Tag(TestCategory.PERFORMANCE_TESTS) public abstract class JanusGraphIterativeBenchmark extends JanusGraphBaseTest { private static final Random random = new Random(); public abstract KeyColumnValueStoreManager openStorageManager() throws BackendException; @RepeatedTest(10) public void testDataSequential() throws Exception { loadData(200000,2); close(); KeyColumnValueStoreManager manager = openStorageManager(); KeyColumnValueStore store = manager.openDatabase(Backend.EDGESTORE_NAME); SliceQuery query = new SliceQuery(BufferUtil.zeroBuffer(8),BufferUtil.oneBuffer(8)); query.setLimit(2); Stopwatch watch = Stopwatch.createStarted(); StoreTransaction txh = manager.beginTransaction(StandardBaseTransactionConfig.of(TimestampProviders.MILLI)); KeyIterator iterator = store.getKeys(query,txh); int numV = 0; while(iterator.hasNext()) { iterator.next(); RecordIterator entries = iterator.getEntries(); assertEquals(2, Iterators.size(entries)); numV++; } iterator.close(); txh.commit(); System.out.println("Time taken: " + watch.elapsed(TimeUnit.MILLISECONDS)); System.out.println("Num Vertices: " + numV); store.close(); manager.close(); } @RepeatedTest(10) public void testLoadData() throws Exception { loadData(100000,2); } public void loadData(final int numVertices, final int numThreads) throws Exception { makeKey("w",Integer.class); PropertyKey time = makeKey("t",Long.class); ((StandardEdgeLabelMaker)mgmt.makeEdgeLabel("l")).sortKey(time).make(); finishSchema(); final int maxQueue = 1000; final int verticesPerTask = 1000; final int maxWeight = 10; final int maxTime = 10000; final BlockingQueue tasks = new ArrayBlockingQueue<>(maxQueue); ExecutorService exe = Executors.newFixedThreadPool(numThreads); for (int i=0;i=maxQueue) Thread.sleep(maxQueue); Preconditions.checkState(tasks.size() { final JanusGraphTransaction tx = graph.newTransaction(); final JanusGraphVertex[] vs = new JanusGraphVertex[verticesPerTask]; for (int j=0;j





© 2015 - 2024 Weber Informatics LLC | Privacy Policy