如何解决Hbase 加载 .opv 和 .ope 给出十六进制输出
我正在使用 Oracle Big Data Spatial & Graph v.2.5 并遵循 the official guide to load through Java a Graph on HBase。 这是我的代码:
public class Main {
public static void main(String[] arg) throws Exception {
org.apache.log4j.BasicConfigurator.configure();
OraclePropertyGraphDataLoader opgdl = OraclePropertyGraphDataLoader.getInstance();
String vfile = "/root/oracle_property_files/connections.opv";
String efile = "/root/oracle_property_files/connections.ope";
PgHbaseGraphConfig cfg = GraphConfigBuilder.forPropertyGraphHbase()
.setName("config").setZkQuorum("zk01node,zk02node,zk03node").build();
OraclePropertyGraph opg = OraclePropertyGraph.getInstance(cfg);
opgdl.loadData(opg,vfile,efile,48);
}
}
使用这个库:
这是我的 .opv 文件:
1,name,1,Alice,age,2,31,Bob,27,
这是我的 .ope 文件:
1,knows,type,friends,
我的代码在 HBase 上创建表:configEI。 配置GE。 配置IT。 配置VI. 配置VT。
问题是,如果我启动命令 scan 'configVT.'
输出混合在十六进制和 ASCII 值中:
hbase(main):003:0> scan 'configVT.'
ROW COLUMN+CELL
3v\x93ur|\xD7\xD3\x00\x00\x00\x00\x00\x00\x00\x02 column=v:i\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01,timestamp=1624009988902,value=knows
3v\x93ur|\xD7\xD3\x00\x00\x00\x00\x00\x00\x00\x02 column=v:kage,timestamp=1624009989001,value=\x00\x00\x00\x1B\x02
3v\x93ur|\xD7\xD3\x00\x00\x00\x00\x00\x00\x00\x02 column=v:kname,value=Bob\x01
\xCB\xFC%\xA7qt\x02\x84\x00\x00\x00\x00\x00\x00\x00 column=v:kage,timestamp=1624009988909,value=\x00\x00\x00\x1F\x02
\x01
\xCB\xFC%\xA7qt\x02\x84\x00\x00\x00\x00\x00\x00\x00 column=v:kname,value=Alice\x01
\x01
\xCB\xFC%\xA7qt\x02\x84\x00\x00\x00\x00\x00\x00\x00 column=v:o\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x01,value=knows
\x01
2 row(s) in 0.0490 seconds
我想要一个更具可读性的结果。
编辑:似乎字符串和日期类型存储正确(但有一些十六进制转义字符为 Alice\x01
)。相反,整数完全转换为它们的十六进制值。
解决方法
我想通了。使用 scan
命令,我将表读取为简单的 hbase 表,但它们不是,它们是存储在 hbase 中的 Oracle 大数据空间和图形表。所以我的 configVT.
表只是用 java 方法 opgdl.loadData
创建的五个表之一,仅仅阅读它是不够的。
为了获得可读的结果,我应该阅读它有边缘或顶点:
opg.getVertices().forEach( e -> {
System.out.println("id vertex: " + e.getId());
e.getPropertyKeys().forEach(p -> {
System.out.println("property: " + p);
System.out.println("value: " + e.getProperty(p));
});
});
opg.getEdges().forEach( e -> {
System.out.println("label: " + e.getLabel());
System.out.println("id edge: " + e.getId());
Vertex vIn = e.getVertex(Direction.IN);
Vertex vOut = e.getVertex(Direction.OUT);
System.out.println("edge from: " + vOut.getId());
System.out.println("edge to: " + vIn.getId());
e.getPropertyKeys().forEach(p -> {
System.out.println("property: " + p);
System.out.println("value: " + e.getProperty(p));
});
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。