Open imbajin opened 5 years ago
就cassandra来说,有一个比较好的思路统计总的点边数 : 它自身提供了一个统计某个表总行数(Number of keys
)的接口,可以快速得到一个预估但具体数值 (可通过JMX
很方便的调用)
≤
顶点表的行数≈
各节点顶点表总行数之和 / 3
统计总的出/入边也可采用相同的思路, 具体的做法如下3.0x
版本,通过Cassandra自带的notetool执行 : /path/to/bin/nodetool cfstats |grep cfName -A 15 |grep "Number of keys" |awk '{print $5}'
可以直接得到本节点的某个表(cf)的数值, 然后通过工具批量分发其他节点汇总一下, 就能得到总行数.curl http://127.0.0.1:7777/jolokia/read/org.apache.cassandra.metrics:type=ColumnFamily,keyspace=hugegraph,scope=graph_vertices,name=EstimatedRowCount
的方式直接获得值, 可以很方便的整合到项目中以上是这种思路的原理和实现方式, 虽然它的局限性比较明显, 但的确是一个简单快速统计出总点边的方法, 仅供大家参考~
@imbajin 非常感谢
补充Cassandra各版本的差异,可参考:
DSE 5.1 ~ 6.8: Number of partitions (estimate)
Apache Cassandra 3.0 ~ 2.2: Number of keys (estimate)
Expected behavior
Easy and quick to estimate the total number of vertices or edges..
Actual behavior
It's obviously unreasonable to use gremlin's method (like
g.V().count
) to get the result. Like #102 , #37Specifications of environment
Backend Version: Cassandra 3.0x or Cassandra 3.1x