PGQL Property Graph 查询语言
来源:互联网 发布:利用python写网络爬虫 编辑:程序博客网 时间:2024/05/22 15:57
http://pgql-lang.org/
m,n,o,p等只是一个节点的代号,e1,e2是边的名称代号
package net.wonderslife.src;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import oracle.pg.hbase.OraclePropertyGraph;
import oracle.pgx.api.PgqlResultSet;
import oracle.pgx.api.Pgx;
import oracle.pgx.api.PgxGraph;
import oracle.pgx.api.PgxSession;
import oracle.pgx.common.types.PropertyType;
import oracle.pgx.config.GraphConfigBuilder;
import oracle.pgx.config.PgHbaseGraphConfig;
public class PQL {
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException,
ExecutionException, InterruptedException {
pql1();
pql2();
pql3();
pql4();
}
private static void pql1() throws MasterNotRunningException, ZooKeeperConnectionException, IOException,
ExecutionException, InterruptedException {
String hbQuorum = "mypc1,mypc1";
String hbClientPort = "2181";
String hbGraphName = "people";
int splitsPerRegion = 2;
int dop = 8; // 并行度
int iClientPort = Integer.parseInt(hbClientPort);
PgHbaseGraphConfig cfg = GraphConfigBuilder.forPropertyGraphHbase().setName(hbGraphName).setZkQuorum(hbQuorum)
.setZkClientPort(iClientPort).setZkSessionTimeout(60000).setMaxNumConnections(dop)
.setSplitsPerRegion(splitsPerRegion).addVertexProperty("name", PropertyType.STRING, "empty name")
.addVertexProperty("country", PropertyType.STRING, "empty country")
.addVertexProperty("company", PropertyType.STRING, "empty company")
.addEdgeProperty("weight", PropertyType.DOUBLE, "1000000").setMaxNumConnections(2).build();
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(cfg);
PgxSession session = Pgx.createSession("session-id-1");
PgxGraph pgxGraph = session.readGraphWithProperties(opg.getConfig());
// PQL 1
PgqlResultSet pgxResultSet = pgxGraph.queryPgql("SELECT m.name,n.name WHERE (m)->(n),m!=n");
pgxResultSet.print(10);
pgxResultSet.close();
pgxGraph.close();
session.close();
opg.shutdown();
}
// PGQLdemo语句
private static void pql2() throws MasterNotRunningException, ZooKeeperConnectionException, IOException,
ExecutionException, InterruptedException {
String hbQuorum = "mypc1,mypc1";
String hbClientPort = "2181";
String hbGraphName = "people";
int splitsPerRegion = 2;
int dop = 8; // 并行度
int iClientPort = Integer.parseInt(hbClientPort);
PgHbaseGraphConfig cfg = GraphConfigBuilder.forPropertyGraphHbase().setName(hbGraphName).setZkQuorum(hbQuorum)
.setZkClientPort(iClientPort).setZkSessionTimeout(60000).setMaxNumConnections(dop)
.setSplitsPerRegion(splitsPerRegion).addVertexProperty("name", PropertyType.STRING, "empty name")
.addVertexProperty("country", PropertyType.STRING, "empty country")
.addVertexProperty("company", PropertyType.STRING, "empty company")
.addEdgeProperty("weight", PropertyType.DOUBLE, "1000000").setMaxNumConnections(2).build();
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(cfg);
PgxSession session = Pgx.createSession("session-id-1");
PgxGraph pgxGraph = session.readGraphWithProperties(opg.getConfig());
// PQL 1
PgqlResultSet pgxResultSet = pgxGraph.queryPgql(
"SELECT m.name,m.country,n.name,n.country WHERE (m with country='United States')-[e1 with weight>50]->(n with country='Russia'),m!=n");
pgxResultSet.print(10);
pgxResultSet.close();
pgxGraph.close();
session.close();
opg.shutdown();
}
// PGQLdemo语句
private static void pql3() throws MasterNotRunningException, ZooKeeperConnectionException, IOException,
ExecutionException, InterruptedException {
String hbQuorum = "mypc1,mypc1";
String hbClientPort = "2181";
String hbGraphName = "people";
int splitsPerRegion = 2;
int dop = 8; // 并行度
int iClientPort = Integer.parseInt(hbClientPort);
PgHbaseGraphConfig cfg = GraphConfigBuilder.forPropertyGraphHbase().setName(hbGraphName).setZkQuorum(hbQuorum)
.setZkClientPort(iClientPort).setZkSessionTimeout(60000).setMaxNumConnections(dop)
.setSplitsPerRegion(splitsPerRegion).addVertexProperty("name", PropertyType.STRING, "empty name")
.addVertexProperty("country", PropertyType.STRING, "empty country")
.addVertexProperty("company", PropertyType.STRING, "empty company")
.addEdgeProperty("weight", PropertyType.DOUBLE, "1000000").setMaxNumConnections(2).build();
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(cfg);
PgxSession session = Pgx.createSession("session-id-1");
PgxGraph pgxGraph = session.readGraphWithProperties(opg.getConfig());
// PQL 1
PgqlResultSet pgxResultSet = pgxGraph.queryPgql(
"SELECT m.country,count(*) as cnt WHERE (m)-[e1 with weight>50]->(n),m!=n group by m.country order by cnt desc");
pgxResultSet.print(10);
pgxResultSet.close();
pgxGraph.close();
session.close();
opg.shutdown();
}
// PGQLdemo语句
private static void pql4() throws MasterNotRunningException, ZooKeeperConnectionException, IOException,
ExecutionException, InterruptedException {
String hbQuorum = "mypc1,mypc1";
String hbClientPort = "2181";
String hbGraphName = "people";
int splitsPerRegion = 2;
int dop = 8; // 并行度
int iClientPort = Integer.parseInt(hbClientPort);
PgHbaseGraphConfig cfg = GraphConfigBuilder.forPropertyGraphHbase().setName(hbGraphName).setZkQuorum(hbQuorum)
.setZkClientPort(iClientPort).setZkSessionTimeout(60000).setMaxNumConnections(dop)
.setSplitsPerRegion(splitsPerRegion).addVertexProperty("name", PropertyType.STRING, "empty name")
.addVertexProperty("country", PropertyType.STRING, "empty country")
.addVertexProperty("company", PropertyType.STRING, "empty company")
.addEdgeProperty("weight", PropertyType.DOUBLE, "1000000").setMaxNumConnections(2).build();
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(cfg);
PgxSession session = Pgx.createSession("session-id-1");
PgxGraph pgxGraph = session.readGraphWithProperties(opg.getConfig());
// PQL 1
PgqlResultSet pgxResultSet = pgxGraph.queryPgql(
"SELECT m.name,n.name,o.name,p.name WHERE (m with country='United States')-[e1 with weight>50]->(n with country ='Russia') -[e2 with weight=1]->(o)->(p)");
pgxResultSet.print(10);
pgxResultSet.close();
pgxGraph.close();
session.close();
opg.shutdown();
}
}
- PGQL Property Graph 查询语言
- Property Graph Model
- Property Graph简介
- Objective-C语言--@property
- Spark组件之GraphX学习1--入门实例Property Graph
- boost graph read_graphml 要解析graph property(图的属性)要自己给boost graph加代码
- Objective-C语言关键词property
- 查询语言
- graph
- Graph
- Graph
- graph
- Graph
- Graph
- Graph
- graph
- Graph
- Graph
- 人工智能帮助千万用户完成「隐形征信」计算
- PC与开发板之间最简单快速的文件传输方式
- MapReducu操作HBase
- javaweb,数据库链接问题Communications link failure
- Hibernate初学者---自定义生成ID策略的步骤
- PGQL Property Graph 查询语言
- Longest Substring Without Repeating Characters
- Python numpy函数:shape用法
- QT读取mp3的lrc歌词文件不乱码的解决方法
- 33:判断字符串是否为回文
- 锐角三角函数的定义
- Python列表内建函数
- 栈的链式实现
- 单(single) (树上操作 函数互推)