Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过Gremlin GraphFactory连接到AWS Neptune_Java_Amazon Web Services_Gremlin_Tinkerpop3_Amazon Neptune - Fatal编程技术网

Java 通过Gremlin GraphFactory连接到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

上的示例显示了如何使用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.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。