Java 通过Gremlin GraphFactory连接到AWS Neptune
上的示例显示了如何使用Gremlin连接到AWS Neptune,如下所示:Java 通过Gremlin GraphFactory连接到AWS Neptune,java,amazon-web-services,gremlin,tinkerpop3,amazon-neptune,Java,Amazon Web Services,Gremlin,Tinkerpop3,Amazon Neptune,上的示例显示了如何使用Gremlin连接到AWS Neptune,如下所示: Cluster.Builder builder = Cluster.build(); builder.addContactPoint("your-neptune-endpoint"); builder.port(8182); builder.enableSsl(true); builder.keyCertChainFile("SFSRootCAG2.pem"); Cluster cluster = builder.c
Cluster.Builder builder = Cluster.build();
builder.addContactPoint("your-neptune-endpoint");
builder.port(8182);
builder.enableSsl(true);
builder.keyCertChainFile("SFSRootCAG2.pem");
Cluster cluster = builder.create();
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster));
import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
GraphTraversalSource g = traversal().withRemote('conf/remote-graph.properties');
但是,我当前连接到通用Gremlin图的代码如下所示:
Configuration conf = new PropertiesConfiguration(...);
... //Set configuration
Graph graph = GraphFactory.open(conf);
有人知道如何使用第二种方法与GraphFactory连接到海王星吗?我在任何地方都找不到任何示例。Neptune没有提供
图形
实例,因为Gremlin是远程执行的,而不是本地执行的GraphFactory
实际上只适用于您有一个Graph
实例要创建的情况。过去有一个RemoteGraph
允许这样做(尽管仍在TinkerPop测试套件中使用),但这种方法早已被放弃,不再推荐
您最初介绍的连接到Neptune等远程Gremlin提供者的方法是建立GraphTraversalSource
的推荐方法。但是值得注意的是,从3.3.5开始,首选方法不再使用EmptyGraph
,并允许您匿名实例化GraphTraversalSource
,如下所示:
Cluster.Builder builder = Cluster.build();
builder.addContactPoint("your-neptune-endpoint");
builder.port(8182);
builder.enableSsl(true);
builder.keyCertChainFile("SFSRootCAG2.pem");
Cluster cluster = builder.create();
GraphTraversalSource g = EmptyGraph.instance().traversal().withRemote(DriverRemoteConnection.using(cluster));
import static org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource.traversal;
GraphTraversalSource g = traversal().withRemote('conf/remote-graph.properties');
withRemote()
还有其他一些重载,看起来应该也很熟悉。我们使用图形的原因之一是我们想读取图形文件(例如Graph.io(IoCore.GraphML()).reader().batchSize(batchSize)。create().readGraph(inputStream,Graph);
)。使用GraphTraversalSource
,这可能吗?它从3.4.0开始,但今天才正式发布,我相当肯定Neptune尚未采用该语法。你可以在这里看到关于新的g.io()
步骤的更多信息:如果你需要将一个GraphML文件读入Neptune,我建议你将它读入TinkerGraph,然后用脚本将数据复制到Neptune。