1. 简介

    (1)titan:存储,查询图形结构的数据库。分布式集群环境下,可支持数以千亿级别的点和边,同时支持上千个并发的实时的复杂图形遍历,支持ACID事务。

    (2)架构:支持以下3方面的自由组合

    • 节点和边的存储:

      • Apache Cassandra
      • Apache HBase
      • Oracle BerkeleyDB(测试使用)
    • 图形分析组件:
      • Spark
      • Giraph
      • Hadoop
    • 地理,数值,全文检索支持
      • ElasticSearch
      • Solr
      • Lucene
  2. titan-hbase-es部署范例

    (1)版本对应

    titan:0.54-hadoop2,hbase:1.1.5 (版本相对宽松),elasticsearch:1.4,rexster-server:2.6

    (2)titan server部署

    • rexster-server解压

    • 修改config/rexster.xml文件,添加如下内容

      <graph>
      <graph-enabled>true</graph-enabled>
      <graph-name>titanexample</graph-name>
      <graph-type>com.thinkaurelius.titan.tinkerpop.rexster.TitanGraphConfiguration</graph-type>
      <graph-location></graph-location>
      <graph-read-only>false</graph-read-only>
      <properties>
      <storage.backend>hbase</storage.backend>
      <storage.hostname>localhost:2181,localhost:2182,localhost:2183</storage.hostname>
      <storage.hbase.table>facebook</storage.hbase.table>
      <index.search.backend>elasticsearch</index.search.backend>
      <index.search.elasticsearch.client-only>true</index.search.elasticsearch.client-only>
      <index.search.hostname>127.0.0.1</index.search.hostname>
      <index.search.index-name>facebook</index.search.index-name>
      </properties>
      <extensions>
      <allows>
      <allow>tp:gremlin</allow>
      </allows>
      </extensions>
      </graph>
    • 复制titan jar包到rexster lib

    cp   TITAN_HOME/lib/*    REXSTER_HOME/ext/titan/
    • 删除rexster/lib下的lucene相关jar包,会与titan的引起冲突
    • 开启rexster
    ./bin/rexster.sh -s -c ./config/rexster.xml
    • 访问http://ip:8182/graphs/titanexample,REST
  3. titan server接口

    (1)RexPro二进制协议

    public class TestClient {
    public static void main(String[] args) throws Exception {
    RexsterClient client = RexsterClientFactory.open("localhost", "titanexample");
    List<Map<String,Object>> result;
    result = client.execute("aa=g.V.has('name','saturn');aa.next()");
    //result = client.execute("g.getManagementSystem().get(‘cache.db-cache’)");
    // result.toString(): [{name="jupiter"}]
    System.out.println(result);
    client.close();
    }
    }
    <dependency>
    <groupId>com.tinkerpop.rexster</groupId>
    <artifactId>rexster-protocol</artifactId>
    <version>2.6.0</version>
    </dependency>

(2)thinkerpop - REST协议

  1. “红楼梦宗谱”示例

    (1)编写blueprint脚本,设置schema,索引,添加将节点数据
    com.thinkaurelius.titan.core.schema.TitanManagement mgmt = g.getManagementSystem();
    //点的属性名
    com.thinkaurelius.titan.core.PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
    com.thinkaurelius.titan.core.PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make();
    // 点的标签名
    mgmt.makeVertexLabel("people").make(); //该点表示人
    mgmt.makeVertexLabel("hobby").make(); //该点是一个运动
    // 给点的姓名年龄建索引
    mgmt.buildIndex("name",Vertex.class).addKey(name).unique().buildCompositeIndex(); // "search"是配置文件中的标识符
    mgmt.buildIndex("vertices",Vertex.class).addKey(age).buildMixedIndex("search"); // mixedIndex是外部索引,用es存储索引 // 边的属性
    mgmt.makeEdgeLabel("father").multiplicity(com.thinkaurelius.titan.core.Multiplicity.MANY2ONE).make();
    mgmt.makeEdgeLabel("mother").multiplicity(com.thinkaurelius.titan.core.Multiplicity.MANY2ONE).make();
    mgmt.makeEdgeLabel("hobby").multiplicity(com.thinkaurelius.titan.core.Multiplicity.MULTI).make();
    com.thinkaurelius.titan.core.PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make();
    com.thinkaurelius.titan.core.EdgeLabel love = mgmt.makeEdgeLabel("love").signature(time).make();//什么时候确立爱情挂席
    mgmt.buildEdgeIndex(love,"lovetime", Direction.BOTH, com.thinkaurelius.titan.core.Order.DESC,time);
    mgmt.commit(); //插入点
    com.thinkaurelius.titan.core.TitanTransaction tx = g.newTransaction();
    Vertex jiazheng = tx.addVertexWithLabel("people"); // 贾政
    jiazheng.setProperty("name","贾政");
    jiazheng.setProperty("age",48);
    Vertex jiabaoyu = tx.addVertexWithLabel("people"); // 贾宝玉
    jiabaoyu.setProperty("name","贾宝玉");
    jiabaoyu.setProperty("age",18);
    Vertex wangfuren = tx.addVertexWithLabel("people"); // 王夫人
    wangfuren.setProperty("name","王夫人");
    wangfuren.setProperty("age",47);
    Vertex xuebaochai = tx.addVertexWithLabel("people"); // 薛宝钗
    xuebaochai.setProperty("name","薛宝钗");
    xuebaochai.setProperty("age",17); Vertex cixiu = tx.addVertexWithLabel("hobby");
    cixiu.setProperty("name","刺绣");
    Vertex zuoshi = tx.addVertexWithLabel("hobby");
    zuoshi.setProperty("name","作诗"); //插入边
    jiabaoyu.addEdge("father",jiazheng);
    jiabaoyu.addEdge("mother",wangfuren);
    ElementHelper.setProperties(jiabaoyu.addEdge("love",xuebaochai),"time",1001); // 贾宝玉爱林黛玉,"time"属性为1001
    wangfuren.addEdge("hobby",cixiu);
    xuebaochai.addEdge("hobby",zuoshi); tx.commit();

(2)通过RexPro协议发送脚本到服务器

java public static void main(String[] args) throws Exception { RexsterClient client = RexsterClientFactory.open("localhost", "titanexample"); List<Map<String,Object>> result; BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("facebook-gremlin"))); String str=""; StringBuffer sb = new StringBuffer(); while((str = br.readLine())!=null){ sb.append(str); } System.out.println(sb.toString()); result = client.execute(sb.toString()); System.out.println(result); client.close(); }

(3)rest api

shell curl -XGET http://localhost:8182/graphs/titanexample/vertices #查看所有边 curl -XGET http://localhost:8182/graphs/titanexample/edges curl -XGET http://localhost:8182/graphs/titanexample/keyindices curl -XGET http://localhost:8182/graphs/titanexample/vertices/16400/in #查询节点的入射边 curl -XPOST http://localhost:8182/graphs/titanexample/vertices/11111?name=zhangsan&age=24 #创建节点 curl -XPOST http://localhost:8182/graphs/titanexample/edges?_outV=<id>&_label=friend&_inV=2&<key>=<key'> #创建节点间的边

(4)gremlin查询示例,查询贾宝玉的父亲

```shell
gremlin> g.V.has('name','贾宝玉').next().out('father').name
==>贾政
``` (5)全文检索节点,按照es的格式封装的map ```java
result = client.execute("g.indexQuery(\"vertices\", \"v.age:(17)\").vertices().get(0).getElement()");
for (Map<String, Object> map : result) {
for (Map.Entry<String, Object> en : map.entrySet()) {
System.out.print(en.getKey()+":"+en.getValue()+"\t\t");
}
System.out.println();
}
/**
_type:vertex _properties:{name=薛宝钗, age=17} _id:16496
*/
```
  1. 数据展现

    • Sigma.js it's a free and open source tool for graph visualization quite nice. Linkurious is using a fork version of it as far as I know in their product.
    • VivaGraph it's another free and open source tool for graph visualization tool - but it has a smaller community compared to SigmaJS.
    • D3.js it's the factotum for data visualization, you can do basically every kind of visualization based on that, but the learning curve is quite steep.
    • Gephi is another free and open source desktop solution, you have to use an external plugin with that probably but it does support most of the formats out there - graphML, CSV, Neo4J, etc...
  2. 参考网站

    thinkerpop

    gremlin与sql对比查询语法

    sparql-gremlin插件

    DataStax给出的图形查询语言,包括sparql,GraphQL, Cypher, Gremlin

titan的更多相关文章

  1. Titan DB的一些问题

    使用熟悉一点的系统来测试TitanDB,HBASE+ES,记录下来一些小tips. 1.首先TitanDB支持的Hadoop只有1.2.1,所以Hbase自然也只能取到0.98,虽然官网上提供了tit ...

  2. 图数据库 Titan 高速入门

    尤其在互联网世界,图计算越来越受到人们的关注,而图计算相关的软件也越来越丰富.本文将高速展示 Titan这个open source 的图数据库. 注:本文的操作主要基于Titan 官方的两篇文档: - ...

  3. 深度学习环境搭建(ubuntu16.04+Titan Xp安装显卡驱动+Cuda9.0+cudnn+其他软件)

    一.硬件环境 ubuntu 16.04LTS + windows10 双系统 NVIDIA TiTan XP 显卡(12G) 二.软件环境 搜狗输入法 下载地址 显卡驱动:LINUX X64 (AMD ...

  4. 图数据库titan 和 rexster安装手册

    titan是图数据库, rexster是图显示服务 titan 安装 下载 titan 0.3.2 解压 titan-all-0.3.2.zip 到 /opt/hugedata/share/解压后得到 ...

  5. 牛客国庆集训派对Day1 B. Attack on Titan

    B. Attack on Titan 链接 #include<cstdio> #include<algorithm> #include<cstring> #incl ...

  6. [知识图谱] 环境配置:Java8 + Maven3 + HBase + Titan

    1.Java Java8安装配置 2.Maven Linux下的Maven安装与配置 3.Hbase 官方安装教程:http://s3.thinkaurelius.com/docs/titan/1.0 ...

  7. ubuntu16.04+Titan Xp安装显卡驱动+Cuda9.0+cudnn

    硬件环境 ubuntu 16.04LTS + windows10 双系统 NVIDIA TiTan XP 显卡(12G) 软件环境 搜狗输入法 显卡驱动:LINUX X64 (AMD64/EM64T) ...

  8. Google为远程入侵Titan M芯片提供最高150万美元的赏金

    Google最近发布了一项新的公告,旨在提高对发现和报告Android操作系统中的严重漏洞的漏洞赏金的奖励,Google昨天为黑客设定了新的挑战性水平,使他们可以赢得高达150万美元的赏金. 从今天开 ...

  9. URAL - 1920 Titan Ruins: the Infinite Power of Magic(乱搞)

    搞死人的题目,,, 就是在n*n的方格中找路径长度为L的回路. 开始的思路值适合n为偶数的情况,而忽视了奇数的case,所以wa了一次. 然后找奇数case的策略,代码从70多行变成了100多,然后改 ...

随机推荐

  1. 关于Toad连接DB2的sqlstate=08001错误

    新装的centos6.3+db29.7,数据库导入完了的之后用Toad连接访问之的时候出错了. DB2 Database Error: ERROR [08001] [IBM] SQL30081N A ...

  2. HTTP详解(3)-http1.0 和http1.1 区别

    HTTP详解(3)-http1.0 和http1.1 区别 分类: 网络知识2013-03-17 16:51 1685人阅读 评论(0) 收藏 举报   目录(?)[+]   翻了下HTTP1.1的协 ...

  3. leetcode 144. Binary Tree Preorder Traversal ----- java

    Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tr ...

  4. Docker仓库管理

    1.# docker pull registry //下载registry镜像,registry为docker官方提供的一个镜像,我们可以用它来创建本地的docker私有仓库. 2.# docker ...

  5. 統計數字(2007年NOIP全国联赛提高组)

    题目描述 Description [问题描述]某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*109).已知不相同的数不超过10000 个,现在需要统计这些自然数各自出现的 ...

  6. 1-3 ISO/OSI七层模型详解

    一.物理层 1.负责设备之间的比特流的传输.物理接口.电气特性等. <1>物理接口:网线接口型号.音频线接口型号.视频线接口型号等 <2>电气特性:例如网线总共8根线,这8根线 ...

  7. php支付接口,代付、感悟

    支付接口: 1.验证用户登录信息 2.验证参数.用加密串来匹配,开信息是否被篡改 3.如果有必要可以仿造购物城 建立购物车列表 4.建立和请求方的关联表 5.进行订单生成.支付流程.各种判断.验证. ...

  8. ..c++中用c语言的输入法

    题目: 竞选时,要求选民在n个候选人中选择,n个人的名字为 A,B,C,D--连续n个大写字母,如果选择n个人名字之外的人员,则为废票.   统计时以输入'#'为结束标记.请按候选人的得票数目从大到小 ...

  9. HDU-3586 Information Disturbing(树形DP+删边)

    题目大意:一棵有n个节点的有根树,1为根节点,边带权,表示删掉这条边的代价.现在要删掉一些边,使叶子节点不能到达根节点.但是,每次删除的边的代价不能超过limit,删掉的边的总代价不能超过m,求最小的 ...

  10. 关于ASP.NET MVC4 Web API简单总结

    原文地址:http://www.cnblogs.com/lei2007/archive/2013/02/01/2888706.html wcf web api 和 asp.net web api , ...