Search in sources :

Example 1 with MaxTestGraphProvider

use of com.alibaba.maxgraph.tests.gremlin.MaxTestGraphProvider in project GraphScope by alibaba.

the class FfiTest method testFfi.

@Test
public void testFfi() throws Exception {
    GraphProvider provider = new MaxTestGraphProvider();
    LoadGraphWith.GraphData modern = LoadGraphWith.GraphData.MODERN;
    Map<String, Object> conf = new HashMap<>();
    conf.put(CommonConfig.STORE_NODE_COUNT.getKey(), "1");
    conf.put(CommonConfig.PARTITION_COUNT.getKey(), "1");
    Configuration graphConf = provider.newGraphConfiguration("ffi-test", FfiTest.class, "testFfi", conf, modern);
    provider.clear(graphConf);
    Graph graph = provider.openTestGraph(graphConf);
    LoadGraphWith loadGraphWith = new LoadGraphWith() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return null;
        }

        @Override
        public GraphData value() {
            return modern;
        }
    };
    provider.loadGraphData(graph, loadGraphWith, FfiTest.class, "testFfi");
    MaxNode maxNode = ((MaxTestGraph) graph).getMaxNode();
    List<NodeBase> storeNodes = maxNode.getStores();
    assertEquals(storeNodes.size(), 1);
    Store store = (Store) storeNodes.get(0);
    StoreService storeService = store.getStoreService();
    JnaGraphStore jnaGraphStore = (JnaGraphStore) storeService.getIdToPartition().get(0);
    Pointer wrapperPartitionGraph = GraphLibrary.INSTANCE.createWrapperPartitionGraph(jnaGraphStore.getPointer());
    GnnLibrary.INSTANCE.setPartitionGraph(wrapperPartitionGraph);
    GnnLibrary.TestResult testResult = new GnnLibrary.TestResult(GnnLibrary.INSTANCE.runLocalTests());
    logger.info(testResult.getInfo());
    assertTrue(testResult.getFlag());
    provider.clear(graph, graphConf);
    maxNode.close();
}
Also used : MaxNode(com.alibaba.maxgraph.servers.MaxNode) Configuration(org.apache.commons.configuration2.Configuration) HashMap(java.util.HashMap) Store(com.alibaba.maxgraph.servers.Store) JnaGraphStore(com.alibaba.graphscope.groot.store.jna.JnaGraphStore) StoreService(com.alibaba.graphscope.groot.store.StoreService) Pointer(com.sun.jna.Pointer) LoadGraphWith(org.apache.tinkerpop.gremlin.LoadGraphWith) JnaGraphStore(com.alibaba.graphscope.groot.store.jna.JnaGraphStore) NodeBase(com.alibaba.maxgraph.servers.NodeBase) Graph(org.apache.tinkerpop.gremlin.structure.Graph) MaxTestGraph(com.alibaba.maxgraph.tests.gremlin.MaxTestGraph) MaxTestGraph(com.alibaba.maxgraph.tests.gremlin.MaxTestGraph) MaxTestGraphProvider(com.alibaba.maxgraph.tests.gremlin.MaxTestGraphProvider) MaxTestGraphProvider(com.alibaba.maxgraph.tests.gremlin.MaxTestGraphProvider) GraphProvider(org.apache.tinkerpop.gremlin.GraphProvider) Test(org.junit.Test)

Aggregations

StoreService (com.alibaba.graphscope.groot.store.StoreService)1 JnaGraphStore (com.alibaba.graphscope.groot.store.jna.JnaGraphStore)1 MaxNode (com.alibaba.maxgraph.servers.MaxNode)1 NodeBase (com.alibaba.maxgraph.servers.NodeBase)1 Store (com.alibaba.maxgraph.servers.Store)1 MaxTestGraph (com.alibaba.maxgraph.tests.gremlin.MaxTestGraph)1 MaxTestGraphProvider (com.alibaba.maxgraph.tests.gremlin.MaxTestGraphProvider)1 Pointer (com.sun.jna.Pointer)1 HashMap (java.util.HashMap)1 Configuration (org.apache.commons.configuration2.Configuration)1 GraphProvider (org.apache.tinkerpop.gremlin.GraphProvider)1 LoadGraphWith (org.apache.tinkerpop.gremlin.LoadGraphWith)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1 Test (org.junit.Test)1