Search in sources :

Example 1 with IDManager

use of org.janusgraph.graphdb.idmanagement.IDManager in project janusgraph by JanusGraph.

the class JanusGraphPartitionGraphTest method testVertexPartitionOlap.

private void testVertexPartitionOlap(CommitMode commitMode) throws Exception {
    Object[] options = { option(GraphDatabaseConfiguration.IDS_FLUSH), false };
    clopen(options);
    // int[] groupDegrees = {10,20,30};
    int[] groupDegrees = { 2 };
    int numVertices = setupGroupClusters(groupDegrees, commitMode);
    Map<Long, Integer> degreeMap = new HashMap<>(groupDegrees.length);
    for (int i = 0; i < groupDegrees.length; i++) {
        degreeMap.put(getOnlyVertex(tx.query().has("groupid", "group" + i)).longId(), groupDegrees[i]);
    }
    clopen(options);
    // Test OLAP works with partitioned vertices
    JanusGraphComputer computer = graph.compute(FulgoraGraphComputer.class);
    computer.resultMode(JanusGraphComputer.ResultMode.NONE);
    computer.workers(1);
    computer.program(new OLAPTest.DegreeCounter());
    computer.mapReduce(new OLAPTest.DegreeMapper());
    ComputerResult result = computer.submit().get();
    assertTrue(result.memory().exists(OLAPTest.DegreeMapper.DEGREE_RESULT));
    Map<Long, Integer> degrees = result.memory().get(OLAPTest.DegreeMapper.DEGREE_RESULT);
    assertNotNull(degrees);
    assertEquals(numVertices, degrees.size());
    final IDManager idManager = graph.getIDManager();
    for (Map.Entry<Long, Integer> entry : degrees.entrySet()) {
        long vid = entry.getKey();
        Integer degree = entry.getValue();
        if (idManager.isPartitionedVertex(vid)) {
            // System.out.println("Partitioned: " + degree );
            assertEquals(degreeMap.get(vid), degree);
        } else {
            assertEquals(1, (long) degree);
        }
    }
}
Also used : HashMap(java.util.HashMap) IDManager(org.janusgraph.graphdb.idmanagement.IDManager) OLAPTest(org.janusgraph.olap.OLAPTest) ComputerResult(org.apache.tinkerpop.gremlin.process.computer.ComputerResult) HashMap(java.util.HashMap) Map(java.util.Map) JanusGraphComputer(org.janusgraph.core.JanusGraphComputer)

Example 2 with IDManager

use of org.janusgraph.graphdb.idmanagement.IDManager in project janusgraph by JanusGraph.

the class StandardJanusGraphTxTest method createTxWithMockedInternals.

private StandardJanusGraphTx createTxWithMockedInternals() throws BackendException {
    StandardJanusGraph mockGraph = createMock(StandardJanusGraph.class);
    TransactionConfiguration txConfig = createMock(TransactionConfiguration.class);
    GraphDatabaseConfiguration gdbConfig = createMock(GraphDatabaseConfiguration.class);
    BackendTransaction txHandle = createMock(BackendTransaction.class);
    TimestampProvider tsProvider = createMock(TimestampProvider.class);
    Serializer mockSerializer = createMock(Serializer.class);
    EdgeSerializer mockEdgeSerializer = createMock(EdgeSerializer.class);
    IndexSerializer mockIndexSerializer = createMock(IndexSerializer.class);
    RelationType relationType = createMock(RelationType.class);
    IDManager idManager = createMock(IDManager.class);
    PropertyKey propertyKey = createMock(PropertyKey.class);
    DefaultSchemaMaker defaultSchemaMaker = createMock(DefaultSchemaMaker.class);
    IndexSelectionStrategy indexSelectionStrategy = createMock(ThresholdBasedIndexSelectionStrategy.class);
    expect(mockGraph.getConfiguration()).andReturn(gdbConfig);
    expect(mockGraph.isOpen()).andReturn(true).anyTimes();
    expect(mockGraph.getDataSerializer()).andReturn(mockSerializer);
    expect(mockGraph.getEdgeSerializer()).andReturn(mockEdgeSerializer);
    expect(mockGraph.getIndexSerializer()).andReturn(mockIndexSerializer);
    expect(mockGraph.getIDManager()).andReturn(idManager);
    expect(mockGraph.getIndexSelector()).andReturn(indexSelectionStrategy);
    mockGraph.closeTransaction(isA(StandardJanusGraphTx.class));
    EasyMock.expectLastCall().anyTimes();
    expect(gdbConfig.getTimestampProvider()).andReturn(tsProvider);
    expect(txConfig.isSingleThreaded()).andReturn(true);
    expect(txConfig.hasPreloadedData()).andReturn(false);
    expect(txConfig.hasVerifyExternalVertexExistence()).andReturn(false);
    expect(txConfig.hasVerifyInternalVertexExistence()).andReturn(false);
    expect(txConfig.getVertexCacheSize()).andReturn(6);
    expect(txConfig.isReadOnly()).andReturn(true);
    expect(txConfig.getDirtyVertexSize()).andReturn(2);
    expect(txConfig.getIndexCacheWeight()).andReturn(2L);
    expect(txConfig.getGroupName()).andReturn(null).anyTimes();
    expect(txConfig.getAutoSchemaMaker()).andReturn(defaultSchemaMaker);
    expect(defaultSchemaMaker.makePropertyKey(isA(PropertyKeyMaker.class), notNull())).andReturn(propertyKey);
    expect(relationType.isPropertyKey()).andReturn(false);
    expect(propertyKey.isPropertyKey()).andReturn(true);
    txHandle.rollback();
    EasyMock.expectLastCall().anyTimes();
    replayAll();
    StandardJanusGraphTx partialMock = createMockBuilder(StandardJanusGraphTx.class).withConstructor(mockGraph, txConfig).addMockedMethod("getRelationType").createMock();
    partialMock.setBackendTransaction(txHandle);
    expect(partialMock.getRelationType("Foo")).andReturn(null);
    expect(partialMock.getRelationType("Qux")).andReturn(propertyKey);
    expect(partialMock.getRelationType("Baz")).andReturn(relationType);
    replay(partialMock);
    return partialMock;
}
Also used : IndexSerializer(org.janusgraph.graphdb.database.IndexSerializer) IDManager(org.janusgraph.graphdb.idmanagement.IDManager) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) ThresholdBasedIndexSelectionStrategy(org.janusgraph.graphdb.query.index.ThresholdBasedIndexSelectionStrategy) IndexSelectionStrategy(org.janusgraph.graphdb.query.index.IndexSelectionStrategy) PropertyKeyMaker(org.janusgraph.core.schema.PropertyKeyMaker) TimestampProvider(org.janusgraph.diskstorage.util.time.TimestampProvider) DefaultSchemaMaker(org.janusgraph.core.schema.DefaultSchemaMaker) RelationType(org.janusgraph.core.RelationType) EdgeSerializer(org.janusgraph.graphdb.database.EdgeSerializer) BackendTransaction(org.janusgraph.diskstorage.BackendTransaction) PropertyKey(org.janusgraph.core.PropertyKey) StandardJanusGraph(org.janusgraph.graphdb.database.StandardJanusGraph) EdgeSerializer(org.janusgraph.graphdb.database.EdgeSerializer) IndexSerializer(org.janusgraph.graphdb.database.IndexSerializer) Serializer(org.janusgraph.graphdb.database.serialize.Serializer)

Aggregations

IDManager (org.janusgraph.graphdb.idmanagement.IDManager)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ComputerResult (org.apache.tinkerpop.gremlin.process.computer.ComputerResult)1 JanusGraphComputer (org.janusgraph.core.JanusGraphComputer)1 PropertyKey (org.janusgraph.core.PropertyKey)1 RelationType (org.janusgraph.core.RelationType)1 DefaultSchemaMaker (org.janusgraph.core.schema.DefaultSchemaMaker)1 PropertyKeyMaker (org.janusgraph.core.schema.PropertyKeyMaker)1 BackendTransaction (org.janusgraph.diskstorage.BackendTransaction)1 TimestampProvider (org.janusgraph.diskstorage.util.time.TimestampProvider)1 GraphDatabaseConfiguration (org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration)1 EdgeSerializer (org.janusgraph.graphdb.database.EdgeSerializer)1 IndexSerializer (org.janusgraph.graphdb.database.IndexSerializer)1 StandardJanusGraph (org.janusgraph.graphdb.database.StandardJanusGraph)1 Serializer (org.janusgraph.graphdb.database.serialize.Serializer)1 IndexSelectionStrategy (org.janusgraph.graphdb.query.index.IndexSelectionStrategy)1 ThresholdBasedIndexSelectionStrategy (org.janusgraph.graphdb.query.index.ThresholdBasedIndexSelectionStrategy)1 OLAPTest (org.janusgraph.olap.OLAPTest)1