Search in sources :

Example 1 with IDManager

use of com.thinkaurelius.titan.graphdb.idmanagement.IDManager in project titan by thinkaurelius.

the class TitanPartitionGraphTest 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
    TitanGraphComputer computer = graph.compute(FulgoraGraphComputer.class);
    computer.resultMode(TitanGraphComputer.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 : IDManager(com.thinkaurelius.titan.graphdb.idmanagement.IDManager) OLAPTest(com.thinkaurelius.titan.olap.OLAPTest) ComputerResult(org.apache.tinkerpop.gremlin.process.computer.ComputerResult)

Aggregations

IDManager (com.thinkaurelius.titan.graphdb.idmanagement.IDManager)1 OLAPTest (com.thinkaurelius.titan.olap.OLAPTest)1 ComputerResult (org.apache.tinkerpop.gremlin.process.computer.ComputerResult)1