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: 100.3.2.1
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.Stopwatch;
import com.google.common.collect.Iterators;
import org.janusgraph.core.PropertyKey;
import org.janusgraph.core.JanusGraphEdge;
import org.janusgraph.core.JanusGraphTransaction;
import org.janusgraph.core.JanusGraphVertex;
import org.janusgraph.diskstorage.Backend;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.Entry;
import org.janusgraph.diskstorage.keycolumnvalue.*;
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 org.apache.tinkerpop.gremlin.structure.VertexProperty;

import java.util.Random;
import java.util.concurrent.*;

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]) */ public abstract class JanusGraphIterativeBenchmark extends JanusGraphBaseTest { private static final Random random = new Random(); public abstract KeyColumnValueStoreManager openStorageManager() throws BackendException; //@Test 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(); } //@Test 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); assert 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