You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by zh...@apache.org on 2022/11/26 12:57:41 UTC
[incubator-hugegraph-computer] 01/01: Rename `com.baidu` to `org.apache`
This is an automated email from the ASF dual-hosted git repository.
zhaocong pushed a commit to branch rename_package
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-computer.git
commit 2f13b543cab07456aa74c36862c4f338ad35b5a8
Author: coderzc <zh...@apache.org>
AuthorDate: Sat Nov 26 20:57:12 2022 +0800
Rename `com.baidu` to `org.apache`
---
README.md | 2 +-
computer-algorithm/pom.xml | 4 +-
.../betweenness/BetweennessCentrality.java | 193 -----
.../betweenness/BetweennessCentralityParams.java | 48 --
.../centrality/betweenness/BetweennessMessage.java | 90 --
.../centrality/betweenness/BetweennessValue.java | 73 --
.../centrality/closeness/ClosenessCentrality.java | 169 ----
.../closeness/ClosenessCentralityParams.java | 47 --
.../centrality/closeness/ClosenessMessage.java | 89 --
.../centrality/closeness/ClosenessValue.java | 44 -
.../centrality/degree/DegreeCentrality.java | 127 ---
.../centrality/degree/DegreeCentralityParams.java | 47 --
.../algorithm/centrality/pagerank/PageRank.java | 155 ----
.../centrality/pagerank/PageRank4Master.java | 104 ---
.../centrality/pagerank/PageRankParams.java | 46 -
.../community/cc/ClusteringCoefficient.java | 83 --
.../community/cc/ClusteringCoefficientOutput.java | 64 --
.../community/cc/ClusteringCoefficientParams.java | 44 -
.../community/cc/ClusteringCoefficientValue.java | 94 ---
.../computer/algorithm/community/kcore/Kcore.java | 123 ---
.../algorithm/community/kcore/KcoreParams.java | 43 -
.../algorithm/community/kcore/KcoreValue.java | 103 ---
.../computer/algorithm/community/lpa/Lpa.java | 102 ---
.../algorithm/community/lpa/LpaParams.java | 40 -
.../community/trianglecount/TriangleCount.java | 118 ---
.../trianglecount/TriangleCountParams.java | 44 -
.../trianglecount/TriangleCountValue.java | 84 --
.../computer/algorithm/community/wcc/Wcc.java | 73 --
.../algorithm/community/wcc/WccParams.java | 43 -
.../algorithm/path/rings/RingsDetection.java | 116 ---
.../algorithm/path/rings/RingsDetectionOutput.java | 50 --
.../algorithm/path/rings/RingsDetectionParams.java | 42 -
.../path/rings/filter/FilterDescribe.java | 85 --
.../path/rings/filter/RingsDetectionMessage.java | 78 --
.../rings/filter/RingsDetectionWithFilter.java | 123 ---
.../filter/RingsDetectionWithFilterParams.java | 44 -
.../algorithm/path/rings/filter/SpreadFilter.java | 158 ----
.../betweenness/BetweennessCentrality.java | 192 +++++
.../betweenness/BetweennessCentralityParams.java | 48 ++
.../centrality/betweenness/BetweennessMessage.java | 90 ++
.../centrality/betweenness/BetweennessValue.java | 73 ++
.../centrality/closeness/ClosenessCentrality.java | 168 ++++
.../closeness/ClosenessCentralityParams.java | 47 ++
.../centrality/closeness/ClosenessMessage.java | 89 ++
.../centrality/closeness/ClosenessValue.java | 44 +
.../centrality/degree/DegreeCentrality.java | 126 +++
.../centrality/degree/DegreeCentralityParams.java | 47 ++
.../algorithm/centrality/pagerank/PageRank.java | 155 ++++
.../centrality/pagerank/PageRank4Master.java | 103 +++
.../centrality/pagerank/PageRankParams.java | 46 +
.../community/cc/ClusteringCoefficient.java | 83 ++
.../community/cc/ClusteringCoefficientOutput.java | 63 ++
.../community/cc/ClusteringCoefficientParams.java | 44 +
.../community/cc/ClusteringCoefficientValue.java | 94 +++
.../computer/algorithm/community/kcore/Kcore.java | 124 +++
.../algorithm/community/kcore/KcoreParams.java | 43 +
.../algorithm/community/kcore/KcoreValue.java | 102 +++
.../computer/algorithm/community/lpa/Lpa.java | 101 +++
.../algorithm/community/lpa/LpaParams.java | 40 +
.../community/trianglecount/TriangleCount.java | 118 +++
.../trianglecount/TriangleCountParams.java | 44 +
.../trianglecount/TriangleCountValue.java | 83 ++
.../computer/algorithm/community/wcc/Wcc.java | 73 ++
.../algorithm/community/wcc/WccParams.java | 43 +
.../algorithm/path/rings/RingsDetection.java | 116 +++
.../algorithm/path/rings/RingsDetectionOutput.java | 50 ++
.../algorithm/path/rings/RingsDetectionParams.java | 42 +
.../path/rings/filter/FilterDescribe.java | 85 ++
.../path/rings/filter/RingsDetectionMessage.java | 78 ++
.../rings/filter/RingsDetectionWithFilter.java | 123 +++
.../filter/RingsDetectionWithFilterParams.java | 44 +
.../algorithm/path/rings/filter/SpreadFilter.java | 158 ++++
computer-api/pom.xml | 2 +-
.../computer/algorithm/AlgorithmParams.java | 76 --
.../computer/core/aggregator/Aggregator.java | 93 --
.../core/aggregator/Aggregator4Master.java | 80 --
.../core/aggregator/Aggregator4Worker.java | 67 --
.../computer/core/allocator/Allocator.java | 34 -
.../computer/core/allocator/Recyclable.java | 23 -
.../computer/core/allocator/RecyclerReference.java | 45 -
.../hugegraph/computer/core/combiner/Combiner.java | 55 --
.../core/combiner/DoubleValueSumCombiner.java | 35 -
.../core/combiner/FloatValueSumCombiner.java | 35 -
.../core/combiner/IntValueSumCombiner.java | 35 -
.../core/combiner/LongValueSumCombiner.java | 35 -
.../core/combiner/MergeNewPropertiesCombiner.java | 55 --
.../core/combiner/MergeOldPropertiesCombiner.java | 55 --
.../computer/core/combiner/OverwriteCombiner.java | 35 -
.../core/combiner/OverwritePropertiesCombiner.java | 41 -
.../computer/core/combiner/PropertiesCombiner.java | 29 -
.../computer/core/combiner/ValueMaxCombiner.java | 39 -
.../computer/core/combiner/ValueMinCombiner.java | 39 -
.../computer/core/common/ComputerContext.java | 65 --
.../hugegraph/computer/core/common/Constants.java | 77 --
.../hugegraph/computer/core/common/SerialEnum.java | 54 --
.../core/common/exception/ComputerException.java | 56 --
.../computer/core/config/ComputerOptions.java | 937 ---------------------
.../hugegraph/computer/core/config/Config.java | 52 --
.../computer/core/config/DefaultConfig.java | 206 -----
.../computer/core/config/EdgeFrequency.java | 44 -
.../hugegraph/computer/core/config/HotConfig.java | 51 --
.../baidu/hugegraph/computer/core/config/Null.java | 32 -
.../computer/core/graph/GraphFactory.java | 78 --
.../hugegraph/computer/core/graph/edge/Edge.java | 46 -
.../hugegraph/computer/core/graph/edge/Edges.java | 27 -
.../baidu/hugegraph/computer/core/graph/id/Id.java | 31 -
.../computer/core/graph/id/IdFactory.java | 92 --
.../hugegraph/computer/core/graph/id/IdType.java | 44 -
.../core/graph/properties/DefaultProperties.java | 131 ---
.../computer/core/graph/properties/Properties.java | 43 -
.../computer/core/graph/value/BooleanValue.java | 111 ---
.../computer/core/graph/value/DoubleValue.java | 134 ---
.../computer/core/graph/value/FloatValue.java | 134 ---
.../computer/core/graph/value/IdList.java | 57 --
.../computer/core/graph/value/IdListList.java | 47 --
.../hugegraph/computer/core/graph/value/IdSet.java | 113 ---
.../computer/core/graph/value/IntValue.java | 134 ---
.../computer/core/graph/value/ListValue.java | 242 ------
.../computer/core/graph/value/LongValue.java | 134 ---
.../computer/core/graph/value/MapValue.java | 169 ----
.../computer/core/graph/value/NullValue.java | 103 ---
.../computer/core/graph/value/StringValue.java | 104 ---
.../hugegraph/computer/core/graph/value/Value.java | 108 ---
.../computer/core/graph/value/ValueType.java | 72 --
.../computer/core/graph/vertex/Vertex.java | 62 --
.../hugegraph/computer/core/input/InputFilter.java | 34 -
.../hugegraph/computer/core/io/BytesInput.java | 23 -
.../hugegraph/computer/core/io/BytesOutput.java | 35 -
.../computer/core/io/GraphComputeInput.java | 39 -
.../computer/core/io/GraphComputeOutput.java | 39 -
.../hugegraph/computer/core/io/GraphInput.java | 23 -
.../hugegraph/computer/core/io/GraphOutput.java | 24 -
.../computer/core/io/GraphWritebackOutput.java | 38 -
.../computer/core/io/RandomAccessInput.java | 80 --
.../computer/core/io/RandomAccessOutput.java | 69 --
.../baidu/hugegraph/computer/core/io/Readable.java | 27 -
.../baidu/hugegraph/computer/core/io/Writable.java | 27 -
.../core/master/DefaultMasterComputation.java | 45 -
.../computer/core/master/MasterComputation.java | 55 --
.../core/master/MasterComputationContext.java | 62 --
.../computer/core/master/MasterContext.java | 28 -
.../core/output/AbstractComputerOutput.java | 55 --
.../computer/core/output/ComputerOutput.java | 59 --
.../computer/core/output/hg/HugeGraphOutput.java | 107 ---
.../output/hg/exceptions/WriteBackException.java | 41 -
.../core/output/hg/metrics/LoadMetrics.java | 49 --
.../core/output/hg/metrics/LoadReport.java | 42 -
.../core/output/hg/metrics/LoadSummary.java | 73 --
.../computer/core/output/hg/metrics/Printer.java | 58 --
.../core/output/hg/task/BatchInsertTask.java | 104 ---
.../computer/core/output/hg/task/InsertTask.java | 81 --
.../core/output/hg/task/SingleInsertTask.java | 62 --
.../computer/core/output/hg/task/TaskManager.java | 188 -----
.../hugegraph/computer/core/util/BytesUtil.java | 78 --
.../hugegraph/computer/core/util/CoderUtil.java | 159 ----
.../computer/core/worker/Computation.java | 103 ---
.../computer/core/worker/ComputationContext.java | 136 ---
.../computer/core/worker/FilterComputation.java | 113 ---
.../computer/core/worker/ReduceComputation.java | 99 ---
.../computer/core/worker/WorkerContext.java | 38 -
.../computer/algorithm/AlgorithmParams.java | 77 ++
.../computer/core/aggregator/Aggregator.java | 93 ++
.../core/aggregator/Aggregator4Master.java | 80 ++
.../core/aggregator/Aggregator4Worker.java | 67 ++
.../computer/core/allocator/Allocator.java | 34 +
.../computer/core/allocator/Recyclable.java | 23 +
.../computer/core/allocator/RecyclerReference.java | 45 +
.../hugegraph/computer/core/combiner/Combiner.java | 55 ++
.../core/combiner/DoubleValueSumCombiner.java | 35 +
.../core/combiner/FloatValueSumCombiner.java | 35 +
.../core/combiner/IntValueSumCombiner.java | 35 +
.../core/combiner/LongValueSumCombiner.java | 35 +
.../core/combiner/MergeNewPropertiesCombiner.java | 55 ++
.../core/combiner/MergeOldPropertiesCombiner.java | 55 ++
.../computer/core/combiner/OverwriteCombiner.java | 35 +
.../core/combiner/OverwritePropertiesCombiner.java | 41 +
.../computer/core/combiner/PropertiesCombiner.java | 29 +
.../computer/core/combiner/ValueMaxCombiner.java | 39 +
.../computer/core/combiner/ValueMinCombiner.java | 39 +
.../computer/core/common/ComputerContext.java | 65 ++
.../hugegraph/computer/core/common/Constants.java | 77 ++
.../hugegraph/computer/core/common/SerialEnum.java | 55 ++
.../core/common/exception/ComputerException.java | 56 ++
.../computer/core/config/ComputerOptions.java | 937 +++++++++++++++++++++
.../hugegraph/computer/core/config/Config.java | 52 ++
.../computer/core/config/DefaultConfig.java | 205 +++++
.../computer/core/config/EdgeFrequency.java | 44 +
.../hugegraph/computer/core/config/HotConfig.java | 51 ++
.../hugegraph/computer/core/config/Null.java | 32 +
.../computer/core/graph/GraphFactory.java | 78 ++
.../hugegraph/computer/core/graph/edge/Edge.java | 46 +
.../hugegraph/computer/core/graph/edge/Edges.java | 27 +
.../hugegraph/computer/core/graph/id/Id.java | 31 +
.../computer/core/graph/id/IdFactory.java | 92 ++
.../hugegraph/computer/core/graph/id/IdType.java | 44 +
.../core/graph/properties/DefaultProperties.java | 131 +++
.../computer/core/graph/properties/Properties.java | 43 +
.../computer/core/graph/value/BooleanValue.java | 111 +++
.../computer/core/graph/value/DoubleValue.java | 134 +++
.../computer/core/graph/value/FloatValue.java | 134 +++
.../computer/core/graph/value/IdList.java | 57 ++
.../computer/core/graph/value/IdListList.java | 47 ++
.../hugegraph/computer/core/graph/value/IdSet.java | 112 +++
.../computer/core/graph/value/IntValue.java | 134 +++
.../computer/core/graph/value/ListValue.java | 241 ++++++
.../computer/core/graph/value/LongValue.java | 134 +++
.../computer/core/graph/value/MapValue.java | 168 ++++
.../computer/core/graph/value/NullValue.java | 103 +++
.../computer/core/graph/value/StringValue.java | 104 +++
.../hugegraph/computer/core/graph/value/Value.java | 108 +++
.../computer/core/graph/value/ValueType.java | 72 ++
.../computer/core/graph/vertex/Vertex.java | 62 ++
.../hugegraph/computer/core/input/InputFilter.java | 34 +
.../hugegraph/computer/core/io/BytesInput.java | 23 +
.../hugegraph/computer/core/io/BytesOutput.java | 35 +
.../computer/core/io/GraphComputeInput.java | 38 +
.../computer/core/io/GraphComputeOutput.java | 39 +
.../hugegraph/computer/core/io/GraphInput.java | 23 +
.../hugegraph/computer/core/io/GraphOutput.java | 24 +
.../computer/core/io/GraphWritebackOutput.java | 38 +
.../computer/core/io/RandomAccessInput.java | 80 ++
.../computer/core/io/RandomAccessOutput.java | 69 ++
.../hugegraph/computer/core/io/Readable.java | 27 +
.../hugegraph/computer/core/io/Writable.java | 27 +
.../core/master/DefaultMasterComputation.java | 45 +
.../computer/core/master/MasterComputation.java | 55 ++
.../core/master/MasterComputationContext.java | 62 ++
.../computer/core/master/MasterContext.java | 28 +
.../core/output/AbstractComputerOutput.java | 54 ++
.../computer/core/output/ComputerOutput.java | 59 ++
.../computer/core/output/hg/HugeGraphOutput.java | 106 +++
.../output/hg/exceptions/WriteBackException.java | 41 +
.../core/output/hg/metrics/LoadMetrics.java | 49 ++
.../core/output/hg/metrics/LoadReport.java | 42 +
.../core/output/hg/metrics/LoadSummary.java | 73 ++
.../computer/core/output/hg/metrics/Printer.java | 58 ++
.../core/output/hg/task/BatchInsertTask.java | 103 +++
.../computer/core/output/hg/task/InsertTask.java | 81 ++
.../core/output/hg/task/SingleInsertTask.java | 62 ++
.../computer/core/output/hg/task/TaskManager.java | 187 ++++
.../hugegraph/computer/core/util/BytesUtil.java | 78 ++
.../hugegraph/computer/core/util/CoderUtil.java | 159 ++++
.../computer/core/worker/Computation.java | 103 +++
.../computer/core/worker/ComputationContext.java | 136 +++
.../computer/core/worker/FilterComputation.java | 113 +++
.../computer/core/worker/ReduceComputation.java | 99 +++
.../computer/core/worker/WorkerContext.java | 38 +
computer-core/pom.xml | 4 +-
.../computer/core/aggregator/Aggregators.java | 80 --
.../core/aggregator/DefaultAggregator.java | 171 ----
.../core/aggregator/MasterAggrManager.java | 157 ----
.../core/aggregator/RegisterAggregators.java | 75 --
.../core/aggregator/WorkerAggrManager.java | 157 ----
.../computer/core/allocator/DefaultAllocator.java | 83 --
.../computer/core/allocator/RecycleHandler.java | 37 -
.../hugegraph/computer/core/bsp/Bsp4Master.java | 223 -----
.../hugegraph/computer/core/bsp/Bsp4Worker.java | 259 ------
.../baidu/hugegraph/computer/core/bsp/BspBase.java | 136 ---
.../hugegraph/computer/core/bsp/BspClient.java | 78 --
.../hugegraph/computer/core/bsp/BspEvent.java | 56 --
.../hugegraph/computer/core/bsp/EtcdBspClient.java | 83 --
.../hugegraph/computer/core/bsp/EtcdClient.java | 484 -----------
.../core/combiner/AbstractPointerCombiner.java | 73 --
.../computer/core/combiner/EdgeValueCombiner.java | 34 -
.../core/combiner/MessageValueCombiner.java | 36 -
.../computer/core/combiner/PointerCombiner.java | 25 -
.../core/combiner/VertexValueCombiner.java | 67 --
.../computer/core/common/ContainerInfo.java | 137 ---
.../core/common/exception/IllegalArgException.java | 45 -
.../core/common/exception/ReadException.java | 41 -
.../core/common/exception/TransportException.java | 71 --
.../core/common/exception/WriteException.java | 41 -
.../computer/core/compute/ComputeManager.java | 207 -----
.../computer/core/compute/FileGraphPartition.java | 446 ----------
.../computer/core/compute/input/EdgesInput.java | 291 -------
.../computer/core/compute/input/MessageInput.java | 127 ---
.../core/compute/input/ReusablePointer.java | 106 ---
.../computer/core/compute/input/VertexInput.java | 89 --
.../computer/core/graph/BuiltinGraphFactory.java | 201 -----
.../computer/core/graph/SuperstepStat.java | 172 ----
.../computer/core/graph/edge/DefaultEdge.java | 120 ---
.../computer/core/graph/edge/DefaultEdges.java | 72 --
.../hugegraph/computer/core/graph/id/BytesId.java | 214 -----
.../core/graph/partition/HashPartitioner.java | 53 --
.../core/graph/partition/PartitionStat.java | 153 ----
.../computer/core/graph/partition/Partitioner.java | 41 -
.../computer/core/graph/vertex/DefaultVertex.java | 168 ----
.../hugegraph/computer/core/input/EdgeFetcher.java | 31 -
.../computer/core/input/ElementFetcher.java | 31 -
.../computer/core/input/GraphFetcher.java | 33 -
.../computer/core/input/HugeConverter.java | 102 ---
.../hugegraph/computer/core/input/IdUtil.java | 67 --
.../computer/core/input/InputSourceFactory.java | 57 --
.../hugegraph/computer/core/input/InputSplit.java | 69 --
.../computer/core/input/InputSplitFetcher.java | 42 -
.../computer/core/input/MasterInputHandler.java | 67 --
.../computer/core/input/MasterInputManager.java | 65 --
.../computer/core/input/VertexFetcher.java | 31 -
.../computer/core/input/WorkerInputManager.java | 97 ---
.../core/input/filter/DefaultInputFilter.java | 39 -
.../filter/ExtractAllPropertyInputFilter.java | 37 -
.../computer/core/input/hg/HugeEdgeFetcher.java | 48 --
.../computer/core/input/hg/HugeElementFetcher.java | 90 --
.../computer/core/input/hg/HugeGraphFetcher.java | 72 --
.../core/input/hg/HugeInputSplitFetcher.java | 82 --
.../computer/core/input/hg/HugeVertexFetcher.java | 49 --
.../core/input/loader/FileEdgeFetcher.java | 73 --
.../core/input/loader/FileElementFetcher.java | 142 ----
.../computer/core/input/loader/FileInputSplit.java | 86 --
.../core/input/loader/FileVertxFetcher.java | 58 --
.../input/loader/LoaderFileInputSplitFetcher.java | 210 -----
.../core/input/loader/LoaderGraphFetcher.java | 66 --
.../core/io/AbstractBufferedFileInput.java | 163 ----
.../core/io/AbstractBufferedFileOutput.java | 105 ---
.../computer/core/io/BufferedFileInput.java | 111 ---
.../computer/core/io/BufferedFileOutput.java | 101 ---
.../computer/core/io/BufferedStreamInput.java | 182 ----
.../computer/core/io/BufferedStreamOutput.java | 193 -----
.../computer/core/io/CsvStructGraphOutput.java | 140 ---
.../hugegraph/computer/core/io/IOFactory.java | 90 --
.../computer/core/io/JsonStructGraphOutput.java | 170 ----
.../computer/core/io/OptimizedBytesInput.java | 237 ------
.../computer/core/io/OptimizedBytesOutput.java | 215 -----
.../hugegraph/computer/core/io/OutputFormat.java | 29 -
.../computer/core/io/StreamGraphInput.java | 165 ----
.../computer/core/io/StreamGraphOutput.java | 144 ----
.../computer/core/io/StructGraphOutput.java | 118 ---
.../computer/core/io/StructRandomAccessOutput.java | 169 ----
.../computer/core/io/UnsafeBytesInput.java | 286 -------
.../computer/core/io/UnsafeBytesOutput.java | 269 ------
.../hugegraph/computer/core/manager/Manager.java | 78 --
.../hugegraph/computer/core/manager/Managers.java | 88 --
.../computer/core/master/MasterService.java | 491 -----------
.../computer/core/network/ClientFactory.java | 46 -
.../computer/core/network/ClientHandler.java | 29 -
.../computer/core/network/ConnectionId.java | 112 ---
.../computer/core/network/DataClientManager.java | 130 ---
.../computer/core/network/DataServerManager.java | 68 --
.../hugegraph/computer/core/network/IOMode.java | 30 -
.../computer/core/network/MessageHandler.java | 49 --
.../computer/core/network/TransportClient.java | 97 ---
.../computer/core/network/TransportConf.java | 216 -----
.../computer/core/network/TransportHandler.java | 44 -
.../computer/core/network/TransportProvider.java | 27 -
.../computer/core/network/TransportServer.java | 61 --
.../computer/core/network/TransportState.java | 30 -
.../computer/core/network/TransportUtil.java | 167 ----
.../core/network/buffer/FileRegionBuffer.java | 133 ---
.../computer/core/network/buffer/NettyBuffer.java | 77 --
.../core/network/buffer/NetworkBuffer.java | 75 --
.../computer/core/network/buffer/NioBuffer.java | 76 --
.../core/network/connection/ConnectionManager.java | 89 --
.../connection/TransportConnectionManager.java | 153 ----
.../core/network/message/AbstractMessage.java | 198 -----
.../computer/core/network/message/AckMessage.java | 46 -
.../computer/core/network/message/DataMessage.java | 71 --
.../computer/core/network/message/FailMessage.java | 88 --
.../core/network/message/FinishMessage.java | 44 -
.../computer/core/network/message/Message.java | 67 --
.../computer/core/network/message/MessageType.java | 74 --
.../computer/core/network/message/PingMessage.java | 40 -
.../computer/core/network/message/PongMessage.java | 40 -
.../core/network/message/RequestMessage.java | 27 -
.../core/network/message/ResponseMessage.java | 27 -
.../core/network/message/StartMessage.java | 46 -
.../core/network/netty/AbstractNettyHandler.java | 147 ----
.../core/network/netty/BufAllocatorFactory.java | 31 -
.../netty/ChannelFutureListenerOnWrite.java | 81 --
.../core/network/netty/HeartbeatHandler.java | 92 --
.../core/network/netty/NettyClientFactory.java | 231 -----
.../core/network/netty/NettyClientHandler.java | 118 ---
.../core/network/netty/NettyEventLoopUtil.java | 111 ---
.../computer/core/network/netty/NettyProtocol.java | 205 -----
.../core/network/netty/NettyServerHandler.java | 235 ------
.../core/network/netty/NettyTransportClient.java | 198 -----
.../core/network/netty/NettyTransportProvider.java | 44 -
.../core/network/netty/NettyTransportServer.java | 229 -----
.../core/network/netty/ServerIdleHandler.java | 61 --
.../core/network/netty/codec/FrameDecoder.java | 76 --
.../core/network/netty/codec/MessageDecoder.java | 99 ---
.../core/network/netty/codec/MessageEncoder.java | 92 --
.../network/netty/codec/PreciseFrameDecoder.java | 98 ---
.../core/network/session/ClientSession.java | 282 -------
.../core/network/session/ServerSession.java | 143 ----
.../core/network/session/TransportSession.java | 79 --
.../computer/core/output/LimitedLogOutput.java | 59 --
.../hugegraph/computer/core/output/LogOutput.java | 45 -
.../computer/core/output/hdfs/HdfsOutput.java | 178 ----
.../core/output/hdfs/HdfsOutputMerger.java | 91 --
.../core/output/hg/HugeGraphDoubleOutput.java | 32 -
.../core/output/hg/HugeGraphFloatOutput.java | 32 -
.../computer/core/output/hg/HugeGraphIdOutput.java | 39 -
.../core/output/hg/HugeGraphIntOutput.java | 32 -
.../core/output/hg/HugeGraphLongOutput.java | 32 -
.../core/output/hg/HugeGraphStringOutput.java | 32 -
.../computer/core/receiver/MessageRecvBuffers.java | 122 ---
.../computer/core/receiver/MessageRecvManager.java | 254 ------
.../core/receiver/MessageRecvPartition.java | 227 -----
.../core/receiver/MessageRecvPartitions.java | 116 ---
.../computer/core/receiver/MessageStat.java | 51 --
.../receiver/edge/EdgeMessageRecvPartition.java | 63 --
.../receiver/edge/EdgeMessageRecvPartitions.java | 41 -
.../message/ComputeMessageRecvPartition.java | 68 --
.../message/ComputeMessageRecvPartitions.java | 41 -
.../vertex/VertexMessageRecvPartition.java | 57 --
.../vertex/VertexMessageRecvPartitions.java | 42 -
.../computer/core/rpc/AggregateRpcService.java | 39 -
.../computer/core/rpc/InputSplitRpcService.java | 29 -
.../computer/core/rpc/MasterRpcManager.java | 75 --
.../computer/core/rpc/WorkerRpcManager.java | 72 --
.../computer/core/sender/MessageQueue.java | 60 --
.../computer/core/sender/MessageSendBuffers.java | 77 --
.../computer/core/sender/MessageSendManager.java | 297 -------
.../computer/core/sender/MessageSendPartition.java | 78 --
.../computer/core/sender/MessageSender.java | 42 -
.../hugegraph/computer/core/sender/MultiQueue.java | 87 --
.../computer/core/sender/QueuedMessage.java | 49 --
.../computer/core/sender/QueuedMessageSender.java | 306 -------
.../computer/core/sender/WriteBuffer.java | 97 ---
.../computer/core/sender/WriteBuffers.java | 135 ---
.../computer/core/sort/BufferFileSorter.java | 107 ---
.../computer/core/sort/DefaultSorter.java | 85 --
.../computer/core/sort/HgkvFileSorter.java | 110 ---
.../baidu/hugegraph/computer/core/sort/Sorter.java | 113 ---
.../core/sort/flusher/CombinableSorterFlusher.java | 69 --
.../sort/flusher/CombineKvInnerSortFlusher.java | 44 -
.../sort/flusher/CombineKvOuterSortFlusher.java | 49 --
.../sort/flusher/CombineSubKvInnerSortFlusher.java | 164 ----
.../sort/flusher/CombineSubKvOuterSortFlusher.java | 136 ---
.../core/sort/flusher/InnerSortFlusher.java | 52 --
.../core/sort/flusher/KvInnerSortFlusher.java | 52 --
.../core/sort/flusher/KvOuterSortFlusher.java | 42 -
.../core/sort/flusher/OuterSortFlusher.java | 56 --
.../core/sort/flusher/PeekableIterator.java | 65 --
.../core/sort/flusher/PeekableIteratorAdaptor.java | 77 --
.../computer/core/sort/merge/FileMerger.java | 42 -
.../computer/core/sort/merge/FileMergerImpl.java | 122 ---
.../computer/core/sort/sorter/InputSorter.java | 32 -
.../computer/core/sort/sorter/InputsSorter.java | 33 -
.../core/sort/sorter/InputsSorterImpl.java | 70 --
.../computer/core/sort/sorter/JavaInputSorter.java | 50 --
.../computer/core/sort/sorter/SubKvSorter.java | 132 ---
.../core/sort/sorting/AbstractInputsSorting.java | 49 --
.../core/sort/sorting/HeapInputsSorting.java | 132 ---
.../computer/core/sort/sorting/InputsSorting.java | 24 -
.../core/sort/sorting/LoserTreeInputsSorting.java | 148 ----
.../core/sort/sorting/RecvSortManager.java | 59 --
.../core/sort/sorting/SendSortManager.java | 43 -
.../computer/core/sort/sorting/SortManager.java | 232 -----
.../computer/core/sort/sorting/SortingFactory.java | 59 --
.../computer/core/sort/sorting/SortingMode.java | 29 -
.../computer/core/store/EntryIterator.java | 33 -
.../computer/core/store/FileGenerator.java | 68 --
.../hugegraph/computer/core/store/FileManager.java | 115 ---
.../computer/core/store/KvEntryFileReader.java | 24 -
.../computer/core/store/KvEntryFileWriter.java | 39 -
.../computer/core/store/StoreManager.java | 23 -
.../core/store/SuperstepFileGenerator.java | 52 --
.../computer/core/store/buffer/KvEntriesInput.java | 70 --
.../store/buffer/KvEntriesWithFirstSubKvInput.java | 53 --
.../core/store/buffer/SubKvEntriesInput.java | 75 --
.../computer/core/store/entry/AbstractKvEntry.java | 46 -
.../computer/core/store/entry/CachedPointer.java | 81 --
.../computer/core/store/entry/DefaultKvEntry.java | 39 -
.../computer/core/store/entry/EntriesUtil.java | 170 ----
.../computer/core/store/entry/EntryInput.java | 46 -
.../computer/core/store/entry/EntryInputImpl.java | 56 --
.../computer/core/store/entry/EntryOutput.java | 46 -
.../computer/core/store/entry/EntryOutputImpl.java | 67 --
.../computer/core/store/entry/InlinePointer.java | 80 --
.../computer/core/store/entry/KvEntry.java | 29 -
.../computer/core/store/entry/KvEntryReader.java | 31 -
.../core/store/entry/KvEntryReaderImpl.java | 61 --
.../core/store/entry/KvEntryWithFirstSubKv.java | 42 -
.../computer/core/store/entry/KvEntryWriter.java | 31 -
.../core/store/entry/KvEntryWriterImpl.java | 123 ---
.../computer/core/store/entry/Pointer.java | 34 -
.../hugegraph/computer/core/store/entry/Range.java | 27 -
.../file/bufferfile/BufferFileEntryBuilder.java | 58 --
.../file/bufferfile/BufferFileEntryReader.java | 89 --
.../file/bufferfile/BufferFileSubEntryReader.java | 83 --
.../core/store/file/hgkvfile/AbstractHgkvFile.java | 82 --
.../computer/core/store/file/hgkvfile/HgkvDir.java | 35 -
.../core/store/file/hgkvfile/HgkvDirImpl.java | 165 ----
.../core/store/file/hgkvfile/HgkvFile.java | 68 --
.../core/store/file/hgkvfile/HgkvFileImpl.java | 146 ----
.../store/file/hgkvfile/builder/BlockBuilder.java | 37 -
.../hgkvfile/builder/DataBlockBuilderImpl.java | 65 --
.../file/hgkvfile/builder/HgkvDirBuilderImpl.java | 110 ---
.../file/hgkvfile/builder/HgkvFileBuilder.java | 58 --
.../file/hgkvfile/builder/HgkvFileBuilderImpl.java | 174 ----
.../file/hgkvfile/builder/IndexBlockBuilder.java | 31 -
.../hgkvfile/builder/IndexBlockBuilderImpl.java | 52 --
.../hgkvfile/reader/HgkvDir4SubKvReaderImpl.java | 71 --
.../file/hgkvfile/reader/HgkvDirReaderImpl.java | 138 ---
.../file/hgkvfile/reader/HgkvFileReaderImpl.java | 110 ---
.../store/file/select/DefaultSelectedFiles.java | 45 -
.../store/file/select/DisperseEvenlySelector.java | 200 -----
.../core/store/file/select/InputFilesSelector.java | 41 -
.../core/store/file/select/SelectedFiles.java | 29 -
.../core/store/file/seqfile/BitsFileReader.java | 35 -
.../store/file/seqfile/BitsFileReaderImpl.java | 65 --
.../core/store/file/seqfile/BitsFileWriter.java | 44 -
.../store/file/seqfile/BitsFileWriterImpl.java | 75 --
.../core/store/file/seqfile/ValueFile.java | 80 --
.../core/store/file/seqfile/ValueFileInput.java | 205 -----
.../core/store/file/seqfile/ValueFileOutput.java | 194 -----
.../computer/core/util/ComputerContextUtil.java | 91 --
.../hugegraph/computer/core/util/Consumers.java | 217 -----
.../hugegraph/computer/core/util/FileUtil.java | 38 -
.../hugegraph/computer/core/util/JsonUtil.java | 64 --
.../computer/core/util/SerializeUtil.java | 86 --
.../hugegraph/computer/core/util/ShutdownHook.java | 61 --
.../computer/core/util/StringEncoding.java | 171 ----
.../computer/core/worker/WorkerService.java | 455 ----------
.../hugegraph/computer/core/worker/WorkerStat.java | 111 ---
.../computer/core/worker/load/LoadService.java | 233 -----
.../computer/core/aggregator/Aggregators.java | 81 ++
.../core/aggregator/DefaultAggregator.java | 171 ++++
.../core/aggregator/MasterAggrManager.java | 156 ++++
.../core/aggregator/RegisterAggregators.java | 75 ++
.../core/aggregator/WorkerAggrManager.java | 157 ++++
.../computer/core/allocator/DefaultAllocator.java | 83 ++
.../computer/core/allocator/RecycleHandler.java | 37 +
.../hugegraph/computer/core/bsp/Bsp4Master.java | 222 +++++
.../hugegraph/computer/core/bsp/Bsp4Worker.java | 258 ++++++
.../hugegraph/computer/core/bsp/BspBase.java | 135 +++
.../hugegraph/computer/core/bsp/BspClient.java | 78 ++
.../hugegraph/computer/core/bsp/BspEvent.java | 56 ++
.../hugegraph/computer/core/bsp/EtcdBspClient.java | 83 ++
.../hugegraph/computer/core/bsp/EtcdClient.java | 484 +++++++++++
.../core/combiner/AbstractPointerCombiner.java | 73 ++
.../computer/core/combiner/EdgeValueCombiner.java | 34 +
.../core/combiner/MessageValueCombiner.java | 36 +
.../computer/core/combiner/PointerCombiner.java | 25 +
.../core/combiner/VertexValueCombiner.java | 67 ++
.../computer/core/common/ContainerInfo.java | 137 +++
.../core/common/exception/IllegalArgException.java | 45 +
.../core/common/exception/ReadException.java | 41 +
.../core/common/exception/TransportException.java | 71 ++
.../core/common/exception/WriteException.java | 41 +
.../computer/core/compute/ComputeManager.java | 206 +++++
.../computer/core/compute/FileGraphPartition.java | 445 ++++++++++
.../computer/core/compute/input/EdgesInput.java | 291 +++++++
.../computer/core/compute/input/MessageInput.java | 127 +++
.../core/compute/input/ReusablePointer.java | 106 +++
.../computer/core/compute/input/VertexInput.java | 89 ++
.../computer/core/graph/BuiltinGraphFactory.java | 201 +++++
.../computer/core/graph/SuperstepStat.java | 172 ++++
.../computer/core/graph/edge/DefaultEdge.java | 120 +++
.../computer/core/graph/edge/DefaultEdges.java | 72 ++
.../hugegraph/computer/core/graph/id/BytesId.java | 214 +++++
.../core/graph/partition/HashPartitioner.java | 53 ++
.../core/graph/partition/PartitionStat.java | 153 ++++
.../computer/core/graph/partition/Partitioner.java | 41 +
.../computer/core/graph/vertex/DefaultVertex.java | 168 ++++
.../hugegraph/computer/core/input/EdgeFetcher.java | 31 +
.../computer/core/input/ElementFetcher.java | 31 +
.../computer/core/input/GraphFetcher.java | 33 +
.../computer/core/input/HugeConverter.java | 101 +++
.../hugegraph/computer/core/input/IdUtil.java | 68 ++
.../computer/core/input/InputSourceFactory.java | 57 ++
.../hugegraph/computer/core/input/InputSplit.java | 69 ++
.../computer/core/input/InputSplitFetcher.java | 42 +
.../computer/core/input/MasterInputHandler.java | 67 ++
.../computer/core/input/MasterInputManager.java | 64 ++
.../computer/core/input/VertexFetcher.java | 31 +
.../computer/core/input/WorkerInputManager.java | 97 +++
.../core/input/filter/DefaultInputFilter.java | 39 +
.../filter/ExtractAllPropertyInputFilter.java | 37 +
.../computer/core/input/hg/HugeEdgeFetcher.java | 48 ++
.../computer/core/input/hg/HugeElementFetcher.java | 90 ++
.../computer/core/input/hg/HugeGraphFetcher.java | 72 ++
.../core/input/hg/HugeInputSplitFetcher.java | 82 ++
.../computer/core/input/hg/HugeVertexFetcher.java | 49 ++
.../core/input/loader/FileEdgeFetcher.java | 73 ++
.../core/input/loader/FileElementFetcher.java | 141 ++++
.../computer/core/input/loader/FileInputSplit.java | 86 ++
.../core/input/loader/FileVertxFetcher.java | 58 ++
.../input/loader/LoaderFileInputSplitFetcher.java | 209 +++++
.../core/input/loader/LoaderGraphFetcher.java | 66 ++
.../core/io/AbstractBufferedFileInput.java | 163 ++++
.../core/io/AbstractBufferedFileOutput.java | 105 +++
.../computer/core/io/BufferedFileInput.java | 111 +++
.../computer/core/io/BufferedFileOutput.java | 101 +++
.../computer/core/io/BufferedStreamInput.java | 182 ++++
.../computer/core/io/BufferedStreamOutput.java | 193 +++++
.../computer/core/io/CsvStructGraphOutput.java | 140 +++
.../hugegraph/computer/core/io/IOFactory.java | 90 ++
.../computer/core/io/JsonStructGraphOutput.java | 170 ++++
.../computer/core/io/OptimizedBytesInput.java | 237 ++++++
.../computer/core/io/OptimizedBytesOutput.java | 215 +++++
.../hugegraph/computer/core/io/OutputFormat.java | 29 +
.../computer/core/io/StreamGraphInput.java | 164 ++++
.../computer/core/io/StreamGraphOutput.java | 144 ++++
.../computer/core/io/StructGraphOutput.java | 118 +++
.../computer/core/io/StructRandomAccessOutput.java | 168 ++++
.../computer/core/io/UnsafeBytesInput.java | 286 +++++++
.../computer/core/io/UnsafeBytesOutput.java | 269 ++++++
.../hugegraph/computer/core/manager/Manager.java | 78 ++
.../hugegraph/computer/core/manager/Managers.java | 88 ++
.../computer/core/master/MasterService.java | 490 +++++++++++
.../computer/core/network/ClientFactory.java | 46 +
.../computer/core/network/ClientHandler.java | 29 +
.../computer/core/network/ConnectionId.java | 112 +++
.../computer/core/network/DataClientManager.java | 129 +++
.../computer/core/network/DataServerManager.java | 67 ++
.../hugegraph/computer/core/network/IOMode.java | 30 +
.../computer/core/network/MessageHandler.java | 49 ++
.../computer/core/network/TransportClient.java | 97 +++
.../computer/core/network/TransportConf.java | 215 +++++
.../computer/core/network/TransportHandler.java | 44 +
.../computer/core/network/TransportProvider.java | 27 +
.../computer/core/network/TransportServer.java | 61 ++
.../computer/core/network/TransportState.java | 30 +
.../computer/core/network/TransportUtil.java | 169 ++++
.../core/network/buffer/FileRegionBuffer.java | 133 +++
.../computer/core/network/buffer/NettyBuffer.java | 77 ++
.../core/network/buffer/NetworkBuffer.java | 75 ++
.../computer/core/network/buffer/NioBuffer.java | 76 ++
.../core/network/connection/ConnectionManager.java | 89 ++
.../connection/TransportConnectionManager.java | 153 ++++
.../core/network/message/AbstractMessage.java | 197 +++++
.../computer/core/network/message/AckMessage.java | 46 +
.../computer/core/network/message/DataMessage.java | 71 ++
.../computer/core/network/message/FailMessage.java | 88 ++
.../core/network/message/FinishMessage.java | 44 +
.../computer/core/network/message/Message.java | 67 ++
.../computer/core/network/message/MessageType.java | 74 ++
.../computer/core/network/message/PingMessage.java | 40 +
.../computer/core/network/message/PongMessage.java | 40 +
.../core/network/message/RequestMessage.java | 27 +
.../core/network/message/ResponseMessage.java | 27 +
.../core/network/message/StartMessage.java | 46 +
.../core/network/netty/AbstractNettyHandler.java | 146 ++++
.../core/network/netty/BufAllocatorFactory.java | 31 +
.../netty/ChannelFutureListenerOnWrite.java | 80 ++
.../core/network/netty/HeartbeatHandler.java | 91 ++
.../core/network/netty/NettyClientFactory.java | 230 +++++
.../core/network/netty/NettyClientHandler.java | 118 +++
.../core/network/netty/NettyEventLoopUtil.java | 111 +++
.../computer/core/network/netty/NettyProtocol.java | 205 +++++
.../core/network/netty/NettyServerHandler.java | 237 ++++++
.../core/network/netty/NettyTransportClient.java | 198 +++++
.../core/network/netty/NettyTransportProvider.java | 44 +
.../core/network/netty/NettyTransportServer.java | 228 +++++
.../core/network/netty/ServerIdleHandler.java | 61 ++
.../core/network/netty/codec/FrameDecoder.java | 75 ++
.../core/network/netty/codec/MessageDecoder.java | 99 +++
.../core/network/netty/codec/MessageEncoder.java | 92 ++
.../network/netty/codec/PreciseFrameDecoder.java | 100 +++
.../core/network/session/ClientSession.java | 281 ++++++
.../core/network/session/ServerSession.java | 143 ++++
.../core/network/session/TransportSession.java | 79 ++
.../computer/core/output/LimitedLogOutput.java | 58 ++
.../hugegraph/computer/core/output/LogOutput.java | 44 +
.../computer/core/output/hdfs/HdfsOutput.java | 176 ++++
.../core/output/hdfs/HdfsOutputMerger.java | 90 ++
.../core/output/hg/HugeGraphDoubleOutput.java | 32 +
.../core/output/hg/HugeGraphFloatOutput.java | 32 +
.../computer/core/output/hg/HugeGraphIdOutput.java | 39 +
.../core/output/hg/HugeGraphIntOutput.java | 32 +
.../core/output/hg/HugeGraphLongOutput.java | 32 +
.../core/output/hg/HugeGraphStringOutput.java | 32 +
.../computer/core/receiver/MessageRecvBuffers.java | 122 +++
.../computer/core/receiver/MessageRecvManager.java | 253 ++++++
.../core/receiver/MessageRecvPartition.java | 228 +++++
.../core/receiver/MessageRecvPartitions.java | 115 +++
.../computer/core/receiver/MessageStat.java | 51 ++
.../receiver/edge/EdgeMessageRecvPartition.java | 63 ++
.../receiver/edge/EdgeMessageRecvPartitions.java | 41 +
.../message/ComputeMessageRecvPartition.java | 68 ++
.../message/ComputeMessageRecvPartitions.java | 41 +
.../vertex/VertexMessageRecvPartition.java | 57 ++
.../vertex/VertexMessageRecvPartitions.java | 42 +
.../computer/core/rpc/AggregateRpcService.java | 39 +
.../computer/core/rpc/InputSplitRpcService.java | 29 +
.../computer/core/rpc/MasterRpcManager.java | 75 ++
.../computer/core/rpc/WorkerRpcManager.java | 72 ++
.../computer/core/sender/MessageQueue.java | 60 ++
.../computer/core/sender/MessageSendBuffers.java | 77 ++
.../computer/core/sender/MessageSendManager.java | 296 +++++++
.../computer/core/sender/MessageSendPartition.java | 78 ++
.../computer/core/sender/MessageSender.java | 42 +
.../hugegraph/computer/core/sender/MultiQueue.java | 87 ++
.../computer/core/sender/QueuedMessage.java | 49 ++
.../computer/core/sender/QueuedMessageSender.java | 305 +++++++
.../computer/core/sender/WriteBuffer.java | 97 +++
.../computer/core/sender/WriteBuffers.java | 135 +++
.../computer/core/sort/BufferFileSorter.java | 107 +++
.../computer/core/sort/DefaultSorter.java | 85 ++
.../computer/core/sort/HgkvFileSorter.java | 110 +++
.../hugegraph/computer/core/sort/Sorter.java | 113 +++
.../core/sort/flusher/CombinableSorterFlusher.java | 69 ++
.../sort/flusher/CombineKvInnerSortFlusher.java | 44 +
.../sort/flusher/CombineKvOuterSortFlusher.java | 49 ++
.../sort/flusher/CombineSubKvInnerSortFlusher.java | 164 ++++
.../sort/flusher/CombineSubKvOuterSortFlusher.java | 136 +++
.../core/sort/flusher/InnerSortFlusher.java | 51 ++
.../core/sort/flusher/KvInnerSortFlusher.java | 52 ++
.../core/sort/flusher/KvOuterSortFlusher.java | 42 +
.../core/sort/flusher/OuterSortFlusher.java | 55 ++
.../core/sort/flusher/PeekableIterator.java | 65 ++
.../core/sort/flusher/PeekableIteratorAdaptor.java | 77 ++
.../computer/core/sort/merge/FileMerger.java | 42 +
.../computer/core/sort/merge/FileMergerImpl.java | 122 +++
.../computer/core/sort/sorter/InputSorter.java | 33 +
.../computer/core/sort/sorter/InputsSorter.java | 33 +
.../core/sort/sorter/InputsSorterImpl.java | 70 ++
.../computer/core/sort/sorter/JavaInputSorter.java | 50 ++
.../computer/core/sort/sorter/SubKvSorter.java | 132 +++
.../core/sort/sorting/AbstractInputsSorting.java | 49 ++
.../core/sort/sorting/HeapInputsSorting.java | 132 +++
.../computer/core/sort/sorting/InputsSorting.java | 24 +
.../core/sort/sorting/LoserTreeInputsSorting.java | 148 ++++
.../core/sort/sorting/RecvSortManager.java | 59 ++
.../core/sort/sorting/SendSortManager.java | 43 +
.../computer/core/sort/sorting/SortManager.java | 231 +++++
.../computer/core/sort/sorting/SortingFactory.java | 59 ++
.../computer/core/sort/sorting/SortingMode.java | 29 +
.../computer/core/store/EntryIterator.java | 32 +
.../computer/core/store/FileGenerator.java | 68 ++
.../hugegraph/computer/core/store/FileManager.java | 114 +++
.../computer/core/store/KvEntryFileReader.java | 24 +
.../computer/core/store/KvEntryFileWriter.java | 39 +
.../computer/core/store/StoreManager.java | 23 +
.../core/store/SuperstepFileGenerator.java | 52 ++
.../computer/core/store/buffer/KvEntriesInput.java | 70 ++
.../store/buffer/KvEntriesWithFirstSubKvInput.java | 53 ++
.../core/store/buffer/SubKvEntriesInput.java | 75 ++
.../computer/core/store/entry/AbstractKvEntry.java | 46 +
.../computer/core/store/entry/CachedPointer.java | 81 ++
.../computer/core/store/entry/DefaultKvEntry.java | 39 +
.../computer/core/store/entry/EntriesUtil.java | 170 ++++
.../computer/core/store/entry/EntryInput.java | 46 +
.../computer/core/store/entry/EntryInputImpl.java | 56 ++
.../computer/core/store/entry/EntryOutput.java | 46 +
.../computer/core/store/entry/EntryOutputImpl.java | 67 ++
.../computer/core/store/entry/InlinePointer.java | 80 ++
.../computer/core/store/entry/KvEntry.java | 29 +
.../computer/core/store/entry/KvEntryReader.java | 31 +
.../core/store/entry/KvEntryReaderImpl.java | 61 ++
.../core/store/entry/KvEntryWithFirstSubKv.java | 42 +
.../computer/core/store/entry/KvEntryWriter.java | 31 +
.../core/store/entry/KvEntryWriterImpl.java | 123 +++
.../computer/core/store/entry/Pointer.java | 34 +
.../hugegraph/computer/core/store/entry/Range.java | 27 +
.../file/bufferfile/BufferFileEntryBuilder.java | 58 ++
.../file/bufferfile/BufferFileEntryReader.java | 89 ++
.../file/bufferfile/BufferFileSubEntryReader.java | 83 ++
.../core/store/file/hgkvfile/AbstractHgkvFile.java | 82 ++
.../computer/core/store/file/hgkvfile/HgkvDir.java | 35 +
.../core/store/file/hgkvfile/HgkvDirImpl.java | 165 ++++
.../core/store/file/hgkvfile/HgkvFile.java | 68 ++
.../core/store/file/hgkvfile/HgkvFileImpl.java | 146 ++++
.../store/file/hgkvfile/builder/BlockBuilder.java | 37 +
.../hgkvfile/builder/DataBlockBuilderImpl.java | 65 ++
.../file/hgkvfile/builder/HgkvDirBuilderImpl.java | 109 +++
.../file/hgkvfile/builder/HgkvFileBuilder.java | 58 ++
.../file/hgkvfile/builder/HgkvFileBuilderImpl.java | 174 ++++
.../file/hgkvfile/builder/IndexBlockBuilder.java | 31 +
.../hgkvfile/builder/IndexBlockBuilderImpl.java | 52 ++
.../hgkvfile/reader/HgkvDir4SubKvReaderImpl.java | 71 ++
.../file/hgkvfile/reader/HgkvDirReaderImpl.java | 138 +++
.../file/hgkvfile/reader/HgkvFileReaderImpl.java | 110 +++
.../store/file/select/DefaultSelectedFiles.java | 45 +
.../store/file/select/DisperseEvenlySelector.java | 201 +++++
.../core/store/file/select/InputFilesSelector.java | 41 +
.../core/store/file/select/SelectedFiles.java | 29 +
.../core/store/file/seqfile/BitsFileReader.java | 35 +
.../store/file/seqfile/BitsFileReaderImpl.java | 66 ++
.../core/store/file/seqfile/BitsFileWriter.java | 44 +
.../store/file/seqfile/BitsFileWriterImpl.java | 76 ++
.../core/store/file/seqfile/ValueFile.java | 81 ++
.../core/store/file/seqfile/ValueFileInput.java | 204 +++++
.../core/store/file/seqfile/ValueFileOutput.java | 194 +++++
.../computer/core/util/ComputerContextUtil.java | 91 ++
.../hugegraph/computer/core/util/Consumers.java | 216 +++++
.../hugegraph/computer/core/util/FileUtil.java | 38 +
.../hugegraph/computer/core/util/JsonUtil.java | 65 ++
.../computer/core/util/SerializeUtil.java | 86 ++
.../hugegraph/computer/core/util/ShutdownHook.java | 61 ++
.../computer/core/util/StringEncoding.java | 172 ++++
.../computer/core/worker/WorkerService.java | 454 ++++++++++
.../hugegraph/computer/core/worker/WorkerStat.java | 111 +++
.../computer/core/worker/load/LoadService.java | 233 +++++
computer-dist/pom.xml | 4 +-
.../src/assembly/static/bin/start-computer.sh | 2 +-
.../src/assembly/static/conf/computer.properties | 2 +-
computer-dist/src/assembly/static/conf/log4j2.xml | 2 +-
.../hugegraph/computer/dist/HugeGraphComputer.java | 153 ----
.../hugegraph/computer/dist/HugeGraphComputer.java | 152 ++++
computer-driver/pom.xml | 4 +-
.../hugegraph/computer/driver/ComputerDriver.java | 106 ---
.../computer/driver/ComputerDriverException.java | 57 --
.../hugegraph/computer/driver/DefaultJobState.java | 92 --
.../hugegraph/computer/driver/JobObserver.java | 28 -
.../baidu/hugegraph/computer/driver/JobState.java | 45 -
.../baidu/hugegraph/computer/driver/JobStatus.java | 41 -
.../hugegraph/computer/driver/SuperstepStat.java | 122 ---
.../computer/driver/config/DriverConfigOption.java | 75 --
.../hugegraph/computer/driver/util/JsonUtil.java | 60 --
.../hugegraph/computer/driver/ComputerDriver.java | 106 +++
.../computer/driver/ComputerDriverException.java | 57 ++
.../hugegraph/computer/driver/DefaultJobState.java | 92 ++
.../hugegraph/computer/driver/JobObserver.java | 28 +
.../apache/hugegraph/computer/driver/JobState.java | 44 +
.../hugegraph/computer/driver/JobStatus.java | 41 +
.../hugegraph/computer/driver/SuperstepStat.java | 122 +++
.../computer/driver/config/DriverConfigOption.java | 75 ++
.../hugegraph/computer/driver/util/JsonUtil.java | 61 ++
computer-k8s-operator/README.md | 6 +-
computer-k8s-operator/crd-generate/Makefile | 4 +-
.../crd-generate/api/v1/groupversion_info.go | 28 +-
.../api/v1/hugegraphcomputerjob_types.go | 162 ++--
computer-k8s-operator/crd-generate/cmd/generate.go | 146 ++--
.../crd-generate/config/crd/kustomization.yaml | 4 +-
.../crd-generate/config/rbac/role.yaml | 6 +-
computer-k8s-operator/crd-generate/go.mod | 2 +-
computer-k8s-operator/crd-generate/go.sum | 2 +
.../manifest/hugegraph-computer-crd.v1.yaml | 4 +-
.../manifest/hugegraph-computer-crd.v1beta1.yaml | 4 +-
.../manifest/hugegraph-computer-operator.yaml | 6 +-
computer-k8s-operator/pom.xml | 6 +-
.../computer/k8s/operator/OperatorEntrypoint.java | 254 ------
.../k8s/operator/common/AbstractController.java | 440 ----------
.../computer/k8s/operator/common/MatchWithMsg.java | 41 -
.../k8s/operator/common/OperatorRequest.java | 114 ---
.../k8s/operator/common/OperatorResult.java | 60 --
.../computer/k8s/operator/common/WorkQueue.java | 120 ---
.../k8s/operator/config/OperatorOptions.java | 147 ----
.../operator/controller/ComputerJobComponent.java | 86 --
.../operator/controller/ComputerJobController.java | 564 -------------
.../operator/controller/ComputerJobDeployer.java | 648 --------------
.../computer/k8s/operator/OperatorEntrypoint.java | 254 ++++++
.../k8s/operator/common/AbstractController.java | 440 ++++++++++
.../computer/k8s/operator/common/MatchWithMsg.java | 41 +
.../k8s/operator/common/OperatorRequest.java | 113 +++
.../k8s/operator/common/OperatorResult.java | 60 ++
.../computer/k8s/operator/common/WorkQueue.java | 120 +++
.../k8s/operator/config/OperatorOptions.java | 147 ++++
.../operator/controller/ComputerJobComponent.java | 86 ++
.../operator/controller/ComputerJobController.java | 564 +++++++++++++
.../operator/controller/ComputerJobDeployer.java | 648 ++++++++++++++
.../src/main/resources/log4j2.xml | 2 +-
computer-k8s/pom.xml | 14 +-
computer-k8s/schema/crd-schema.json | 108 +--
computer-k8s/schema/enum-schema.json | 16 +-
.../baidu/hugegraph/computer/k8s/Constants.java | 67 --
.../computer/k8s/config/KubeDriverOptions.java | 160 ----
.../computer/k8s/config/KubeSpecOptions.java | 214 -----
.../k8s/crd/model/HugeGraphComputerJob.java | 62 --
.../k8s/crd/model/HugeGraphComputerJobList.java | 28 -
.../computer/k8s/driver/KubernetesDriver.java | 578 -------------
.../hugegraph/computer/k8s/util/KubeUtil.java | 281 ------
.../apache/hugegraph/computer/k8s/Constants.java | 67 ++
.../computer/k8s/config/KubeDriverOptions.java | 159 ++++
.../computer/k8s/config/KubeSpecOptions.java | 215 +++++
.../k8s/crd/model/HugeGraphComputerJob.java | 62 ++
.../k8s/crd/model/HugeGraphComputerJobList.java | 28 +
.../computer/k8s/driver/KubernetesDriver.java | 577 +++++++++++++
.../hugegraph/computer/k8s/util/KubeUtil.java | 280 ++++++
computer-test/conf/log4j2-test.xml | 2 +-
computer-test/pom.xml | 18 +-
.../computer/algorithm/AlgorithmTestBase.java | 152 ----
.../computer/algorithm/AlgorithmTestSuite.java | 52 --
.../betweenness/BetweennessCentralityTest.java | 146 ----
.../closeness/ClosenessCentralityTest.java | 165 ----
.../centrality/degree/DegreeCentralityTest.java | 102 ---
.../centrality/pagerank/PageRankTest.java | 32 -
.../community/cc/ClusteringCoefficientTest.java | 133 ---
.../algorithm/community/kcore/KcoreTest.java | 32 -
.../computer/algorithm/community/lpa/LpaTest.java | 32 -
.../community/trianglecount/TriangleCountTest.java | 134 ---
.../computer/algorithm/community/wcc/WccTest.java | 38 -
.../algorithm/path/rings/RingsDetectionTest.java | 136 ---
.../path/rings/RingsDetectionWithFilterTest.java | 136 ---
.../core/allocator/AllocatorTestSuite.java | 31 -
.../core/allocator/DefaultAllocatorTest.java | 168 ----
.../computer/core/allocator/RecyclersTest.java | 180 ----
.../hugegraph/computer/core/bsp/BspEventTest.java | 45 -
.../hugegraph/computer/core/bsp/BspTestSuite.java | 31 -
.../hugegraph/computer/core/bsp/EtcdBspTest.java | 190 -----
.../computer/core/bsp/EtcdClientTest.java | 268 ------
.../computer/core/combiner/CombinerTestSuite.java | 39 -
.../core/combiner/DoubleValueSumCombinerTest.java | 66 --
.../core/combiner/FloatValueSumCombinerTest.java | 66 --
.../core/combiner/IntValueSumCombinerTest.java | 66 --
.../core/combiner/LongValueSumCombinerTest.java | 66 --
.../combiner/MergeNewPropertiesCombinerTest.java | 85 --
.../combiner/MergeOldPropertiesCombinerTest.java | 85 --
.../core/combiner/OverwriteCombinerTest.java | 67 --
.../core/combiner/PointerCombinerTest.java | 176 ----
.../core/combiner/ValueMaxCombinerTest.java | 66 --
.../core/combiner/ValueMinCombinerTest.java | 59 --
.../computer/core/common/CommonTestSuite.java | 31 -
.../computer/core/common/ContainerInfoTest.java | 73 --
.../computer/core/common/ExceptionTest.java | 77 --
.../core/common/FakeMasterComputation.java | 48 --
.../computer/core/compute/ComputeManagerTest.java | 235 ------
.../computer/core/compute/ComputeTestSuite.java | 37 -
.../computer/core/compute/MockComputation.java | 85 --
.../computer/core/compute/MockMessageSender.java | 41 -
.../core/compute/input/EdgesInputTest.java | 285 -------
.../core/compute/input/MessageInputTest.java | 177 ----
.../core/compute/input/ResuablePointerTest.java | 55 --
.../computer/core/config/ConfigTestSuite.java | 30 -
.../computer/core/config/DefaultConfigTest.java | 190 -----
.../core/graph/BuiltinGraphFactoryTest.java | 105 ---
.../computer/core/graph/DefaultEdgeTest.java | 91 --
.../computer/core/graph/DefaultPropertiesTest.java | 97 ---
.../computer/core/graph/GraphTestSuite.java | 71 --
.../computer/core/graph/SuperstepStatTest.java | 165 ----
.../computer/core/graph/id/BytesIdTest.java | 180 ----
.../computer/core/graph/id/IdFactoryTest.java | 57 --
.../computer/core/graph/id/IdTypeTest.java | 52 --
.../core/graph/partition/HashPartitionerTest.java | 211 -----
.../core/graph/partition/PartitionStatTest.java | 151 ----
.../core/graph/value/BooleanValueTest.java | 192 -----
.../computer/core/graph/value/DoubleValueTest.java | 253 ------
.../computer/core/graph/value/FloatValueTest.java | 227 -----
.../computer/core/graph/value/IdListListTest.java | 103 ---
.../computer/core/graph/value/IdValueListTest.java | 87 --
.../computer/core/graph/value/IdValueTest.java | 219 -----
.../computer/core/graph/value/IntValueTest.java | 259 ------
.../computer/core/graph/value/ListValueTest.java | 432 ----------
.../computer/core/graph/value/LongValueTest.java | 225 -----
.../computer/core/graph/value/NullValueTest.java | 152 ----
.../computer/core/graph/value/StringValueTest.java | 161 ----
.../computer/core/graph/value/ValueTypeTest.java | 64 --
.../computer/core/input/FileInputSplitTest.java | 68 --
.../computer/core/input/HugeConverterTest.java | 131 ---
.../computer/core/input/InputSplitDataTest.java | 100 ---
.../computer/core/input/InputSplitTest.java | 54 --
.../computer/core/input/InputTestSuite.java | 33 -
.../core/input/MockMasterInputManager.java | 60 --
.../computer/core/input/MockRpcClient.java | 41 -
.../core/input/MockWorkerInputManager.java | 116 ---
.../computer/core/io/BufferedFileTest.java | 754 -----------------
.../computer/core/io/BufferedStreamTest.java | 410 ---------
.../computer/core/io/CsvStructGraphOutputTest.java | 166 ----
.../hugegraph/computer/core/io/IOTestSuite.java | 38 -
.../core/io/JsonStructGraphOutputTest.java | 177 ----
.../computer/core/io/MockRankComputation.java | 52 --
.../computer/core/io/OptimizedUnsafeBytesTest.java | 192 -----
.../core/io/StreamGraphOutputInputTest.java | 271 ------
.../core/io/StructRandomAccessOutputTest.java | 248 ------
.../computer/core/io/UnsafeBytesTest.java | 613 --------------
.../computer/core/network/ConnectionIdTest.java | 78 --
.../core/network/DataServerManagerTest.java | 82 --
.../computer/core/network/MockClientHandler.java | 53 --
.../computer/core/network/MockMessageHandler.java | 89 --
.../computer/core/network/MockUnDecodeMessage.java | 49 --
.../computer/core/network/NetworkTestSuite.java | 49 --
.../computer/core/network/TransportUtilTest.java | 129 ---
.../core/network/buffer/NetworkBufferTest.java | 157 ----
.../network/connection/ConnectionManagerTest.java | 147 ----
.../core/network/netty/AbstractNetworkTest.java | 145 ----
.../core/network/netty/HeartbeatHandlerTest.java | 136 ---
.../core/network/netty/NettyClientFactoryTest.java | 136 ---
.../netty/NettyEncodeDecodeHandlerTest.java | 171 ----
.../network/netty/NettyTransportClientTest.java | 380 ---------
.../network/netty/NettyTransportServerTest.java | 245 ------
.../core/network/session/TransportSessionTest.java | 344 --------
.../core/receiver/MessageRecvBuffersTest.java | 187 ----
.../core/receiver/MessageRecvManagerTest.java | 165 ----
.../computer/core/receiver/ReceiverTestSuite.java | 38 -
.../computer/core/receiver/ReceiverUtil.java | 82 --
.../edge/EdgeMessageRecvPartitionTest.java | 280 ------
.../message/ComputeMessageRecvPartitionTest.java | 191 -----
.../vertex/VertexMessageRecvPartitionTest.java | 279 ------
.../computer/core/sender/MessageQueueTest.java | 66 --
.../core/sender/MessageSendBuffersTest.java | 66 --
.../core/sender/MessageSendManagerTest.java | 30 -
.../computer/core/sender/MockTransportClient.java | 94 ---
.../computer/core/sender/MultiQueueTest.java | 249 ------
.../core/sender/QueuedMessageSenderTest.java | 69 --
.../computer/core/sender/QueuedMessageTest.java | 39 -
.../computer/core/sender/SenderTestSuite.java | 37 -
.../computer/core/sender/WriteBufferTest.java | 194 -----
.../computer/core/sender/WriteBuffersTest.java | 262 ------
.../computer/core/sort/SorterTestUtil.java | 178 ----
.../core/sort/combiner/MockIntSumCombiner.java | 31 -
.../core/sort/sorter/EmptyFlusherTest.java | 50 --
.../computer/core/sort/sorter/FlusherTest.java | 157 ----
.../core/sort/sorter/SortLargeDataTest.java | 333 --------
.../computer/core/sort/sorter/SorterTest.java | 491 -----------
.../computer/core/sort/sorter/SorterTestSuite.java | 33 -
.../core/sort/sorting/InputsSortingTest.java | 75 --
.../core/sort/sorting/SortingTestSuite.java | 31 -
.../computer/core/sort/sorting/TestData.java | 142 ----
.../hugegraph/computer/core/store/BitFileTest.java | 95 ---
.../computer/core/store/EntriesUtilTest.java | 116 ---
.../computer/core/store/EntryOutputTest.java | 185 ----
.../computer/core/store/FileManagerTest.java | 110 ---
.../hugegraph/computer/core/store/HgkvDirTest.java | 146 ----
.../computer/core/store/HgkvFileTest.java | 157 ----
.../hugegraph/computer/core/store/PointerTest.java | 94 ---
.../computer/core/store/StoreTestSuite.java | 37 -
.../computer/core/store/StoreTestUtil.java | 187 ----
.../computer/core/store/ValueFileTest.java | 492 -----------
.../core/util/ComputerContextUtilTest.java | 74 --
.../hugegraph/computer/core/util/JsonUtilTest.java | 54 --
.../computer/core/util/SerializeUtilTest.java | 56 --
.../computer/core/util/UtilTestSuite.java | 32 -
.../computer/core/worker/MockComputation.java | 407 ---------
.../computer/core/worker/MockComputation2.java | 57 --
.../core/worker/MockComputationParams.java | 47 --
.../core/worker/MockMasterComputation.java | 391 ---------
.../core/worker/MockMasterComputation2.java | 96 ---
.../computer/core/worker/MockWorkerService.java | 33 -
.../computer/core/worker/WorkerServiceTest.java | 269 ------
.../computer/core/worker/WorkerStatTest.java | 118 ---
.../computer/core/worker/WorkerTestSuite.java | 31 -
.../computer/dist/ComputerDistTestSuite.java | 29 -
.../computer/dist/HugeGraphComputerTest.java | 106 ---
.../computer/driver/ComputerOptionsTest.java | 91 --
.../hugegraph/computer/driver/DriverTest.java | 88 --
.../hugegraph/computer/driver/DriverTestSuite.java | 31 -
.../hugegraph/computer/k8s/AbstractK8sTest.java | 216 -----
.../baidu/hugegraph/computer/k8s/K8sTestSuite.java | 32 -
.../computer/k8s/KubernetesDriverTest.java | 321 -------
.../baidu/hugegraph/computer/k8s/MiniKubeTest.java | 446 ----------
.../baidu/hugegraph/computer/k8s/OperatorTest.java | 59 --
.../suite/integrate/IntegrateTestSuite.java | 57 --
.../computer/suite/integrate/MockComputation.java | 51 --
.../suite/integrate/SenderIntegrateTest.java | 431 ----------
.../computer/suite/unit/UnitTestBase.java | 297 -------
.../computer/suite/unit/UnitTestSuite.java | 71 --
.../computer/algorithm/AlgorithmTestBase.java | 151 ++++
.../computer/algorithm/AlgorithmTestSuite.java | 51 ++
.../betweenness/BetweennessCentralityTest.java | 144 ++++
.../closeness/ClosenessCentralityTest.java | 165 ++++
.../centrality/degree/DegreeCentralityTest.java | 102 +++
.../centrality/pagerank/PageRankTest.java | 31 +
.../community/cc/ClusteringCoefficientTest.java | 133 +++
.../algorithm/community/kcore/KcoreTest.java | 31 +
.../computer/algorithm/community/lpa/LpaTest.java | 31 +
.../community/trianglecount/TriangleCountTest.java | 134 +++
.../computer/algorithm/community/wcc/WccTest.java | 37 +
.../algorithm/path/rings/RingsDetectionTest.java | 136 +++
.../path/rings/RingsDetectionWithFilterTest.java | 136 +++
.../core/allocator/AllocatorTestSuite.java | 31 +
.../core/allocator/DefaultAllocatorTest.java | 167 ++++
.../computer/core/allocator/RecyclersTest.java | 179 ++++
.../hugegraph/computer/core/bsp/BspEventTest.java | 44 +
.../hugegraph/computer/core/bsp/BspTestSuite.java | 31 +
.../hugegraph/computer/core/bsp/EtcdBspTest.java | 189 +++++
.../computer/core/bsp/EtcdClientTest.java | 267 ++++++
.../computer/core/combiner/CombinerTestSuite.java | 39 +
.../core/combiner/DoubleValueSumCombinerTest.java | 65 ++
.../core/combiner/FloatValueSumCombinerTest.java | 65 ++
.../core/combiner/IntValueSumCombinerTest.java | 65 ++
.../core/combiner/LongValueSumCombinerTest.java | 65 ++
.../combiner/MergeNewPropertiesCombinerTest.java | 84 ++
.../combiner/MergeOldPropertiesCombinerTest.java | 84 ++
.../core/combiner/OverwriteCombinerTest.java | 66 ++
.../core/combiner/PointerCombinerTest.java | 175 ++++
.../core/combiner/ValueMaxCombinerTest.java | 65 ++
.../core/combiner/ValueMinCombinerTest.java | 58 ++
.../computer/core/common/CommonTestSuite.java | 31 +
.../computer/core/common/ContainerInfoTest.java | 72 ++
.../computer/core/common/ExceptionTest.java | 76 ++
.../core/common/FakeMasterComputation.java | 48 ++
.../computer/core/compute/ComputeManagerTest.java | 234 +++++
.../computer/core/compute/ComputeTestSuite.java | 36 +
.../computer/core/compute/MockComputation.java | 84 ++
.../computer/core/compute/MockMessageSender.java | 41 +
.../core/compute/input/EdgesInputTest.java | 284 +++++++
.../core/compute/input/MessageInputTest.java | 176 ++++
.../core/compute/input/ResuablePointerTest.java | 54 ++
.../computer/core/config/ConfigTestSuite.java | 30 +
.../computer/core/config/DefaultConfigTest.java | 189 +++++
.../core/graph/BuiltinGraphFactoryTest.java | 104 +++
.../computer/core/graph/DefaultEdgeTest.java | 90 ++
.../computer/core/graph/DefaultPropertiesTest.java | 96 +++
.../computer/core/graph/GraphTestSuite.java | 70 ++
.../computer/core/graph/SuperstepStatTest.java | 164 ++++
.../computer/core/graph/id/BytesIdTest.java | 179 ++++
.../computer/core/graph/id/IdFactoryTest.java | 56 ++
.../computer/core/graph/id/IdTypeTest.java | 51 ++
.../core/graph/partition/HashPartitionerTest.java | 210 +++++
.../core/graph/partition/PartitionStatTest.java | 150 ++++
.../core/graph/value/BooleanValueTest.java | 191 +++++
.../computer/core/graph/value/DoubleValueTest.java | 252 ++++++
.../computer/core/graph/value/FloatValueTest.java | 226 +++++
.../computer/core/graph/value/IdListListTest.java | 103 +++
.../computer/core/graph/value/IdValueListTest.java | 87 ++
.../computer/core/graph/value/IdValueTest.java | 218 +++++
.../computer/core/graph/value/IntValueTest.java | 258 ++++++
.../computer/core/graph/value/ListValueTest.java | 431 ++++++++++
.../computer/core/graph/value/LongValueTest.java | 224 +++++
.../computer/core/graph/value/NullValueTest.java | 151 ++++
.../computer/core/graph/value/StringValueTest.java | 160 ++++
.../computer/core/graph/value/ValueTypeTest.java | 63 ++
.../computer/core/input/FileInputSplitTest.java | 67 ++
.../computer/core/input/HugeConverterTest.java | 131 +++
.../computer/core/input/InputSplitDataTest.java | 99 +++
.../computer/core/input/InputSplitTest.java | 53 ++
.../computer/core/input/InputTestSuite.java | 33 +
.../core/input/MockMasterInputManager.java | 60 ++
.../computer/core/input/MockRpcClient.java | 41 +
.../core/input/MockWorkerInputManager.java | 116 +++
.../computer/core/io/BufferedFileTest.java | 753 +++++++++++++++++
.../computer/core/io/BufferedStreamTest.java | 409 +++++++++
.../computer/core/io/CsvStructGraphOutputTest.java | 165 ++++
.../hugegraph/computer/core/io/IOTestSuite.java | 38 +
.../core/io/JsonStructGraphOutputTest.java | 176 ++++
.../computer/core/io/MockRankComputation.java | 52 ++
.../computer/core/io/OptimizedUnsafeBytesTest.java | 191 +++++
.../core/io/StreamGraphOutputInputTest.java | 270 ++++++
.../core/io/StructRandomAccessOutputTest.java | 247 ++++++
.../computer/core/io/UnsafeBytesTest.java | 612 ++++++++++++++
.../computer/core/network/ConnectionIdTest.java | 77 ++
.../core/network/DataServerManagerTest.java | 81 ++
.../computer/core/network/MockClientHandler.java | 52 ++
.../computer/core/network/MockMessageHandler.java | 88 ++
.../computer/core/network/MockUnDecodeMessage.java | 49 ++
.../computer/core/network/NetworkTestSuite.java | 48 ++
.../computer/core/network/TransportUtilTest.java | 128 +++
.../core/network/buffer/NetworkBufferTest.java | 156 ++++
.../network/connection/ConnectionManagerTest.java | 146 ++++
.../core/network/netty/AbstractNetworkTest.java | 144 ++++
.../core/network/netty/HeartbeatHandlerTest.java | 135 +++
.../core/network/netty/NettyClientFactoryTest.java | 135 +++
.../netty/NettyEncodeDecodeHandlerTest.java | 170 ++++
.../network/netty/NettyTransportClientTest.java | 379 +++++++++
.../network/netty/NettyTransportServerTest.java | 244 ++++++
.../core/network/session/TransportSessionTest.java | 343 ++++++++
.../core/receiver/MessageRecvBuffersTest.java | 186 ++++
.../core/receiver/MessageRecvManagerTest.java | 164 ++++
.../computer/core/receiver/ReceiverTestSuite.java | 37 +
.../computer/core/receiver/ReceiverUtil.java | 82 ++
.../edge/EdgeMessageRecvPartitionTest.java | 279 ++++++
.../message/ComputeMessageRecvPartitionTest.java | 190 +++++
.../vertex/VertexMessageRecvPartitionTest.java | 278 ++++++
.../computer/core/sender/MessageQueueTest.java | 65 ++
.../core/sender/MessageSendBuffersTest.java | 65 ++
.../core/sender/MessageSendManagerTest.java | 30 +
.../computer/core/sender/MockTransportClient.java | 94 +++
.../computer/core/sender/MultiQueueTest.java | 249 ++++++
.../core/sender/QueuedMessageSenderTest.java | 69 ++
.../computer/core/sender/QueuedMessageTest.java | 38 +
.../computer/core/sender/SenderTestSuite.java | 37 +
.../computer/core/sender/WriteBufferTest.java | 194 +++++
.../computer/core/sender/WriteBuffersTest.java | 262 ++++++
.../computer/core/sort/SorterTestUtil.java | 178 ++++
.../core/sort/combiner/MockIntSumCombiner.java | 31 +
.../core/sort/sorter/EmptyFlusherTest.java | 49 ++
.../computer/core/sort/sorter/FlusherTest.java | 157 ++++
.../core/sort/sorter/SortLargeDataTest.java | 333 ++++++++
.../computer/core/sort/sorter/SorterTest.java | 492 +++++++++++
.../computer/core/sort/sorter/SorterTestSuite.java | 33 +
.../core/sort/sorting/InputsSortingTest.java | 75 ++
.../core/sort/sorting/SortingTestSuite.java | 31 +
.../computer/core/sort/sorting/TestData.java | 143 ++++
.../hugegraph/computer/core/store/BitFileTest.java | 94 +++
.../computer/core/store/EntriesUtilTest.java | 115 +++
.../computer/core/store/EntryOutputTest.java | 185 ++++
.../computer/core/store/FileManagerTest.java | 109 +++
.../hugegraph/computer/core/store/HgkvDirTest.java | 146 ++++
.../computer/core/store/HgkvFileTest.java | 157 ++++
.../hugegraph/computer/core/store/PointerTest.java | 93 ++
.../computer/core/store/StoreTestSuite.java | 37 +
.../computer/core/store/StoreTestUtil.java | 186 ++++
.../computer/core/store/ValueFileTest.java | 491 +++++++++++
.../core/util/ComputerContextUtilTest.java | 74 ++
.../hugegraph/computer/core/util/JsonUtilTest.java | 53 ++
.../computer/core/util/SerializeUtilTest.java | 56 ++
.../computer/core/util/UtilTestSuite.java | 32 +
.../computer/core/worker/MockComputation.java | 407 +++++++++
.../computer/core/worker/MockComputation2.java | 57 ++
.../core/worker/MockComputationParams.java | 47 ++
.../core/worker/MockMasterComputation.java | 391 +++++++++
.../core/worker/MockMasterComputation2.java | 96 +++
.../computer/core/worker/MockWorkerService.java | 33 +
.../computer/core/worker/WorkerServiceTest.java | 268 ++++++
.../computer/core/worker/WorkerStatTest.java | 117 +++
.../computer/core/worker/WorkerTestSuite.java | 31 +
.../computer/dist/ComputerDistTestSuite.java | 29 +
.../computer/dist/HugeGraphComputerTest.java | 105 +++
.../computer/driver/ComputerOptionsTest.java | 90 ++
.../hugegraph/computer/driver/DriverTest.java | 87 ++
.../hugegraph/computer/driver/DriverTestSuite.java | 31 +
.../hugegraph/computer/k8s/AbstractK8sTest.java | 215 +++++
.../hugegraph/computer/k8s/K8sTestSuite.java | 32 +
.../computer/k8s/KubernetesDriverTest.java | 320 +++++++
.../hugegraph/computer/k8s/MiniKubeTest.java | 446 ++++++++++
.../hugegraph/computer/k8s/OperatorTest.java | 58 ++
.../suite/integrate/IntegrateTestSuite.java | 56 ++
.../computer/suite/integrate/MockComputation.java | 51 ++
.../suite/integrate/SenderIntegrateTest.java | 430 ++++++++++
.../computer/suite/unit/UnitTestBase.java | 296 +++++++
.../computer/suite/unit/UnitTestSuite.java | 71 ++
.../src/main/resources/computer.properties | 8 +-
computer-test/src/main/resources/log4j2.xml | 2 +-
computer-yarn/pom.xml | 2 +-
pom.xml | 4 +-
1198 files changed, 64870 insertions(+), 65016 deletions(-)
diff --git a/README.md b/README.md
index db1430c7..73f1e7a1 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# hugegraph-computer
+# Apache HugeGraph Computer
[![License](https://img.shields.io/badge/license-Apache%202-0E78BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Build Status](https://github.com/apache/hugegraph-computer/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/hugegraph-computer/actions/workflows/ci.yml)
diff --git a/computer-algorithm/pom.xml b/computer-algorithm/pom.xml
index b35c7eed..abbf0525 100644
--- a/computer-algorithm/pom.xml
+++ b/computer-algorithm/pom.xml
@@ -20,7 +20,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hugegraph-computer</artifactId>
- <groupId>com.baidu.hugegraph</groupId>
+ <groupId>org.apache.hugegraph</groupId>
<version>0.1.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -29,7 +29,7 @@
<dependencies>
<dependency>
- <groupId>com.baidu.hugegraph</groupId>
+ <groupId>org.apache.hugegraph</groupId>
<artifactId>computer-api</artifactId>
<version>${version}</version>
<scope>provided</scope>
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentrality.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentrality.java
deleted file mode 100644
index 094f3ea8..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentrality.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.betweenness;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.slf4j.Logger;
-
-import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.IdSet;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-import org.apache.hugegraph.util.Log;
-
-public class BetweennessCentrality implements Computation<BetweennessMessage> {
-
- private static final Logger LOG = Log.logger(BetweennessCentrality.class);
-
- public static final String OPTION_SAMPLE_RATE =
- "betweenness_centrality.sample_rate";
-
- private double sampleRate;
- /*
- * Record the number of shortest paths for intermediate vertex, suppose
- * there are two shortest paths from A(source vertex) to E(current vertex),
- * [A -> B -> C -> E] and [A -> B -> D -> E]
- *
- * The saved data is as follows
- * A: B:2
- * C:1
- * D:1
- * totalCount:2
- */
- private Map<Id, SeqCount> seqTable;
-
- @Override
- public String name() {
- return "betweenness_centrality";
- }
-
- @Override
- public String category() {
- return "centrality";
- }
-
- @Override
- public void init(Config config) {
- this.sampleRate = config.getDouble(OPTION_SAMPLE_RATE, 1.0D);
- if (this.sampleRate <= 0.0D || this.sampleRate > 1.0D) {
- throw new ComputerException("The param %s must be in (0.0, 1.0], " +
- "actual got '%s'",
- OPTION_SAMPLE_RATE, this.sampleRate);
- }
- this.seqTable = new HashMap<>();
- }
-
- @Override
- public void close(Config config) {
- // pass
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- // First superstep is special, we just send vertex id to its neighbors
- BetweennessValue initialValue = new BetweennessValue(0.0D);
- initialValue.arrivedVertices().add(vertex.id());
- vertex.value(initialValue);
- if (vertex.numEdges() == 0) {
- return;
- }
-
- IdList sequence = new IdList();
- sequence.add(vertex.id());
- context.sendMessageToAllEdges(vertex, new BetweennessMessage(sequence));
- LOG.info("Finished compute-0 step");
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<BetweennessMessage> messages) {
- BetweennessValue value = vertex.value();
- // The betweenness value to be updated
- DoubleValue betweenness = value.betweenness();
- // Collect the vertices sent here this time
- IdSet arrivingVertices = new IdSet();
- while (messages.hasNext()) {
- BetweennessMessage message = messages.next();
- // The value contributed to the intermediate node on the path
- DoubleValue vote = message.vote();
- betweenness.value(betweenness.value() + vote.value());
-
- this.forward(context, vertex, message.sequence(), arrivingVertices);
- }
- value.arrivedVertices().addAll(arrivingVertices);
-
- boolean active = !this.seqTable.isEmpty();
- if (active) {
- this.sendMessage(context);
- this.seqTable.clear();
- } else {
- vertex.inactivate();
- }
- }
-
- private void forward(ComputationContext context, Vertex vertex,
- IdList sequence, IdSet arrivingVertices) {
- if (sequence.size() == 0) {
- return;
- }
-
- BetweennessValue value = vertex.value();
- IdSet arrivedVertices = value.arrivedVertices();
- Id source = sequence.get(0);
- // The source vertex is arriving at first time
- if (!arrivedVertices.contains(source)) {
- arrivingVertices.add(source);
-
- SeqCount seqCount = this.seqTable.computeIfAbsent(
- source, k -> new SeqCount());
- seqCount.totalCount++;
- // Accumulate the number of shortest paths for intermediate vertices
- for (int i = 1; i < sequence.size(); i++) {
- Id id = sequence.get(i);
- Map<Id, Integer> idCounts = seqCount.idCount;
- idCounts.put(id, idCounts.getOrDefault(id, 0) + 1);
- }
-
- Id selfId = vertex.id();
- sequence.add(selfId);
- BetweennessMessage newMessage = new BetweennessMessage(sequence);
- for (Edge edge : vertex.edges()) {
- Id targetId = edge.targetId();
- if (this.sample(selfId, targetId, edge) &&
- !sequence.contains(targetId)) {
- context.sendMessage(targetId, newMessage);
- }
- }
- }
- }
-
- private void sendMessage(ComputationContext context) {
- for (SeqCount seqCount : this.seqTable.values()) {
- for (Map.Entry<Id, Integer> entry : seqCount.idCount.entrySet()) {
- double vote = (double) entry.getValue() / seqCount.totalCount;
- BetweennessMessage voteMessage = new BetweennessMessage(
- new DoubleValue(vote));
-
- context.sendMessage(entry.getKey(), voteMessage);
- }
- }
- }
-
- private boolean sample(Id sourceId, Id targetId, Edge edge) {
- // Now just use the simplest way
- return Math.random() <= this.sampleRate;
- }
-
- private static class SeqCount {
-
- private final Map<Id, Integer> idCount;
- private int totalCount;
-
- public SeqCount() {
- this.idCount = new HashMap<>();
- this.totalCount = 0;
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityParams.java
deleted file mode 100644
index 87a26bed..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityParams.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.betweenness;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.algorithm.centrality.closeness.ClosenessCentrality;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation;
-
-public class BetweennessCentralityParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
- DefaultMasterComputation.class.getName());
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- BetweennessCentrality.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- BetweennessValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- BetweennessMessage.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS,
- EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME);
- this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE,
- "0.5D");
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessMessage.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessMessage.java
deleted file mode 100644
index 9503fcfe..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessMessage.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.betweenness;
-
-import java.io.IOException;
-
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import com.baidu.hugegraph.computer.core.graph.value.Value.CustomizeValue;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-import org.apache.hugegraph.util.E;
-
-public class BetweennessMessage implements CustomizeValue<BetweennessMessage> {
-
- private final IdList sequence;
- private final DoubleValue vote;
-
- public BetweennessMessage() {
- this.sequence = new IdList();
- this.vote = new DoubleValue(0.0D);
- }
-
- public BetweennessMessage(IdList sequence) {
- this.sequence = sequence;
- this.vote = new DoubleValue();
- }
-
- public BetweennessMessage(DoubleValue betweenness) {
- this.sequence = new IdList();
- this.vote = betweenness;
- }
-
- public IdList sequence() {
- return this.sequence;
- }
-
- public DoubleValue vote() {
- return this.vote;
- }
-
- @Override
- public BetweennessMessage value() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.sequence.read(in);
- this.vote.read(in);
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.sequence.write(out);
- this.vote.write(out);
- }
-
- @Override
- public int compareTo(Value value) {
- E.checkArgument(value instanceof BetweennessMessage,
- "The BetweennessMessage can't compare with class '%s'",
- value.getClass());
- BetweennessMessage other = (BetweennessMessage) value;
- E.checkArgument(this.sequence.size() != 0, "Sequence can't be empty");
- E.checkArgument(other.sequence.size() != 0, "Sequence can't be empty");
- Id selfSourceId = this.sequence.get(0);
- Id otherSourceId = other.sequence.get(0);
- return selfSourceId.compareTo(otherSourceId);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessValue.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessValue.java
deleted file mode 100644
index 210cb7c2..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessValue.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.betweenness;
-
-import java.io.IOException;
-
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.IdSet;
-import com.baidu.hugegraph.computer.core.graph.value.Value.CustomizeValue;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-
-public class BetweennessValue implements CustomizeValue<Double> {
-
- private final DoubleValue betweenness;
- private final IdSet arrivedVertices;
-
- public BetweennessValue() {
- this(0.0D);
- }
-
- public BetweennessValue(double betweenness) {
- this.betweenness = new DoubleValue(betweenness);
- this.arrivedVertices = new IdSet();
- }
-
- public DoubleValue betweenness() {
- return this.betweenness;
- }
-
- public IdSet arrivedVertices() {
- return this.arrivedVertices;
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.betweenness.read(in);
- this.arrivedVertices.read(in);
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.betweenness.write(out);
- this.arrivedVertices.write(out);
- }
-
- @Override
- public Double value() {
- return this.betweenness.value();
- }
-
- @Override
- public String string() {
- return this.value().toString();
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java
deleted file mode 100644
index 965462e0..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.closeness;
-
-import java.util.Iterator;
-
-import org.slf4j.Logger;
-
-import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-import org.apache.hugegraph.util.Log;
-import org.apache.hugegraph.util.NumericUtil;
-
-public class ClosenessCentrality implements Computation<ClosenessMessage> {
-
- private static final Logger LOG = Log.logger(ClosenessCentrality.class);
-
- public static final String OPTION_WEIGHT_PROPERTY =
- "closeness_centrality.weight_property";
- public static final String OPTION_SAMPLE_RATE =
- "closeness_centrality.sample_rate";
-
- private String weightProp;
- private double sampleRate;
-
- @Override
- public String name() {
- return "closeness_centrality";
- }
-
- @Override
- public String category() {
- return "centrality";
- }
-
- @Override
- public void init(Config config) {
- this.weightProp = config.getString(OPTION_WEIGHT_PROPERTY, "");
- this.sampleRate = config.getDouble(OPTION_SAMPLE_RATE, 1.0D);
- if (this.sampleRate <= 0.0D || this.sampleRate > 1.0D) {
- throw new ComputerException("The param %s must be in (0.0, 1.0], " +
- "actual got '%s'",
- OPTION_SAMPLE_RATE, this.sampleRate);
- }
- }
-
- @Override
- public void close(Config config) {
- // pass
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- // Set empty map as initial value
- vertex.value(new ClosenessValue());
-
- // Send messages to adjacent edges
- for (Edge edge : vertex.edges()) {
- Id senderId = vertex.id();
- // Get property value
- double value = this.weightValue(edge.property(this.weightProp));
- DoubleValue distance = new DoubleValue(value);
- ClosenessMessage message = new ClosenessMessage(senderId, senderId,
- distance);
- context.sendMessage(edge.targetId(), message);
- }
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<ClosenessMessage> messages) {
- Id selfId = vertex.id();
- // Save the distance from other vertices to self
- ClosenessValue localValue = vertex.value();
- boolean active = false;
- while (messages.hasNext()) {
- active = true;
- ClosenessMessage message = messages.next();
- Id senderId = message.senderId();
- // In theory, it won't happen, defensive programming
- if (selfId.equals(senderId)) {
- continue;
- }
- Id startId = message.startId();
- if (selfId.equals(startId)) {
- continue;
- }
-
- DoubleValue oldValue = localValue.get(startId);
- DoubleValue newValue = message.distance();
- // If the id already exists and the new value >= old value, skip it
- if (oldValue != null && newValue.compareTo(oldValue) >= 0) {
- continue;
- }
- // Update local saved values (take smaller value)
- localValue.put(startId, newValue);
- // Send this smaller value to neighbors
- this.sendMessage(context, vertex, senderId, startId, newValue);
- }
- if (!active) {
- vertex.inactivate();
- }
- }
-
- private void sendMessage(ComputationContext context, Vertex vertex,
- Id senderId, Id startId, DoubleValue newValue) {
- Id selfId = vertex.id();
- double baseNewValue = this.weightValue(newValue);
- for (Edge edge : vertex.edges()) {
- Id targetId = edge.targetId();
- if (senderId.equals(targetId) || startId.equals(targetId)) {
- continue;
- }
- if (!sample(selfId, targetId, edge)) {
- continue;
- }
- // Update distance information
- double updatedValue = baseNewValue + this.weightValue(edge.property(
- this.weightProp));
- DoubleValue newDistance = new DoubleValue(updatedValue);
- ClosenessMessage message = new ClosenessMessage(selfId, startId,
- newDistance);
- context.sendMessage(targetId, message);
- }
- }
-
- private boolean sample(Id sourceId, Id targetId, Edge edge) {
- // Now just use the simplest way
- return Math.random() <= this.sampleRate;
- }
-
- private double weightValue(Value rawValue) {
- if (rawValue == null) {
- return 1.0D;
- }
- if (rawValue.isNumber()) {
- return NumericUtil.convertToNumber(rawValue).doubleValue();
- } else {
- throw new ComputerException("The weight property can only be " +
- "either Long or Int or Double or " +
- "Float, but got %s",
- rawValue.valueType());
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityParams.java
deleted file mode 100644
index 9fbf58f9..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityParams.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.closeness;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation;
-
-public class ClosenessCentralityParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
- DefaultMasterComputation.class.getName());
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- ClosenessCentrality.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- ClosenessValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- ClosenessMessage.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS,
- EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME);
- this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE,
- "0.5D");
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessMessage.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessMessage.java
deleted file mode 100644
index 7251640e..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessMessage.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.closeness;
-
-import java.io.IOException;
-
-import com.baidu.hugegraph.computer.core.common.ComputerContext;
-import com.baidu.hugegraph.computer.core.graph.GraphFactory;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.id.IdFactory;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.Value.CustomizeValue;
-import com.baidu.hugegraph.computer.core.graph.value.ValueType;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-
-public class ClosenessMessage implements CustomizeValue<ClosenessMessage> {
-
- private final GraphFactory graphFactory;
-
- private Id senderId;
- private Id startId;
- private DoubleValue distance;
-
- public ClosenessMessage() {
- this(IdFactory.createId(), IdFactory.createId(), new DoubleValue(0.0D));
- }
-
- public ClosenessMessage(Id senderId, Id startId, DoubleValue distance) {
- this.graphFactory = ComputerContext.instance().graphFactory();
- this.senderId = senderId;
- this.startId = startId;
- this.distance = distance;
- }
-
- public Id senderId() {
- return this.senderId;
- }
-
- public Id startId() {
- return this.startId;
- }
-
- public DoubleValue distance() {
- return this.distance;
- }
-
- @Override
- public ClosenessMessage value() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.senderId = this.graphFactory.createId();
- this.senderId.read(in);
-
- this.startId = this.graphFactory.createId();
- this.startId.read(in);
-
- this.distance = (DoubleValue) this.graphFactory.createValue(
- ValueType.DOUBLE);
- this.distance.read(in);
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.senderId.write(out);
- this.startId.write(out);
- this.distance.write(out);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java
deleted file mode 100644
index ace25316..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.closeness;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.MapValue;
-
-public class ClosenessValue extends MapValue<DoubleValue> {
-
- @Override
- public Double value() {
- // Cumulative distance
- double centrality = 0;
- for (Map.Entry<Id, DoubleValue> entry : this.entrySet()) {
- centrality += 1.0D / entry.getValue().value();
- }
- return centrality;
- }
-
- @Override
- public String string() {
- return this.value().toString();
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentrality.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentrality.java
deleted file mode 100644
index d5289a9d..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentrality.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.degree;
-
-import java.util.Iterator;
-
-import org.apache.commons.lang.StringUtils;
-
-import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.NullValue;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-import com.baidu.hugegraph.computer.core.worker.WorkerContext;
-import org.apache.hugegraph.util.NumericUtil;
-
-public class DegreeCentrality implements Computation<NullValue> {
-
- public static final String OPTION_WEIGHT_PROPERTY = "degree_centrality.weight_property";
-
- private boolean calculateByWeightProperty;
- private String weightProperty;
-
- @Override
- public String name() {
- return "degree_centrality";
- }
-
- @Override
- public String category() {
- return "centrality";
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- if (!this.calculateByWeightProperty) {
- vertex.value(new DoubleValue(vertex.numEdges()));
- } else {
- /*
- * TODO: Here we use doubleValue type now, we will use BigDecimal
- * and output "BigDecimalValue" to resolve double type overflow
- * int the future;
- */
- double totalWeight = 0.0;
- for (Edge edge : vertex.edges()) {
- double weight = weightValue(edge.property(this.weightProperty));
- totalWeight += weight;
- if (Double.isInfinite(totalWeight)) {
- throw new ComputerException("Calculate weight overflow, " +
- "current is %s, edge '%s' " +
- "is %s", totalWeight, edge, weight);
- }
- }
- vertex.value(new DoubleValue(totalWeight));
- }
- vertex.inactivate();
- }
-
- private static double weightValue(Value value) {
- if (value == null) {
- return 1.0;
- }
-
- switch (value.valueType()) {
- case LONG:
- case INT:
- case DOUBLE:
- case FLOAT:
- return NumericUtil.convertToNumber(value).doubleValue();
- default:
- throw new ComputerException("The weight property can only be " +
- "either Long or Int or Double or " +
- "Float, but got %s",
- value.valueType());
- }
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<NullValue> messages) {
- // pass
- }
-
- @Override
- public void init(Config config) {
- this.weightProperty = config.getString(
- OPTION_WEIGHT_PROPERTY, "");
- this.calculateByWeightProperty = StringUtils.isNotEmpty(
- this.weightProperty);
- }
-
- @Override
- public void close(Config config) {
- // pass
- }
-
- @Override
- public void beforeSuperstep(WorkerContext context) {
- // pass
- }
-
- @Override
- public void afterSuperstep(WorkerContext context) {
- // pass
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityParams.java
deleted file mode 100644
index 04fc08ef..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityParams.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.degree;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.combiner.DoubleValueSumCombiner;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation;
-
-public class DegreeCentralityParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
- DefaultMasterComputation.class.getName());
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- DegreeCentrality.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- DoubleValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- DoubleValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
- DoubleValueSumCombiner.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRank.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRank.java
deleted file mode 100644
index b37ba4d0..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRank.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.pagerank;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.core.aggregator.Aggregator;
-import com.baidu.hugegraph.computer.core.combiner.Combiner;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.LongValue;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-import com.baidu.hugegraph.computer.core.worker.WorkerContext;
-
-public class PageRank implements Computation<DoubleValue> {
-
- public static final String OPTION_ALPHA = "page_rank.alpha";
-
- public static final double ALPHA_DEFAULT_VALUE = 0.15;
-
- private double alpha;
- private double danglingRank;
- private double initialRankInSuperstep;
- private double cumulativeRank;
-
- private Aggregator<DoubleValue> l1DiffAggr;
- private Aggregator<DoubleValue> cumulativeRankAggr;
- private Aggregator<LongValue> danglingVertexNumAggr;
- private Aggregator<DoubleValue> danglingCumulativeAggr;
-
- // Initial value in superstep 0.
- private DoubleValue initialValue;
- private DoubleValue contribValue;
-
- @Override
- public String name() {
- return "page_rank";
- }
-
- @Override
- public String category() {
- return "centrality";
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- vertex.value(this.initialValue);
- this.cumulativeRankAggr.aggregateValue(this.initialValue.value());
- int edgeCount = vertex.numEdges();
- if (edgeCount == 0) {
- this.danglingVertexNumAggr.aggregateValue(1L);
- this.danglingCumulativeAggr.aggregateValue(
- this.initialValue.value());
- } else {
- this.contribValue.value(this.initialValue.value() / edgeCount);
- context.sendMessageToAllEdges(vertex, this.contribValue);
- }
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<DoubleValue> messages) {
- DoubleValue message = Combiner.combineAll(context.combiner(), messages);
- double rankFromNeighbors = 0.0;
- if (message != null) {
- rankFromNeighbors = message.value();
- }
- double rank = (this.danglingRank + rankFromNeighbors) *
- (1.0 - this.alpha) + this.initialRankInSuperstep;
- rank /= this.cumulativeRank;
- DoubleValue oldRank = vertex.value();
- vertex.value(new DoubleValue(rank));
- this.l1DiffAggr.aggregateValue(Math.abs(oldRank.value() - rank));
- this.cumulativeRankAggr.aggregateValue(rank);
- int edgeCount = vertex.numEdges();
- if (edgeCount == 0) {
- this.danglingVertexNumAggr.aggregateValue(1L);
- this.danglingCumulativeAggr.aggregateValue(rank);
- } else {
- this.contribValue.value(rank / edgeCount);
- context.sendMessageToAllEdges(vertex, this.contribValue);
- }
- }
-
- @Override
- public void init(Config config) {
- this.alpha = config.getDouble(OPTION_ALPHA, ALPHA_DEFAULT_VALUE);
- this.contribValue = new DoubleValue();
- }
-
- @Override
- public void close(Config config) {
- // pass
- }
-
- @Override
- public void beforeSuperstep(WorkerContext context) {
- // Get aggregator values for computation
- DoubleValue danglingTotalRank = context.aggregatedValue(
- PageRank4Master.AGGR_COMULATIVE_DANGLING_PROBABILITY);
- DoubleValue cumulativeRank = context.aggregatedValue(
- PageRank4Master.AGGR_COMULATIVE_PROBABILITY);
- long totalVertex = context.totalVertexCount();
-
- this.danglingRank = danglingTotalRank.value() / totalVertex;
- this.initialRankInSuperstep = this.alpha / totalVertex;
- this.cumulativeRank = cumulativeRank.value();
- this.initialValue = new DoubleValue(1.0 / totalVertex);
-
- // Create aggregators
- this.l1DiffAggr = context.createAggregator(
- PageRank4Master.AGGR_L1_NORM_DIFFERENCE_KEY);
- this.cumulativeRankAggr = context.createAggregator(
- PageRank4Master.AGGR_COMULATIVE_PROBABILITY);
- this.danglingVertexNumAggr = context.createAggregator(
- PageRank4Master.AGGR_DANGLING_VERTICES_NUM);
- this.danglingCumulativeAggr = context.createAggregator(
- PageRank4Master.AGGR_COMULATIVE_DANGLING_PROBABILITY);
- }
-
- @Override
- public void afterSuperstep(WorkerContext context) {
- context.aggregateValue(
- PageRank4Master.AGGR_COMULATIVE_PROBABILITY,
- this.cumulativeRankAggr.aggregatedValue());
- context.aggregateValue(
- PageRank4Master.AGGR_L1_NORM_DIFFERENCE_KEY,
- this.l1DiffAggr.aggregatedValue());
- context.aggregateValue(
- PageRank4Master.AGGR_DANGLING_VERTICES_NUM,
- this.danglingVertexNumAggr.aggregatedValue());
- context.aggregateValue(
- PageRank4Master.AGGR_COMULATIVE_DANGLING_PROBABILITY,
- this.danglingCumulativeAggr.aggregatedValue());
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRank4Master.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRank4Master.java
deleted file mode 100644
index f7aeb306..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRank4Master.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.pagerank;
-
-import org.slf4j.Logger;
-
-import com.baidu.hugegraph.computer.core.combiner.DoubleValueSumCombiner;
-import com.baidu.hugegraph.computer.core.combiner.LongValueSumCombiner;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import com.baidu.hugegraph.computer.core.graph.value.LongValue;
-import com.baidu.hugegraph.computer.core.graph.value.ValueType;
-import com.baidu.hugegraph.computer.core.master.MasterComputation;
-import com.baidu.hugegraph.computer.core.master.MasterComputationContext;
-import com.baidu.hugegraph.computer.core.master.MasterContext;
-import org.apache.hugegraph.util.Log;
-
-public class PageRank4Master implements MasterComputation {
-
- private static final Logger LOG = Log.logger(PageRank4Master.class);
-
- public static final String CONF_L1_NORM_DIFFERENCE_THRESHOLD_KEY =
- "pagerank.l1DiffThreshold";
- public static final double CONF_L1_DIFF_THRESHOLD_DEFAULT = 0.00001D;
-
- public static final String AGGR_L1_NORM_DIFFERENCE_KEY =
- "pagerank.aggr_l1_norm_difference";
- public static final String AGGR_DANGLING_VERTICES_NUM =
- "pagerank.dangling_vertices_num";
- public static final String AGGR_COMULATIVE_DANGLING_PROBABILITY =
- "pagerank.comulative_dangling_probability";
- public static final String AGGR_COMULATIVE_PROBABILITY =
- "pagerank.comulative_probability";
-
- private double l1DiffThreshold;
-
- @Override
- public void init(MasterContext context) {
- this.l1DiffThreshold = context.config().getDouble(
- CONF_L1_NORM_DIFFERENCE_THRESHOLD_KEY,
- CONF_L1_DIFF_THRESHOLD_DEFAULT);
- context.registerAggregator(AGGR_DANGLING_VERTICES_NUM,
- ValueType.LONG,
- LongValueSumCombiner.class);
- context.registerAggregator(AGGR_COMULATIVE_DANGLING_PROBABILITY,
- ValueType.DOUBLE,
- DoubleValueSumCombiner.class);
- context.registerAggregator(AGGR_COMULATIVE_PROBABILITY,
- ValueType.DOUBLE,
- DoubleValueSumCombiner.class);
- context.registerAggregator(AGGR_L1_NORM_DIFFERENCE_KEY,
- ValueType.DOUBLE,
- DoubleValueSumCombiner.class);
- }
-
- @Override
- public void close(MasterContext context) {
- // pass
- }
-
- @Override
- public boolean compute(MasterComputationContext context) {
- LongValue danglingVerticesNum = context.aggregatedValue(
- AGGR_DANGLING_VERTICES_NUM);
- DoubleValue danglingProbability = context.aggregatedValue(
- AGGR_COMULATIVE_DANGLING_PROBABILITY);
- DoubleValue cumulativeProbability = context.aggregatedValue(
- AGGR_COMULATIVE_PROBABILITY);
- DoubleValue l1NormDifference = context.aggregatedValue(
- AGGR_L1_NORM_DIFFERENCE_KEY);
-
- StringBuilder sb = new StringBuilder();
- sb.append("[Superstep ").append(context.superstep()).append("]")
- .append(", dangling vertices num = ").append(danglingVerticesNum)
- .append(", cumulative dangling probability = ")
- .append(danglingProbability.value())
- .append(", cumulative probability = ").append(cumulativeProbability)
- .append(", l1 norm difference = ").append(l1NormDifference.value());
-
- LOG.info("PageRank running status: {}", sb);
- double l1Diff = l1NormDifference.value();
- if (context.superstep() > 1 && l1Diff <= this.l1DiffThreshold) {
- return false;
- } else {
- return true;
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankParams.java
deleted file mode 100644
index a10018c7..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankParams.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.centrality.pagerank;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.combiner.DoubleValueSumCombiner;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-
-public class PageRankParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
- PageRank4Master.class.getName());
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- PageRank.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- DoubleValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- DoubleValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
- DoubleValueSumCombiner.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficient.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficient.java
deleted file mode 100644
index 9cec92ef..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficient.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.cc;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.algorithm.community.trianglecount.TriangleCount;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.IdSet;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-
-/**
- * ClusteringCoefficient(CC) algorithm could calculate local & the whole graph:
- * 1. local cc: get triangles & degree for current vertex, calculate them
- * 2. whole cc have 2 ways to get the result: (NOT SUPPORTED NOW)
- * - sum all open & closed triangles in graph, and calculate the result
- * - sum all local cc for each vertex, and use avg as the whole graph result
- * <p>
- * And we have 2 ways to count local cc:
- * 1. if we already saved the triangles in each vertex, we can calculate only
- * in superstep0/compute0 to get the result
- * <p>
- * The formula of local CC is: C(v) = 2T / Dv(Dv - 1)
- * v represents one vertex, T represents the triangles of current vertex,
- * D represents the degree of current vertex
- */
-public class ClusteringCoefficient extends TriangleCount {
-
- @Override
- public String name() {
- return "clustering_coefficient";
- }
-
- @Override
- public String category() {
- return "community";
- }
-
- @Override
- public void init(Config config) {
- // Reuse triangle count later
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- IdList selfId = new IdList();
- selfId.add(vertex.id());
-
- context.sendMessageToAllEdgesIf(vertex, selfId, (ids, targetId) -> {
- return !ids.get(0).equals(targetId);
- });
- vertex.value(new ClusteringCoefficientValue());
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex, Iterator<IdList> messages) {
- IdSet neighbors = ((ClusteringCoefficientValue) vertex.value()).idSet();
- Integer count = super.triangleCount(context, vertex, messages, neighbors);
- if (count != null) {
- ((ClusteringCoefficientValue) vertex.value()).count(count);
- vertex.inactivate();
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientOutput.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientOutput.java
deleted file mode 100644
index 0d7ed78f..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientOutput.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.cc;
-
-import org.apache.hugegraph.structure.constant.WriteType;
-
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput;
-
-/**
- * Offer 2 ways to output: write-back + hdfs-file(TODO)
- */
-public class ClusteringCoefficientOutput extends HugeGraphOutput<Float> {
-
- @Override
- public String name() {
- return "clustering_coefficient";
- }
-
- @Override
- public void prepareSchema() {
- this.client().schema().propertyKey(this.name())
- .asFloat()
- .writeType(WriteType.OLAP_RANGE)
- .ifNotExist()
- .create();
- }
-
- @Override
- protected org.apache.hugegraph.structure.graph.Vertex constructHugeVertex(Vertex vertex) {
- org.apache.hugegraph.structure.graph.Vertex hugeVertex =
- new org.apache.hugegraph.structure.graph.Vertex(null);
- hugeVertex.id(vertex.id().asObject());
- float triangle = ((ClusteringCoefficientValue) vertex.value()).count();
- int degree = ((ClusteringCoefficientValue) vertex.value()).idSet().value().size();
- hugeVertex.property(this.name(), 2 * triangle / degree / (degree - 1));
- return hugeVertex;
- }
-
- /* TODO: enhance it
- @Override
- protected Float value(Vertex vertex) {
- float triangle = ((ClusteringCoefficientValue) vertex.value()).count();
- int degree = ((ClusteringCoefficientValue) vertex.value()).idList().size();
- return 2 * triangle / degree / (degree - 1);
- }*/
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientParams.java
deleted file mode 100644
index 8a310469..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientParams.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.cc;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.config.EdgeFrequency;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-
-public class ClusteringCoefficientParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- ClusteringCoefficient.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- IdList.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- ClusteringCoefficientValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- ClusteringCoefficientOutput.class.getName());
- this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.name(),
- EdgeFrequency.SINGLE.name());
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientValue.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientValue.java
deleted file mode 100644
index 16c9f776..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientValue.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.cc;
-
-import java.io.IOException;
-
-import com.baidu.hugegraph.computer.core.graph.value.IdSet;
-import com.baidu.hugegraph.computer.core.graph.value.IntValue;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-
-/**
- * TODO: We could reuse triangle's result to simplify it (and avoid logical differences)
- */
-public class ClusteringCoefficientValue implements Value.CustomizeValue<Integer> {
-
- private IdSet idSet;
- private IntValue count;
- private final IntValue degree;
-
- public ClusteringCoefficientValue() {
- this.idSet = new IdSet();
- this.count = new IntValue();
- this.degree = new IntValue();
- }
-
- public IdSet idSet() {
- return this.idSet;
- }
-
- public int count() {
- return this.count.intValue();
- }
-
- public void count(Integer count) {
- this.count.value(count);
- }
-
- public int degree() {
- return this.degree.value();
- }
-
- public void degree(Integer degree) {
- this.degree.value(degree);
- }
-
- @Override
- public ClusteringCoefficientValue copy() {
- ClusteringCoefficientValue ccValue = new ClusteringCoefficientValue();
- ccValue.idSet = this.idSet.copy();
- ccValue.count = this.count.copy();
- return ccValue;
- }
-
- @Override
- public Integer value() {
- return this.count.value();
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.idSet.read(in);
- this.count.read(in);
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.idSet.write(out);
- this.count.write(out);
- }
-
- @Override
- public String toString() {
- return String.valueOf(count);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/Kcore.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/Kcore.java
deleted file mode 100644
index f11ad534..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/Kcore.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.kcore;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.core.combiner.Combiner;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-import com.google.common.collect.Iterators;
-
-public class Kcore implements Computation<Id> {
-
- public static final String OPTION_K = "kcore.k";
- public static final int K_DEFAULT_VALUE = 3;
-
- private final KcoreValue initValue = new KcoreValue();
-
- private int k = 0;
-
- @Override
- public String name() {
- return "kcore";
- }
-
- @Override
- public String category() {
- return "community";
- }
-
- @Override
- public void init(Config config) {
- this.k = config.getInt(OPTION_K, K_DEFAULT_VALUE);
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- KcoreValue value = this.initValue;
- value.core((Id) vertex.id().copy());
- vertex.value(value);
-
- if (vertex.numEdges() < this.k) {
- value.degree(0);
- /*
- * TODO: send int type message at phase 1, it's different from id
- * type of phase 2 (wcc message), need support switch message type.
- */
- context.sendMessageToAllEdges(vertex, vertex.id());
- vertex.inactivate();
- } else {
- value.degree(vertex.numEdges());
- assert vertex.active();
- }
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<Id> messages) {
- KcoreValue value = vertex.value();
- if (!value.active()) {
- // Ignore messages of deleted vertex
- vertex.inactivate();
- return;
- }
-
- int superstep = context.superstep();
- if (superstep <= 2) {
- int deleted = Iterators.size(messages);
- assert value.active();
- if (value.decreaseDegree(deleted) < this.k) {
- // From active to inactive, delete self vertex
- value.degree(0);
- if (superstep == 1) {
- context.sendMessageToAllEdges(vertex, vertex.id());
- }
- vertex.inactivate();
- } else {
- // From active to active, do wcc from superstep 2
- if (superstep == 2) {
- // Start wcc
- context.sendMessageToAllEdgesIf(vertex, vertex.id(),
- (source, target) -> {
- return source.compareTo(target) < 0;
- });
- vertex.inactivate();
- } else {
- // Keep active at superstep 1 to continue superstep 2
- assert superstep == 1;
- assert vertex.active();
- }
- }
- } else {
- // Do wcc
- assert superstep > 2;
- Id message = Combiner.combineAll(context.combiner(), messages);
- if (value.core().compareTo(message) > 0) {
- value.core(message);
- context.sendMessageToAllEdges(vertex, message);
- }
- vertex.inactivate();
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/KcoreParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/KcoreParams.java
deleted file mode 100644
index bdd4b155..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/KcoreParams.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.kcore;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.combiner.ValueMinCombiner;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-
-public class KcoreParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- Kcore.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- KcoreValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- BYTESID_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
- ValueMinCombiner.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_ID_OUTPUT_CLASS_NAME);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/KcoreValue.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/KcoreValue.java
deleted file mode 100644
index 04b51626..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/kcore/KcoreValue.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.kcore;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.hugegraph.util.E;
-
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.id.IdFactory;
-import com.baidu.hugegraph.computer.core.graph.value.Value.CustomizeValue;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-
-public class KcoreValue implements CustomizeValue<Object> {
-
- private int degree;
- private Id core;
-
- public KcoreValue() {
- this.degree = 0;
- this.core = IdFactory.createId();
- }
-
- public void degree(int degree) {
- assert degree >= 0;
- this.degree = degree;
- }
-
- public int degree() {
- return this.degree;
- }
-
- public int decreaseDegree(int decrease) {
- assert decrease <= this.degree;
- this.degree -= decrease;
- return this.degree;
- }
-
- public boolean active() {
- return this.degree > 0;
- }
-
- public void core(Id core) {
- this.core = core;
- }
-
- public Id core() {
- E.checkNotNull(this.core, "core");
- return this.core;
- }
-
- @Override
- public KcoreValue copy() {
- KcoreValue kcoreValue = new KcoreValue();
- kcoreValue.core = (Id) this.core.copy();
- kcoreValue.degree = this.degree;
- return kcoreValue;
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.core.read(in);
- this.degree = in.readInt();
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.core.write(out);
- out.writeInt(this.degree);
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this)
- .append("core", this.core)
- .append("degree", this.degree)
- .toString();
- }
-
- @Override
- public Object value() {
- return this.core.value();
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/lpa/Lpa.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/lpa/Lpa.java
deleted file mode 100644
index bdc8abb2..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/lpa/Lpa.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.lpa;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.commons.lang3.mutable.MutableInt;
-
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-
-public class Lpa implements Computation<Id> {
-
- private final Random random = new Random();
-
- @Override
- public String name() {
- return "lpa";
- }
-
- @Override
- public String category() {
- return "community";
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- Id value = vertex.id();
- vertex.value(value);
- vertex.inactivate();
- context.sendMessageToAllEdges(vertex, value);
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<Id> messages) {
- Id label = this.voteLabel(messages);
- Id value = vertex.value();
- if (!value.equals(label)) {
- vertex.value(label);
- context.sendMessageToAllEdges(vertex, label);
- }
- vertex.inactivate();
- }
-
- private Id voteLabel(Iterator<Id> messages) {
- // Calculate label frequency
- Map<Id, MutableInt> labels = new HashMap<>();
- assert messages.hasNext();
- while (messages.hasNext()) {
- Id label = messages.next();
- MutableInt labelCount = labels.get(label);
- if (labelCount != null) {
- labelCount.increment();
- } else {
- labels.put(label, new MutableInt(1));
- }
- }
-
- // Calculate the labels with maximum frequency
- List<Id> maxLabels = new ArrayList<>();
- int maxFreq = 1;
- for (Map.Entry<Id, MutableInt> e : labels.entrySet()) {
- int value = e.getValue().intValue();
- if (value > maxFreq) {
- maxFreq = value;
- maxLabels.clear();
- }
- if (value == maxFreq) {
- maxLabels.add(e.getKey());
- }
- }
-
- // Random choice
- int selected = this.random.nextInt(maxLabels.size());
- return maxLabels.get(selected);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/lpa/LpaParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/lpa/LpaParams.java
deleted file mode 100644
index 9839f2b2..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/lpa/LpaParams.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.lpa;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-
-public class LpaParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- Lpa.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- BYTESID_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- BYTESID_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_ID_OUTPUT_CLASS_NAME);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCount.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCount.java
deleted file mode 100644
index 7fa082d0..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCount.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.trianglecount;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.edge.Edges;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.IdSet;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-
-public class TriangleCount implements Computation<IdList> {
-
- @Override
- public String name() {
- return "triangle_count";
- }
-
- @Override
- public String category() {
- return "community";
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- IdSet selfId = new IdSet();
- selfId.add(vertex.id());
-
- context.sendMessageToAllEdgesIf(vertex, selfId, (ids, targetId) -> {
- return !vertex.id().equals(targetId);
- });
- vertex.value(new TriangleCountValue());
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<IdList> messages) {
- IdSet neighbors = ((TriangleCountValue) vertex.value()).idSet();
- Integer count = this.triangleCount(context, vertex, messages, neighbors);
- if (count != null) {
- ((TriangleCountValue) vertex.value()).count(count);
- vertex.inactivate();
- }
- }
-
- protected Integer triangleCount(ComputationContext context, Vertex vertex,
- Iterator<IdList> messages, IdSet neighbors) {
- if (context.superstep() == 1) {
- // Collect outgoing neighbors
- Set<Id> outNeighbors = getOutNeighbors(vertex);
- neighbors.addAll(outNeighbors);
-
- // Collect incoming neighbors
- while (messages.hasNext()) {
- IdList idList = messages.next();
- assert idList.size() == 1;
- Id inId = idList.get(0);
- if (!outNeighbors.contains(inId)) {
- neighbors.add(inId);
- }
- }
-
- // Send all neighbors to neighbors
- for (Id targetId : neighbors.value()) {
- context.sendMessage(targetId, neighbors);
- }
- } else if (context.superstep() == 2) {
- int count = 0;
-
- while (messages.hasNext()) {
- IdList twoDegreeNeighbors = messages.next();
- for (Id twoDegreeNeighbor : twoDegreeNeighbors.values()) {
- if (neighbors.contains(twoDegreeNeighbor)) {
- count++;
- }
- }
- }
-
- return count >> 1;
- }
- return null;
- }
-
- private static Set<Id> getOutNeighbors(Vertex vertex) {
- Set<Id> outNeighbors = new HashSet<>();
- Edges edges = vertex.edges();
- for (Edge edge : edges) {
- Id targetId = edge.targetId();
- if (!vertex.id().equals(targetId)) {
- outNeighbors.add(targetId);
- }
- }
- return outNeighbors;
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountParams.java
deleted file mode 100644
index 799da979..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountParams.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.trianglecount;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.config.EdgeFrequency;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-
-public class TriangleCountParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- TriangleCount.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- IdList.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- TriangleCountValue.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_INT_OUTPUT_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.name(),
- EdgeFrequency.SINGLE.name());
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountValue.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountValue.java
deleted file mode 100644
index b50007d0..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountValue.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.trianglecount;
-
-import java.io.IOException;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-import com.baidu.hugegraph.computer.core.graph.value.IdSet;
-import com.baidu.hugegraph.computer.core.graph.value.IntValue;
-import com.baidu.hugegraph.computer.core.graph.value.Value.CustomizeValue;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-
-public class TriangleCountValue implements CustomizeValue<Integer> {
-
- private IdSet idSet;
- private IntValue count;
-
- public TriangleCountValue() {
- this.idSet = new IdSet();
- this.count = new IntValue();
- }
-
- public IdSet idSet() {
- return this.idSet;
- }
-
- public int count() {
- return this.count.intValue();
- }
-
- public void count(int count) {
- this.count.value(count);
- }
-
- @Override
- public TriangleCountValue copy() {
- TriangleCountValue triangleCountValue = new TriangleCountValue();
- triangleCountValue.idSet = this.idSet.copy();
- triangleCountValue.count = this.count.copy();
- return triangleCountValue;
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.idSet.read(in);
- this.count.read(in);
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.idSet.write(out);
- this.count.write(out);
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("idSet", this.idSet)
- .append("count", this.count).toString();
- }
-
- @Override
- public Integer value() {
- return this.count.value();
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/Wcc.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/Wcc.java
deleted file mode 100644
index 071af0e7..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/Wcc.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.wcc;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.core.combiner.Combiner;
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-
-/**
- * Wcc stands for Weak Connected Component.
- */
-public class Wcc implements Computation<Id> {
-
- @Override
- public String name() {
- return "wcc";
- }
-
- @Override
- public String category() {
- return "community";
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- Id min = vertex.id();
- for (Edge edge : vertex.edges()) {
- if (edge.targetId().compareTo(min) < 0) {
- min = edge.targetId();
- }
- }
- Id value = min;
- vertex.value(value);
- vertex.inactivate();
- context.sendMessageToAllEdgesIf(vertex, value, (result, target) -> {
- return result.compareTo(target) < 0;
- });
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<Id> messages) {
- Id message = Combiner.combineAll(context.combiner(), messages);
- Id value = vertex.value();
- if (value.compareTo(message) > 0) {
- vertex.value(message);
- context.sendMessageToAllEdges(vertex, message);
- }
- vertex.inactivate();
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/WccParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/WccParams.java
deleted file mode 100644
index 192169bd..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/WccParams.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.community.wcc;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.combiner.ValueMinCombiner;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-
-public class WccParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- Wcc.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- BYTESID_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- BYTESID_CLASS_NAME);
- this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
- ValueMinCombiner.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- HUGEGRAPH_ID_OUTPUT_CLASS_NAME);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetection.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetection.java
deleted file mode 100644
index 4527065a..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetection.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.IdListList;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-
-public class RingsDetection implements Computation<IdList> {
-
- @Override
- public String name() {
- return "rings";
- }
-
- @Override
- public String category() {
- return "path";
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- vertex.value(new IdListList());
- if (vertex.edges().size() == 0) {
- return;
- }
-
- // Init path
- Id id = vertex.id();
- IdList path = new IdList();
- path.add(id);
-
- for (Edge edge : vertex.edges()) {
- /*
- * Only send path to vertex whose id is larger than
- * or equals current vertex id
- */
- if (id.compareTo(edge.targetId()) <= 0) {
- context.sendMessage(edge.targetId(), path);
- }
- }
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<IdList> messages) {
- Id id = vertex.id();
- boolean halt = true;
- while (messages.hasNext()) {
- halt = false;
- IdList sequence = messages.next();
- if (id.equals(sequence.get(0))) {
- // Use the smallest vertex record ring
- boolean isMin = true;
- for (int i = 1; i < sequence.size(); i++) {
- Id pathVertexValue = sequence.get(i);
- if (id.compareTo(pathVertexValue) > 0) {
- isMin = false;
- break;
- }
- }
- if (isMin) {
- sequence.add(id);
- IdListList sequences = vertex.value();
- sequences.add(sequence);
- }
- } else {
- boolean contains = false;
- // Drop sequence if path contains this vertex
- for (int i = 0; i < sequence.size(); i++) {
- Id pathVertexValue = sequence.get(i);
- if (pathVertexValue.equals(vertex.id())) {
- contains = true;
- break;
- }
- }
- // Field ringId is smallest vertex id in path
- Id ringId = sequence.get(0);
- if (!contains) {
- sequence.add(vertex.id());
- for (Edge edge : vertex.edges()) {
- if (ringId.compareTo(edge.targetId()) <= 0) {
- context.sendMessage(edge.targetId(), sequence);
- }
- }
- }
- }
- }
- if (halt) {
- vertex.inactivate();
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java
deleted file mode 100644
index d74ec6f2..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.baidu.hugegraph.computer.core.graph.value.IdListList;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput;
-
-public class RingsDetectionOutput extends HugeGraphOutput<List<String>> {
-
- @Override
- protected void prepareSchema() {
- this.client().schema().propertyKey(this.name())
- .asText()
- .writeType(this.writeType())
- .valueList()
- .ifNotExist()
- .create();
- }
-
- @Override
- protected List<String> value(Vertex vertex) {
- IdListList value = vertex.value();
- List<String> propValues = new ArrayList<>();
- for (int i = 0; i < value.size(); i++) {
- propValues.add(value.get(i).toString());
- }
- return propValues;
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionParams.java
deleted file mode 100644
index 55ded11e..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionParams.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.IdListList;
-
-public class RingsDetectionParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- RingsDetection.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- IdList.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- IdListList.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- RingsDetectionOutput.class.getName());
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/FilterDescribe.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/FilterDescribe.java
deleted file mode 100644
index 38dbc41b..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/FilterDescribe.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings.filter;
-
-import java.util.List;
-
-import org.apache.commons.collections.CollectionUtils;
-
-import org.apache.hugegraph.util.JsonUtil;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.collect.ImmutableList;
-
-public class FilterDescribe {
-
- private final List<DescribeItem> vertexFilter;
- private final List<DescribeItem> edgeFilter;
-
- @JsonCreator
- private FilterDescribe(@JsonProperty("vertex_filter")
- List<DescribeItem> vertexFilter,
- @JsonProperty("edge_filter")
- List<DescribeItem> edgeFilter) {
- this.vertexFilter = CollectionUtils.isEmpty(vertexFilter) ?
- ImmutableList.of() :
- ImmutableList.copyOf(vertexFilter);
- this.edgeFilter = CollectionUtils.isEmpty(edgeFilter) ?
- ImmutableList.of() :
- ImmutableList.copyOf(edgeFilter);
- }
-
- public static FilterDescribe of(String describe) {
- return JsonUtil.fromJson(describe, FilterDescribe.class);
- }
-
- public List<DescribeItem> vertexFilter() {
- return this.vertexFilter;
- }
-
- public List<DescribeItem> edgeFilter() {
- return this.edgeFilter;
- }
-
- public static class DescribeItem {
-
- private final String label;
- private final String propertyFilter;
-
- @JsonCreator
- private DescribeItem(@JsonProperty(value = "label",
- required = true)
- String label,
- @JsonProperty(value = "property_filter",
- required = true)
- String propertyFilter) {
- this.label = label;
- this.propertyFilter = propertyFilter;
- }
-
- public String label() {
- return this.label;
- }
-
- public String propertyFilter() {
- return this.propertyFilter;
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionMessage.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionMessage.java
deleted file mode 100644
index 31649a47..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionMessage.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings.filter;
-
-import java.io.IOException;
-import java.util.List;
-
-import com.baidu.hugegraph.computer.core.common.ComputerContext;
-import com.baidu.hugegraph.computer.core.graph.GraphFactory;
-import com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties;
-import com.baidu.hugegraph.computer.core.graph.properties.Properties;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.Value.CustomizeValue;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.io.RandomAccessInput;
-import com.baidu.hugegraph.computer.core.io.RandomAccessOutput;
-
-public class RingsDetectionMessage implements CustomizeValue<List<Object>> {
-
- private final IdList path;
- private Properties walkEdgeProps;
-
- public RingsDetectionMessage() {
- GraphFactory graphFactory = ComputerContext.instance().graphFactory();
- this.path = new IdList();
- this.walkEdgeProps = new DefaultProperties(graphFactory);
- }
-
- @Override
- public void read(RandomAccessInput in) throws IOException {
- this.path.read(in);
- this.walkEdgeProps.read(in);
- }
-
- @Override
- public void write(RandomAccessOutput out) throws IOException {
- this.path.write(out);
- this.walkEdgeProps.write(out);
- }
-
- public IdList path() {
- return this.path;
- }
-
- public void addPath(Vertex vertex) {
- this.path.add(vertex.id());
- }
-
- public Properties walkEdgeProp() {
- return this.walkEdgeProps;
- }
-
- public void walkEdgeProp(Properties properties) {
- this.walkEdgeProps = properties;
- }
-
- @Override
- public List<Object> value() {
- return this.path.value();
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilter.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilter.java
deleted file mode 100644
index 8e349357..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings.filter;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.id.Id;
-import com.baidu.hugegraph.computer.core.graph.value.IdList;
-import com.baidu.hugegraph.computer.core.graph.value.IdListList;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.baidu.hugegraph.computer.core.worker.Computation;
-import com.baidu.hugegraph.computer.core.worker.ComputationContext;
-
-public class RingsDetectionWithFilter
- implements Computation<RingsDetectionMessage> {
-
- public static final String OPTION_FILTER = "rings.property_filter";
-
- private SpreadFilter filter;
-
- @Override
- public String name() {
- return "rings_with_filter";
- }
-
- @Override
- public String category() {
- return "path";
- }
-
- @Override
- public void init(Config config) {
- this.filter = new SpreadFilter(config.getString(OPTION_FILTER, "{}"));
- }
-
- @Override
- public void compute0(ComputationContext context, Vertex vertex) {
- vertex.value(new IdListList());
- if (vertex.edges().size() == 0 || !this.filter.filter(vertex)) {
- return;
- }
-
- RingsDetectionMessage message = new RingsDetectionMessage();
- message.addPath(vertex);
- for (Edge edge : vertex.edges()) {
- if (this.filter.filter(edge)) {
- message.walkEdgeProp(edge.properties());
- context.sendMessage(edge.targetId(), message);
- }
- }
- }
-
- @Override
- public void compute(ComputationContext context, Vertex vertex,
- Iterator<RingsDetectionMessage> messages) {
- boolean halt = true;
- if (this.filter.filter(vertex)) {
- Id vertexId = vertex.id();
- while (messages.hasNext()) {
- halt = false;
- RingsDetectionMessage message = messages.next();
- IdList path = message.path();
- if (vertexId.equals(path.get(0))) {
- // Use the smallest vertex record ring
- boolean isMin = true;
- for (int i = 0; i < path.size(); i++) {
- Id pathVertexValue = path.get(i);
- if (vertexId.compareTo(pathVertexValue) > 0) {
- isMin = false;
- break;
- }
- }
- if (isMin) {
- path.add(vertexId);
- IdListList value = vertex.value();
- value.add(path.copy());
- }
- } else {
- boolean contains = false;
- // Drop sequence if path contains this vertex
- for (int i = 0; i < path.size(); i++) {
- Id pathVertexValue = path.get(i);
- if (pathVertexValue.equals(vertex.id())) {
- contains = true;
- break;
- }
- }
- if (!contains) {
- path.add(vertex.id());
- for (Edge edge : vertex.edges()) {
- if (this.filter.filter(edge, message)) {
- message.walkEdgeProp(edge.properties());
- context.sendMessage(edge.targetId(), message);
- }
- }
- }
- }
- }
- }
- if (halt) {
- vertex.inactivate();
- }
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilterParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilterParams.java
deleted file mode 100644
index 35571243..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilterParams.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings.filter;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.algorithm.AlgorithmParams;
-import com.baidu.hugegraph.computer.algorithm.path.rings.RingsDetectionOutput;
-import com.baidu.hugegraph.computer.core.config.ComputerOptions;
-import com.baidu.hugegraph.computer.core.graph.value.IdListList;
-
-public class RingsDetectionWithFilterParams implements AlgorithmParams {
-
- @Override
- public void setAlgorithmParameters(Map<String, String> params) {
- this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
- RingsDetectionWithFilter.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
- IdListList.class.getName());
- this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
- RingsDetectionMessage.class.getName());
- this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
- RingsDetectionOutput.class.getName());
- this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS,
- EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME);
- }
-}
diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java
deleted file mode 100644
index fa197b58..00000000
--- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm.path.rings.filter;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Predicate;
-
-import org.mvel2.MVEL;
-
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class SpreadFilter {
-
- private static final String ALL = "*";
- private static final String MESSAGE = "$message";
- private static final String ELEMENT = "$element";
- private static final List<Serializable> PASS = ImmutableList.of();
-
- private final Map<String, Serializable> vertexFilter;
- private final Map<String, Serializable> edgeSpreadFilter;
- private final Map<String, Serializable> edgeFilter;
-
- public SpreadFilter(String describe) {
- FilterDescribe des = FilterDescribe.of(describe);
-
- this.vertexFilter = new HashMap<>();
- this.edgeSpreadFilter = new HashMap<>();
- this.edgeFilter = new HashMap<>();
-
- this.init(this.vertexFilter, des.vertexFilter(), expression -> true);
- this.init(this.edgeSpreadFilter, des.edgeFilter(), expression -> true);
- // TODO: Use a better scheme to parse expressions with only $element
- this.init(this.edgeFilter, des.edgeFilter(), expression -> {
- return !expression.contains(MESSAGE);
- });
- }
-
- private void init(Map<String, Serializable> filter,
- List<FilterDescribe.DescribeItem> describes,
- Predicate<? super String> predicate) {
- for (FilterDescribe.DescribeItem describe : describes) {
- String labelName = describe.label();
- String propertyFilter = describe.propertyFilter();
- if (predicate.test(propertyFilter) || ALL.equals(labelName)) {
- Serializable expression = MVEL.compileExpression(
- describe.propertyFilter());
- filter.put(labelName, expression);
- }
- }
- }
-
- public boolean filter(Vertex vertex) {
- String label = vertex.label();
- List<Serializable> expressions = expressions(this.vertexFilter, label);
-
- if (expressions == PASS) {
- return true;
- }
-
- Map<String, Map<String, Value>> params =
- ImmutableMap.of(ELEMENT, vertex.properties().get());
- return filter(params, expressions);
- }
-
- public boolean filter(Edge edge) {
- String label = edge.label();
- List<Serializable> expressions = expressions(this.edgeFilter, label);
-
- if (expressions == PASS) {
- return true;
- }
-
- Map<String, Map<String, Value>> params =
- ImmutableMap.of(ELEMENT, edge.properties().get());
- return filter(params, expressions);
- }
-
- public boolean filter(Edge edge, RingsDetectionMessage message) {
- String label = edge.label();
- List<Serializable> expressions = expressions(this.edgeSpreadFilter,
- label);
-
- if (expressions == PASS) {
- return true;
- }
-
- Map<String, Map<String, Value>> params =
- ImmutableMap.of(ELEMENT, edge.properties().get(),
- MESSAGE, message.walkEdgeProp().get());
- return filter(params, expressions);
- }
-
- private static boolean filter(Map<String, Map<String, Value>> params,
- List<Serializable> expressions) {
- Map<String, Object> map = convertParamsValueToObject(params);
- return expressions.stream()
- .allMatch(expression -> {
- return (Boolean) MVEL.executeExpression(
- expression, map);
- });
- }
-
- private static List<Serializable> expressions(
- Map<String, Serializable> filter,
- String label) {
- if (filter.size() == 0) {
- return PASS;
- }
- List<Serializable> expressions = new ArrayList<>();
- if (filter.containsKey(ALL)) {
- expressions.add(filter.get(ALL));
- }
- if (filter.containsKey(label)) {
- expressions.add(filter.get(label));
- }
-
- return expressions;
- }
-
- private static Map<String, Object> convertParamsValueToObject(
- Map<String, Map<String, Value>> params) {
- Map<String, Object> result = new HashMap<>();
- for (Map.Entry<String, Map<String, Value>> entry : params.entrySet()) {
- Map<String, Object> subKv = new HashMap<>();
- Map<String, Value> param = entry.getValue();
- for (Map.Entry<String, Value> paramItem : param.entrySet()) {
- subKv.put(paramItem.getKey(), paramItem.getValue().value());
- }
- result.put(entry.getKey(), subKv);
- }
- return result;
- }
-}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentrality.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentrality.java
new file mode 100644
index 00000000..12d7bd86
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentrality.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.betweenness;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.hugegraph.computer.core.common.exception.ComputerException;
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.IdSet;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+import org.apache.hugegraph.util.Log;
+import org.slf4j.Logger;
+
+public class BetweennessCentrality implements Computation<BetweennessMessage> {
+
+ private static final Logger LOG = Log.logger(BetweennessCentrality.class);
+
+ public static final String OPTION_SAMPLE_RATE =
+ "betweenness_centrality.sample_rate";
+
+ private double sampleRate;
+ /*
+ * Record the number of shortest paths for intermediate vertex, suppose
+ * there are two shortest paths from A(source vertex) to E(current vertex),
+ * [A -> B -> C -> E] and [A -> B -> D -> E]
+ *
+ * The saved data is as follows
+ * A: B:2
+ * C:1
+ * D:1
+ * totalCount:2
+ */
+ private Map<Id, SeqCount> seqTable;
+
+ @Override
+ public String name() {
+ return "betweenness_centrality";
+ }
+
+ @Override
+ public String category() {
+ return "centrality";
+ }
+
+ @Override
+ public void init(Config config) {
+ this.sampleRate = config.getDouble(OPTION_SAMPLE_RATE, 1.0D);
+ if (this.sampleRate <= 0.0D || this.sampleRate > 1.0D) {
+ throw new ComputerException("The param %s must be in (0.0, 1.0], " +
+ "actual got '%s'",
+ OPTION_SAMPLE_RATE, this.sampleRate);
+ }
+ this.seqTable = new HashMap<>();
+ }
+
+ @Override
+ public void close(Config config) {
+ // pass
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ // First superstep is special, we just send vertex id to its neighbors
+ BetweennessValue initialValue = new BetweennessValue(0.0D);
+ initialValue.arrivedVertices().add(vertex.id());
+ vertex.value(initialValue);
+ if (vertex.numEdges() == 0) {
+ return;
+ }
+
+ IdList sequence = new IdList();
+ sequence.add(vertex.id());
+ context.sendMessageToAllEdges(vertex, new BetweennessMessage(sequence));
+ LOG.info("Finished compute-0 step");
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<BetweennessMessage> messages) {
+ BetweennessValue value = vertex.value();
+ // The betweenness value to be updated
+ DoubleValue betweenness = value.betweenness();
+ // Collect the vertices sent here this time
+ IdSet arrivingVertices = new IdSet();
+ while (messages.hasNext()) {
+ BetweennessMessage message = messages.next();
+ // The value contributed to the intermediate node on the path
+ DoubleValue vote = message.vote();
+ betweenness.value(betweenness.value() + vote.value());
+
+ this.forward(context, vertex, message.sequence(), arrivingVertices);
+ }
+ value.arrivedVertices().addAll(arrivingVertices);
+
+ boolean active = !this.seqTable.isEmpty();
+ if (active) {
+ this.sendMessage(context);
+ this.seqTable.clear();
+ } else {
+ vertex.inactivate();
+ }
+ }
+
+ private void forward(ComputationContext context, Vertex vertex,
+ IdList sequence, IdSet arrivingVertices) {
+ if (sequence.size() == 0) {
+ return;
+ }
+
+ BetweennessValue value = vertex.value();
+ IdSet arrivedVertices = value.arrivedVertices();
+ Id source = sequence.get(0);
+ // The source vertex is arriving at first time
+ if (!arrivedVertices.contains(source)) {
+ arrivingVertices.add(source);
+
+ SeqCount seqCount = this.seqTable.computeIfAbsent(
+ source, k -> new SeqCount());
+ seqCount.totalCount++;
+ // Accumulate the number of shortest paths for intermediate vertices
+ for (int i = 1; i < sequence.size(); i++) {
+ Id id = sequence.get(i);
+ Map<Id, Integer> idCounts = seqCount.idCount;
+ idCounts.put(id, idCounts.getOrDefault(id, 0) + 1);
+ }
+
+ Id selfId = vertex.id();
+ sequence.add(selfId);
+ BetweennessMessage newMessage = new BetweennessMessage(sequence);
+ for (Edge edge : vertex.edges()) {
+ Id targetId = edge.targetId();
+ if (this.sample(selfId, targetId, edge) &&
+ !sequence.contains(targetId)) {
+ context.sendMessage(targetId, newMessage);
+ }
+ }
+ }
+ }
+
+ private void sendMessage(ComputationContext context) {
+ for (SeqCount seqCount : this.seqTable.values()) {
+ for (Map.Entry<Id, Integer> entry : seqCount.idCount.entrySet()) {
+ double vote = (double) entry.getValue() / seqCount.totalCount;
+ BetweennessMessage voteMessage = new BetweennessMessage(
+ new DoubleValue(vote));
+
+ context.sendMessage(entry.getKey(), voteMessage);
+ }
+ }
+ }
+
+ private boolean sample(Id sourceId, Id targetId, Edge edge) {
+ // Now just use the simplest way
+ return Math.random() <= this.sampleRate;
+ }
+
+ private static class SeqCount {
+
+ private final Map<Id, Integer> idCount;
+ private int totalCount;
+
+ public SeqCount() {
+ this.idCount = new HashMap<>();
+ this.totalCount = 0;
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityParams.java
new file mode 100644
index 00000000..bb7d288e
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityParams.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.betweenness;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.algorithm.centrality.closeness.ClosenessCentrality;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.master.DefaultMasterComputation;
+
+public class BetweennessCentralityParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
+ DefaultMasterComputation.class.getName());
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ BetweennessCentrality.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ BetweennessValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ BetweennessMessage.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS,
+ EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME);
+ this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE,
+ "0.5D");
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessMessage.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessMessage.java
new file mode 100644
index 00000000..436c0808
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessMessage.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.betweenness;
+
+import java.io.IOException;
+
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.Value;
+import org.apache.hugegraph.computer.core.graph.value.Value.CustomizeValue;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+import org.apache.hugegraph.util.E;
+
+public class BetweennessMessage implements CustomizeValue<BetweennessMessage> {
+
+ private final IdList sequence;
+ private final DoubleValue vote;
+
+ public BetweennessMessage() {
+ this.sequence = new IdList();
+ this.vote = new DoubleValue(0.0D);
+ }
+
+ public BetweennessMessage(IdList sequence) {
+ this.sequence = sequence;
+ this.vote = new DoubleValue();
+ }
+
+ public BetweennessMessage(DoubleValue betweenness) {
+ this.sequence = new IdList();
+ this.vote = betweenness;
+ }
+
+ public IdList sequence() {
+ return this.sequence;
+ }
+
+ public DoubleValue vote() {
+ return this.vote;
+ }
+
+ @Override
+ public BetweennessMessage value() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.sequence.read(in);
+ this.vote.read(in);
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.sequence.write(out);
+ this.vote.write(out);
+ }
+
+ @Override
+ public int compareTo(Value value) {
+ E.checkArgument(value instanceof BetweennessMessage,
+ "The BetweennessMessage can't compare with class '%s'",
+ value.getClass());
+ BetweennessMessage other = (BetweennessMessage) value;
+ E.checkArgument(this.sequence.size() != 0, "Sequence can't be empty");
+ E.checkArgument(other.sequence.size() != 0, "Sequence can't be empty");
+ Id selfSourceId = this.sequence.get(0);
+ Id otherSourceId = other.sequence.get(0);
+ return selfSourceId.compareTo(otherSourceId);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessValue.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessValue.java
new file mode 100644
index 00000000..2ebf9525
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/betweenness/BetweennessValue.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.betweenness;
+
+import java.io.IOException;
+
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.IdSet;
+import org.apache.hugegraph.computer.core.graph.value.Value.CustomizeValue;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+
+public class BetweennessValue implements CustomizeValue<Double> {
+
+ private final DoubleValue betweenness;
+ private final IdSet arrivedVertices;
+
+ public BetweennessValue() {
+ this(0.0D);
+ }
+
+ public BetweennessValue(double betweenness) {
+ this.betweenness = new DoubleValue(betweenness);
+ this.arrivedVertices = new IdSet();
+ }
+
+ public DoubleValue betweenness() {
+ return this.betweenness;
+ }
+
+ public IdSet arrivedVertices() {
+ return this.arrivedVertices;
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.betweenness.read(in);
+ this.arrivedVertices.read(in);
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.betweenness.write(out);
+ this.arrivedVertices.write(out);
+ }
+
+ @Override
+ public Double value() {
+ return this.betweenness.value();
+ }
+
+ @Override
+ public String string() {
+ return this.value().toString();
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java
new file mode 100644
index 00000000..db6be5d6
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentrality.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.closeness;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.core.common.exception.ComputerException;
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.Value;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+import org.apache.hugegraph.util.Log;
+import org.apache.hugegraph.util.NumericUtil;
+import org.slf4j.Logger;
+
+public class ClosenessCentrality implements Computation<ClosenessMessage> {
+
+ private static final Logger LOG = Log.logger(ClosenessCentrality.class);
+
+ public static final String OPTION_WEIGHT_PROPERTY =
+ "closeness_centrality.weight_property";
+ public static final String OPTION_SAMPLE_RATE =
+ "closeness_centrality.sample_rate";
+
+ private String weightProp;
+ private double sampleRate;
+
+ @Override
+ public String name() {
+ return "closeness_centrality";
+ }
+
+ @Override
+ public String category() {
+ return "centrality";
+ }
+
+ @Override
+ public void init(Config config) {
+ this.weightProp = config.getString(OPTION_WEIGHT_PROPERTY, "");
+ this.sampleRate = config.getDouble(OPTION_SAMPLE_RATE, 1.0D);
+ if (this.sampleRate <= 0.0D || this.sampleRate > 1.0D) {
+ throw new ComputerException("The param %s must be in (0.0, 1.0], " +
+ "actual got '%s'",
+ OPTION_SAMPLE_RATE, this.sampleRate);
+ }
+ }
+
+ @Override
+ public void close(Config config) {
+ // pass
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ // Set empty map as initial value
+ vertex.value(new ClosenessValue());
+
+ // Send messages to adjacent edges
+ for (Edge edge : vertex.edges()) {
+ Id senderId = vertex.id();
+ // Get property value
+ double value = this.weightValue(edge.property(this.weightProp));
+ DoubleValue distance = new DoubleValue(value);
+ ClosenessMessage message = new ClosenessMessage(senderId, senderId,
+ distance);
+ context.sendMessage(edge.targetId(), message);
+ }
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<ClosenessMessage> messages) {
+ Id selfId = vertex.id();
+ // Save the distance from other vertices to self
+ ClosenessValue localValue = vertex.value();
+ boolean active = false;
+ while (messages.hasNext()) {
+ active = true;
+ ClosenessMessage message = messages.next();
+ Id senderId = message.senderId();
+ // In theory, it won't happen, defensive programming
+ if (selfId.equals(senderId)) {
+ continue;
+ }
+ Id startId = message.startId();
+ if (selfId.equals(startId)) {
+ continue;
+ }
+
+ DoubleValue oldValue = localValue.get(startId);
+ DoubleValue newValue = message.distance();
+ // If the id already exists and the new value >= old value, skip it
+ if (oldValue != null && newValue.compareTo(oldValue) >= 0) {
+ continue;
+ }
+ // Update local saved values (take smaller value)
+ localValue.put(startId, newValue);
+ // Send this smaller value to neighbors
+ this.sendMessage(context, vertex, senderId, startId, newValue);
+ }
+ if (!active) {
+ vertex.inactivate();
+ }
+ }
+
+ private void sendMessage(ComputationContext context, Vertex vertex,
+ Id senderId, Id startId, DoubleValue newValue) {
+ Id selfId = vertex.id();
+ double baseNewValue = this.weightValue(newValue);
+ for (Edge edge : vertex.edges()) {
+ Id targetId = edge.targetId();
+ if (senderId.equals(targetId) || startId.equals(targetId)) {
+ continue;
+ }
+ if (!sample(selfId, targetId, edge)) {
+ continue;
+ }
+ // Update distance information
+ double updatedValue = baseNewValue + this.weightValue(edge.property(
+ this.weightProp));
+ DoubleValue newDistance = new DoubleValue(updatedValue);
+ ClosenessMessage message = new ClosenessMessage(selfId, startId,
+ newDistance);
+ context.sendMessage(targetId, message);
+ }
+ }
+
+ private boolean sample(Id sourceId, Id targetId, Edge edge) {
+ // Now just use the simplest way
+ return Math.random() <= this.sampleRate;
+ }
+
+ private double weightValue(Value rawValue) {
+ if (rawValue == null) {
+ return 1.0D;
+ }
+ if (rawValue.isNumber()) {
+ return NumericUtil.convertToNumber(rawValue).doubleValue();
+ } else {
+ throw new ComputerException("The weight property can only be " +
+ "either Long or Int or Double or " +
+ "Float, but got %s",
+ rawValue.valueType());
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityParams.java
new file mode 100644
index 00000000..d62d1bf8
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityParams.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.closeness;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.master.DefaultMasterComputation;
+
+public class ClosenessCentralityParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
+ DefaultMasterComputation.class.getName());
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ ClosenessCentrality.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ ClosenessValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ ClosenessMessage.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS,
+ EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME);
+ this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE,
+ "0.5D");
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessMessage.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessMessage.java
new file mode 100644
index 00000000..4c15baf7
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessMessage.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.closeness;
+
+import java.io.IOException;
+
+import org.apache.hugegraph.computer.core.common.ComputerContext;
+import org.apache.hugegraph.computer.core.graph.GraphFactory;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.id.IdFactory;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.Value.CustomizeValue;
+import org.apache.hugegraph.computer.core.graph.value.ValueType;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+
+public class ClosenessMessage implements CustomizeValue<ClosenessMessage> {
+
+ private final GraphFactory graphFactory;
+
+ private Id senderId;
+ private Id startId;
+ private DoubleValue distance;
+
+ public ClosenessMessage() {
+ this(IdFactory.createId(), IdFactory.createId(), new DoubleValue(0.0D));
+ }
+
+ public ClosenessMessage(Id senderId, Id startId, DoubleValue distance) {
+ this.graphFactory = ComputerContext.instance().graphFactory();
+ this.senderId = senderId;
+ this.startId = startId;
+ this.distance = distance;
+ }
+
+ public Id senderId() {
+ return this.senderId;
+ }
+
+ public Id startId() {
+ return this.startId;
+ }
+
+ public DoubleValue distance() {
+ return this.distance;
+ }
+
+ @Override
+ public ClosenessMessage value() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.senderId = this.graphFactory.createId();
+ this.senderId.read(in);
+
+ this.startId = this.graphFactory.createId();
+ this.startId.read(in);
+
+ this.distance = (DoubleValue) this.graphFactory.createValue(
+ ValueType.DOUBLE);
+ this.distance.read(in);
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.senderId.write(out);
+ this.startId.write(out);
+ this.distance.write(out);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java
new file mode 100644
index 00000000..4e167407
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/closeness/ClosenessValue.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.closeness;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.MapValue;
+
+public class ClosenessValue extends MapValue<DoubleValue> {
+
+ @Override
+ public Double value() {
+ // Cumulative distance
+ double centrality = 0;
+ for (Map.Entry<Id, DoubleValue> entry : this.entrySet()) {
+ centrality += 1.0D / entry.getValue().value();
+ }
+ return centrality;
+ }
+
+ @Override
+ public String string() {
+ return this.value().toString();
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/degree/DegreeCentrality.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/degree/DegreeCentrality.java
new file mode 100644
index 00000000..105746ef
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/degree/DegreeCentrality.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.degree;
+
+import java.util.Iterator;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.hugegraph.computer.core.common.exception.ComputerException;
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.NullValue;
+import org.apache.hugegraph.computer.core.graph.value.Value;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+import org.apache.hugegraph.computer.core.worker.WorkerContext;
+import org.apache.hugegraph.util.NumericUtil;
+
+public class DegreeCentrality implements Computation<NullValue> {
+
+ public static final String OPTION_WEIGHT_PROPERTY = "degree_centrality.weight_property";
+
+ private boolean calculateByWeightProperty;
+ private String weightProperty;
+
+ @Override
+ public String name() {
+ return "degree_centrality";
+ }
+
+ @Override
+ public String category() {
+ return "centrality";
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ if (!this.calculateByWeightProperty) {
+ vertex.value(new DoubleValue(vertex.numEdges()));
+ } else {
+ /*
+ * TODO: Here we use doubleValue type now, we will use BigDecimal
+ * and output "BigDecimalValue" to resolve double type overflow
+ * int the future;
+ */
+ double totalWeight = 0.0;
+ for (Edge edge : vertex.edges()) {
+ double weight = weightValue(edge.property(this.weightProperty));
+ totalWeight += weight;
+ if (Double.isInfinite(totalWeight)) {
+ throw new ComputerException("Calculate weight overflow, " +
+ "current is %s, edge '%s' " +
+ "is %s", totalWeight, edge, weight);
+ }
+ }
+ vertex.value(new DoubleValue(totalWeight));
+ }
+ vertex.inactivate();
+ }
+
+ private static double weightValue(Value value) {
+ if (value == null) {
+ return 1.0;
+ }
+
+ switch (value.valueType()) {
+ case LONG:
+ case INT:
+ case DOUBLE:
+ case FLOAT:
+ return NumericUtil.convertToNumber(value).doubleValue();
+ default:
+ throw new ComputerException("The weight property can only be " +
+ "either Long or Int or Double or " +
+ "Float, but got %s",
+ value.valueType());
+ }
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<NullValue> messages) {
+ // pass
+ }
+
+ @Override
+ public void init(Config config) {
+ this.weightProperty = config.getString(
+ OPTION_WEIGHT_PROPERTY, "");
+ this.calculateByWeightProperty = StringUtils.isNotEmpty(
+ this.weightProperty);
+ }
+
+ @Override
+ public void close(Config config) {
+ // pass
+ }
+
+ @Override
+ public void beforeSuperstep(WorkerContext context) {
+ // pass
+ }
+
+ @Override
+ public void afterSuperstep(WorkerContext context) {
+ // pass
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityParams.java
new file mode 100644
index 00000000..4b5744ac
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityParams.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.degree;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.combiner.DoubleValueSumCombiner;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.master.DefaultMasterComputation;
+
+public class DegreeCentralityParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
+ DefaultMasterComputation.class.getName());
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ DegreeCentrality.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ DoubleValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ DoubleValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
+ DoubleValueSumCombiner.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRank.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRank.java
new file mode 100644
index 00000000..27891b3e
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRank.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.pagerank;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.core.aggregator.Aggregator;
+import org.apache.hugegraph.computer.core.combiner.Combiner;
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.LongValue;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+import org.apache.hugegraph.computer.core.worker.WorkerContext;
+
+public class PageRank implements Computation<DoubleValue> {
+
+ public static final String OPTION_ALPHA = "page_rank.alpha";
+
+ public static final double ALPHA_DEFAULT_VALUE = 0.15;
+
+ private double alpha;
+ private double danglingRank;
+ private double initialRankInSuperstep;
+ private double cumulativeRank;
+
+ private Aggregator<DoubleValue> l1DiffAggr;
+ private Aggregator<DoubleValue> cumulativeRankAggr;
+ private Aggregator<LongValue> danglingVertexNumAggr;
+ private Aggregator<DoubleValue> danglingCumulativeAggr;
+
+ // Initial value in superstep 0.
+ private DoubleValue initialValue;
+ private DoubleValue contribValue;
+
+ @Override
+ public String name() {
+ return "page_rank";
+ }
+
+ @Override
+ public String category() {
+ return "centrality";
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ vertex.value(this.initialValue);
+ this.cumulativeRankAggr.aggregateValue(this.initialValue.value());
+ int edgeCount = vertex.numEdges();
+ if (edgeCount == 0) {
+ this.danglingVertexNumAggr.aggregateValue(1L);
+ this.danglingCumulativeAggr.aggregateValue(
+ this.initialValue.value());
+ } else {
+ this.contribValue.value(this.initialValue.value() / edgeCount);
+ context.sendMessageToAllEdges(vertex, this.contribValue);
+ }
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<DoubleValue> messages) {
+ DoubleValue message = Combiner.combineAll(context.combiner(), messages);
+ double rankFromNeighbors = 0.0;
+ if (message != null) {
+ rankFromNeighbors = message.value();
+ }
+ double rank = (this.danglingRank + rankFromNeighbors) *
+ (1.0 - this.alpha) + this.initialRankInSuperstep;
+ rank /= this.cumulativeRank;
+ DoubleValue oldRank = vertex.value();
+ vertex.value(new DoubleValue(rank));
+ this.l1DiffAggr.aggregateValue(Math.abs(oldRank.value() - rank));
+ this.cumulativeRankAggr.aggregateValue(rank);
+ int edgeCount = vertex.numEdges();
+ if (edgeCount == 0) {
+ this.danglingVertexNumAggr.aggregateValue(1L);
+ this.danglingCumulativeAggr.aggregateValue(rank);
+ } else {
+ this.contribValue.value(rank / edgeCount);
+ context.sendMessageToAllEdges(vertex, this.contribValue);
+ }
+ }
+
+ @Override
+ public void init(Config config) {
+ this.alpha = config.getDouble(OPTION_ALPHA, ALPHA_DEFAULT_VALUE);
+ this.contribValue = new DoubleValue();
+ }
+
+ @Override
+ public void close(Config config) {
+ // pass
+ }
+
+ @Override
+ public void beforeSuperstep(WorkerContext context) {
+ // Get aggregator values for computation
+ DoubleValue danglingTotalRank = context.aggregatedValue(
+ PageRank4Master.AGGR_COMULATIVE_DANGLING_PROBABILITY);
+ DoubleValue cumulativeRank = context.aggregatedValue(
+ PageRank4Master.AGGR_COMULATIVE_PROBABILITY);
+ long totalVertex = context.totalVertexCount();
+
+ this.danglingRank = danglingTotalRank.value() / totalVertex;
+ this.initialRankInSuperstep = this.alpha / totalVertex;
+ this.cumulativeRank = cumulativeRank.value();
+ this.initialValue = new DoubleValue(1.0 / totalVertex);
+
+ // Create aggregators
+ this.l1DiffAggr = context.createAggregator(
+ PageRank4Master.AGGR_L1_NORM_DIFFERENCE_KEY);
+ this.cumulativeRankAggr = context.createAggregator(
+ PageRank4Master.AGGR_COMULATIVE_PROBABILITY);
+ this.danglingVertexNumAggr = context.createAggregator(
+ PageRank4Master.AGGR_DANGLING_VERTICES_NUM);
+ this.danglingCumulativeAggr = context.createAggregator(
+ PageRank4Master.AGGR_COMULATIVE_DANGLING_PROBABILITY);
+ }
+
+ @Override
+ public void afterSuperstep(WorkerContext context) {
+ context.aggregateValue(
+ PageRank4Master.AGGR_COMULATIVE_PROBABILITY,
+ this.cumulativeRankAggr.aggregatedValue());
+ context.aggregateValue(
+ PageRank4Master.AGGR_L1_NORM_DIFFERENCE_KEY,
+ this.l1DiffAggr.aggregatedValue());
+ context.aggregateValue(
+ PageRank4Master.AGGR_DANGLING_VERTICES_NUM,
+ this.danglingVertexNumAggr.aggregatedValue());
+ context.aggregateValue(
+ PageRank4Master.AGGR_COMULATIVE_DANGLING_PROBABILITY,
+ this.danglingCumulativeAggr.aggregatedValue());
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRank4Master.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRank4Master.java
new file mode 100644
index 00000000..13a052e5
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRank4Master.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.pagerank;
+
+import org.apache.hugegraph.computer.core.combiner.DoubleValueSumCombiner;
+import org.apache.hugegraph.computer.core.combiner.LongValueSumCombiner;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+import org.apache.hugegraph.computer.core.graph.value.LongValue;
+import org.apache.hugegraph.computer.core.graph.value.ValueType;
+import org.apache.hugegraph.computer.core.master.MasterComputation;
+import org.apache.hugegraph.computer.core.master.MasterComputationContext;
+import org.apache.hugegraph.computer.core.master.MasterContext;
+import org.apache.hugegraph.util.Log;
+import org.slf4j.Logger;
+
+public class PageRank4Master implements MasterComputation {
+
+ private static final Logger LOG = Log.logger(PageRank4Master.class);
+
+ public static final String CONF_L1_NORM_DIFFERENCE_THRESHOLD_KEY =
+ "pagerank.l1DiffThreshold";
+ public static final double CONF_L1_DIFF_THRESHOLD_DEFAULT = 0.00001D;
+
+ public static final String AGGR_L1_NORM_DIFFERENCE_KEY =
+ "pagerank.aggr_l1_norm_difference";
+ public static final String AGGR_DANGLING_VERTICES_NUM =
+ "pagerank.dangling_vertices_num";
+ public static final String AGGR_COMULATIVE_DANGLING_PROBABILITY =
+ "pagerank.comulative_dangling_probability";
+ public static final String AGGR_COMULATIVE_PROBABILITY =
+ "pagerank.comulative_probability";
+
+ private double l1DiffThreshold;
+
+ @Override
+ public void init(MasterContext context) {
+ this.l1DiffThreshold = context.config().getDouble(
+ CONF_L1_NORM_DIFFERENCE_THRESHOLD_KEY,
+ CONF_L1_DIFF_THRESHOLD_DEFAULT);
+ context.registerAggregator(AGGR_DANGLING_VERTICES_NUM,
+ ValueType.LONG,
+ LongValueSumCombiner.class);
+ context.registerAggregator(AGGR_COMULATIVE_DANGLING_PROBABILITY,
+ ValueType.DOUBLE,
+ DoubleValueSumCombiner.class);
+ context.registerAggregator(AGGR_COMULATIVE_PROBABILITY,
+ ValueType.DOUBLE,
+ DoubleValueSumCombiner.class);
+ context.registerAggregator(AGGR_L1_NORM_DIFFERENCE_KEY,
+ ValueType.DOUBLE,
+ DoubleValueSumCombiner.class);
+ }
+
+ @Override
+ public void close(MasterContext context) {
+ // pass
+ }
+
+ @Override
+ public boolean compute(MasterComputationContext context) {
+ LongValue danglingVerticesNum = context.aggregatedValue(
+ AGGR_DANGLING_VERTICES_NUM);
+ DoubleValue danglingProbability = context.aggregatedValue(
+ AGGR_COMULATIVE_DANGLING_PROBABILITY);
+ DoubleValue cumulativeProbability = context.aggregatedValue(
+ AGGR_COMULATIVE_PROBABILITY);
+ DoubleValue l1NormDifference = context.aggregatedValue(
+ AGGR_L1_NORM_DIFFERENCE_KEY);
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("[Superstep ").append(context.superstep()).append("]")
+ .append(", dangling vertices num = ").append(danglingVerticesNum)
+ .append(", cumulative dangling probability = ")
+ .append(danglingProbability.value())
+ .append(", cumulative probability = ").append(cumulativeProbability)
+ .append(", l1 norm difference = ").append(l1NormDifference.value());
+
+ LOG.info("PageRank running status: {}", sb);
+ double l1Diff = l1NormDifference.value();
+ if (context.superstep() > 1 && l1Diff <= this.l1DiffThreshold) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRankParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRankParams.java
new file mode 100644
index 00000000..eb1c9302
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/centrality/pagerank/PageRankParams.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.centrality.pagerank;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.combiner.DoubleValueSumCombiner;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.graph.value.DoubleValue;
+
+public class PageRankParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.MASTER_COMPUTATION_CLASS,
+ PageRank4Master.class.getName());
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ PageRank.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ DoubleValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ DoubleValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
+ DoubleValueSumCombiner.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficient.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficient.java
new file mode 100644
index 00000000..9f9ba5e3
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficient.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.cc;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.algorithm.community.trianglecount.TriangleCount;
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.IdSet;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+/**
+ * ClusteringCoefficient(CC) algorithm could calculate local & the whole graph:
+ * 1. local cc: get triangles & degree for current vertex, calculate them
+ * 2. whole cc have 2 ways to get the result: (NOT SUPPORTED NOW)
+ * - sum all open & closed triangles in graph, and calculate the result
+ * - sum all local cc for each vertex, and use avg as the whole graph result
+ * <p>
+ * And we have 2 ways to count local cc:
+ * 1. if we already saved the triangles in each vertex, we can calculate only
+ * in superstep0/compute0 to get the result
+ * <p>
+ * The formula of local CC is: C(v) = 2T / Dv(Dv - 1)
+ * v represents one vertex, T represents the triangles of current vertex,
+ * D represents the degree of current vertex
+ */
+public class ClusteringCoefficient extends TriangleCount {
+
+ @Override
+ public String name() {
+ return "clustering_coefficient";
+ }
+
+ @Override
+ public String category() {
+ return "community";
+ }
+
+ @Override
+ public void init(Config config) {
+ // Reuse triangle count later
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ IdList selfId = new IdList();
+ selfId.add(vertex.id());
+
+ context.sendMessageToAllEdgesIf(vertex, selfId, (ids, targetId) -> {
+ return !ids.get(0).equals(targetId);
+ });
+ vertex.value(new ClusteringCoefficientValue());
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex, Iterator<IdList> messages) {
+ IdSet neighbors = ((ClusteringCoefficientValue) vertex.value()).idSet();
+ Integer count = super.triangleCount(context, vertex, messages, neighbors);
+ if (count != null) {
+ ((ClusteringCoefficientValue) vertex.value()).count(count);
+ vertex.inactivate();
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientOutput.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientOutput.java
new file mode 100644
index 00000000..a24dd408
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientOutput.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.cc;
+
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.output.hg.HugeGraphOutput;
+import org.apache.hugegraph.structure.constant.WriteType;
+
+/**
+ * Offer 2 ways to output: write-back + hdfs-file(TODO)
+ */
+public class ClusteringCoefficientOutput extends HugeGraphOutput<Float> {
+
+ @Override
+ public String name() {
+ return "clustering_coefficient";
+ }
+
+ @Override
+ public void prepareSchema() {
+ this.client().schema().propertyKey(this.name())
+ .asFloat()
+ .writeType(WriteType.OLAP_RANGE)
+ .ifNotExist()
+ .create();
+ }
+
+ @Override
+ protected org.apache.hugegraph.structure.graph.Vertex constructHugeVertex(Vertex vertex) {
+ org.apache.hugegraph.structure.graph.Vertex hugeVertex =
+ new org.apache.hugegraph.structure.graph.Vertex(null);
+ hugeVertex.id(vertex.id().asObject());
+ float triangle = ((ClusteringCoefficientValue) vertex.value()).count();
+ int degree = ((ClusteringCoefficientValue) vertex.value()).idSet().value().size();
+ hugeVertex.property(this.name(), 2 * triangle / degree / (degree - 1));
+ return hugeVertex;
+ }
+
+ /* TODO: enhance it
+ @Override
+ protected Float value(Vertex vertex) {
+ float triangle = ((ClusteringCoefficientValue) vertex.value()).count();
+ int degree = ((ClusteringCoefficientValue) vertex.value()).idList().size();
+ return 2 * triangle / degree / (degree - 1);
+ }*/
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientParams.java
new file mode 100644
index 00000000..3106672c
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientParams.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.cc;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.config.EdgeFrequency;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+
+public class ClusteringCoefficientParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ ClusteringCoefficient.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ IdList.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ ClusteringCoefficientValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ ClusteringCoefficientOutput.class.getName());
+ this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.name(),
+ EdgeFrequency.SINGLE.name());
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientValue.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientValue.java
new file mode 100644
index 00000000..50d6b9cb
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/cc/ClusteringCoefficientValue.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.cc;
+
+import java.io.IOException;
+
+import org.apache.hugegraph.computer.core.graph.value.IdSet;
+import org.apache.hugegraph.computer.core.graph.value.IntValue;
+import org.apache.hugegraph.computer.core.graph.value.Value;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+
+/**
+ * TODO: We could reuse triangle's result to simplify it (and avoid logical differences)
+ */
+public class ClusteringCoefficientValue implements Value.CustomizeValue<Integer> {
+
+ private IdSet idSet;
+ private IntValue count;
+ private final IntValue degree;
+
+ public ClusteringCoefficientValue() {
+ this.idSet = new IdSet();
+ this.count = new IntValue();
+ this.degree = new IntValue();
+ }
+
+ public IdSet idSet() {
+ return this.idSet;
+ }
+
+ public int count() {
+ return this.count.intValue();
+ }
+
+ public void count(Integer count) {
+ this.count.value(count);
+ }
+
+ public int degree() {
+ return this.degree.value();
+ }
+
+ public void degree(Integer degree) {
+ this.degree.value(degree);
+ }
+
+ @Override
+ public ClusteringCoefficientValue copy() {
+ ClusteringCoefficientValue ccValue = new ClusteringCoefficientValue();
+ ccValue.idSet = this.idSet.copy();
+ ccValue.count = this.count.copy();
+ return ccValue;
+ }
+
+ @Override
+ public Integer value() {
+ return this.count.value();
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.idSet.read(in);
+ this.count.read(in);
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.idSet.write(out);
+ this.count.write(out);
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(count);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/Kcore.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/Kcore.java
new file mode 100644
index 00000000..df590a18
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/Kcore.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.kcore;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.core.combiner.Combiner;
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+import com.google.common.collect.Iterators;
+
+public class Kcore implements Computation<Id> {
+
+ public static final String OPTION_K = "kcore.k";
+ public static final int K_DEFAULT_VALUE = 3;
+
+ private final KcoreValue initValue = new KcoreValue();
+
+ private int k = 0;
+
+ @Override
+ public String name() {
+ return "kcore";
+ }
+
+ @Override
+ public String category() {
+ return "community";
+ }
+
+ @Override
+ public void init(Config config) {
+ this.k = config.getInt(OPTION_K, K_DEFAULT_VALUE);
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ KcoreValue value = this.initValue;
+ value.core((Id) vertex.id().copy());
+ vertex.value(value);
+
+ if (vertex.numEdges() < this.k) {
+ value.degree(0);
+ /*
+ * TODO: send int type message at phase 1, it's different from id
+ * type of phase 2 (wcc message), need support switch message type.
+ */
+ context.sendMessageToAllEdges(vertex, vertex.id());
+ vertex.inactivate();
+ } else {
+ value.degree(vertex.numEdges());
+ assert vertex.active();
+ }
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<Id> messages) {
+ KcoreValue value = vertex.value();
+ if (!value.active()) {
+ // Ignore messages of deleted vertex
+ vertex.inactivate();
+ return;
+ }
+
+ int superstep = context.superstep();
+ if (superstep <= 2) {
+ int deleted = Iterators.size(messages);
+ assert value.active();
+ if (value.decreaseDegree(deleted) < this.k) {
+ // From active to inactive, delete self vertex
+ value.degree(0);
+ if (superstep == 1) {
+ context.sendMessageToAllEdges(vertex, vertex.id());
+ }
+ vertex.inactivate();
+ } else {
+ // From active to active, do wcc from superstep 2
+ if (superstep == 2) {
+ // Start wcc
+ context.sendMessageToAllEdgesIf(vertex, vertex.id(),
+ (source, target) -> {
+ return source.compareTo(target) < 0;
+ });
+ vertex.inactivate();
+ } else {
+ // Keep active at superstep 1 to continue superstep 2
+ assert superstep == 1;
+ assert vertex.active();
+ }
+ }
+ } else {
+ // Do wcc
+ assert superstep > 2;
+ Id message = Combiner.combineAll(context.combiner(), messages);
+ if (value.core().compareTo(message) > 0) {
+ value.core(message);
+ context.sendMessageToAllEdges(vertex, message);
+ }
+ vertex.inactivate();
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/KcoreParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/KcoreParams.java
new file mode 100644
index 00000000..0e7a3def
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/KcoreParams.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.kcore;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.combiner.ValueMinCombiner;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+
+public class KcoreParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ Kcore.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ KcoreValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ BYTESID_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
+ ValueMinCombiner.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_ID_OUTPUT_CLASS_NAME);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/KcoreValue.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/KcoreValue.java
new file mode 100644
index 00000000..17b6c79b
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/kcore/KcoreValue.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.kcore;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.id.IdFactory;
+import org.apache.hugegraph.computer.core.graph.value.Value.CustomizeValue;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+import org.apache.hugegraph.util.E;
+
+public class KcoreValue implements CustomizeValue<Object> {
+
+ private int degree;
+ private Id core;
+
+ public KcoreValue() {
+ this.degree = 0;
+ this.core = IdFactory.createId();
+ }
+
+ public void degree(int degree) {
+ assert degree >= 0;
+ this.degree = degree;
+ }
+
+ public int degree() {
+ return this.degree;
+ }
+
+ public int decreaseDegree(int decrease) {
+ assert decrease <= this.degree;
+ this.degree -= decrease;
+ return this.degree;
+ }
+
+ public boolean active() {
+ return this.degree > 0;
+ }
+
+ public void core(Id core) {
+ this.core = core;
+ }
+
+ public Id core() {
+ E.checkNotNull(this.core, "core");
+ return this.core;
+ }
+
+ @Override
+ public KcoreValue copy() {
+ KcoreValue kcoreValue = new KcoreValue();
+ kcoreValue.core = (Id) this.core.copy();
+ kcoreValue.degree = this.degree;
+ return kcoreValue;
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.core.read(in);
+ this.degree = in.readInt();
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.core.write(out);
+ out.writeInt(this.degree);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("core", this.core)
+ .append("degree", this.degree)
+ .toString();
+ }
+
+ @Override
+ public Object value() {
+ return this.core.value();
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/lpa/Lpa.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/lpa/Lpa.java
new file mode 100644
index 00000000..bdc5b954
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/lpa/Lpa.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.lpa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import org.apache.commons.lang3.mutable.MutableInt;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+public class Lpa implements Computation<Id> {
+
+ private final Random random = new Random();
+
+ @Override
+ public String name() {
+ return "lpa";
+ }
+
+ @Override
+ public String category() {
+ return "community";
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ Id value = vertex.id();
+ vertex.value(value);
+ vertex.inactivate();
+ context.sendMessageToAllEdges(vertex, value);
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<Id> messages) {
+ Id label = this.voteLabel(messages);
+ Id value = vertex.value();
+ if (!value.equals(label)) {
+ vertex.value(label);
+ context.sendMessageToAllEdges(vertex, label);
+ }
+ vertex.inactivate();
+ }
+
+ private Id voteLabel(Iterator<Id> messages) {
+ // Calculate label frequency
+ Map<Id, MutableInt> labels = new HashMap<>();
+ assert messages.hasNext();
+ while (messages.hasNext()) {
+ Id label = messages.next();
+ MutableInt labelCount = labels.get(label);
+ if (labelCount != null) {
+ labelCount.increment();
+ } else {
+ labels.put(label, new MutableInt(1));
+ }
+ }
+
+ // Calculate the labels with maximum frequency
+ List<Id> maxLabels = new ArrayList<>();
+ int maxFreq = 1;
+ for (Map.Entry<Id, MutableInt> e : labels.entrySet()) {
+ int value = e.getValue().intValue();
+ if (value > maxFreq) {
+ maxFreq = value;
+ maxLabels.clear();
+ }
+ if (value == maxFreq) {
+ maxLabels.add(e.getKey());
+ }
+ }
+
+ // Random choice
+ int selected = this.random.nextInt(maxLabels.size());
+ return maxLabels.get(selected);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/lpa/LpaParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/lpa/LpaParams.java
new file mode 100644
index 00000000..48004866
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/lpa/LpaParams.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.lpa;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+
+public class LpaParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ Lpa.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ BYTESID_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ BYTESID_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_ID_OUTPUT_CLASS_NAME);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCount.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCount.java
new file mode 100644
index 00000000..bda124aa
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCount.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.trianglecount;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.edge.Edges;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.IdSet;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+public class TriangleCount implements Computation<IdList> {
+
+ @Override
+ public String name() {
+ return "triangle_count";
+ }
+
+ @Override
+ public String category() {
+ return "community";
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ IdSet selfId = new IdSet();
+ selfId.add(vertex.id());
+
+ context.sendMessageToAllEdgesIf(vertex, selfId, (ids, targetId) -> {
+ return !vertex.id().equals(targetId);
+ });
+ vertex.value(new TriangleCountValue());
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<IdList> messages) {
+ IdSet neighbors = ((TriangleCountValue) vertex.value()).idSet();
+ Integer count = this.triangleCount(context, vertex, messages, neighbors);
+ if (count != null) {
+ ((TriangleCountValue) vertex.value()).count(count);
+ vertex.inactivate();
+ }
+ }
+
+ protected Integer triangleCount(ComputationContext context, Vertex vertex,
+ Iterator<IdList> messages, IdSet neighbors) {
+ if (context.superstep() == 1) {
+ // Collect outgoing neighbors
+ Set<Id> outNeighbors = getOutNeighbors(vertex);
+ neighbors.addAll(outNeighbors);
+
+ // Collect incoming neighbors
+ while (messages.hasNext()) {
+ IdList idList = messages.next();
+ assert idList.size() == 1;
+ Id inId = idList.get(0);
+ if (!outNeighbors.contains(inId)) {
+ neighbors.add(inId);
+ }
+ }
+
+ // Send all neighbors to neighbors
+ for (Id targetId : neighbors.value()) {
+ context.sendMessage(targetId, neighbors);
+ }
+ } else if (context.superstep() == 2) {
+ int count = 0;
+
+ while (messages.hasNext()) {
+ IdList twoDegreeNeighbors = messages.next();
+ for (Id twoDegreeNeighbor : twoDegreeNeighbors.values()) {
+ if (neighbors.contains(twoDegreeNeighbor)) {
+ count++;
+ }
+ }
+ }
+
+ return count >> 1;
+ }
+ return null;
+ }
+
+ private static Set<Id> getOutNeighbors(Vertex vertex) {
+ Set<Id> outNeighbors = new HashSet<>();
+ Edges edges = vertex.edges();
+ for (Edge edge : edges) {
+ Id targetId = edge.targetId();
+ if (!vertex.id().equals(targetId)) {
+ outNeighbors.add(targetId);
+ }
+ }
+ return outNeighbors;
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCountParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCountParams.java
new file mode 100644
index 00000000..b87c1f3e
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCountParams.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.trianglecount;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.config.EdgeFrequency;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+
+public class TriangleCountParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ TriangleCount.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ IdList.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ TriangleCountValue.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_INT_OUTPUT_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.name(),
+ EdgeFrequency.SINGLE.name());
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCountValue.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCountValue.java
new file mode 100644
index 00000000..ca6a0dc9
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/trianglecount/TriangleCountValue.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.trianglecount;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.hugegraph.computer.core.graph.value.IdSet;
+import org.apache.hugegraph.computer.core.graph.value.IntValue;
+import org.apache.hugegraph.computer.core.graph.value.Value.CustomizeValue;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+
+public class TriangleCountValue implements CustomizeValue<Integer> {
+
+ private IdSet idSet;
+ private IntValue count;
+
+ public TriangleCountValue() {
+ this.idSet = new IdSet();
+ this.count = new IntValue();
+ }
+
+ public IdSet idSet() {
+ return this.idSet;
+ }
+
+ public int count() {
+ return this.count.intValue();
+ }
+
+ public void count(int count) {
+ this.count.value(count);
+ }
+
+ @Override
+ public TriangleCountValue copy() {
+ TriangleCountValue triangleCountValue = new TriangleCountValue();
+ triangleCountValue.idSet = this.idSet.copy();
+ triangleCountValue.count = this.count.copy();
+ return triangleCountValue;
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.idSet.read(in);
+ this.count.read(in);
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.idSet.write(out);
+ this.count.write(out);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("idSet", this.idSet)
+ .append("count", this.count).toString();
+ }
+
+ @Override
+ public Integer value() {
+ return this.count.value();
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/wcc/Wcc.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/wcc/Wcc.java
new file mode 100644
index 00000000..778b4b7c
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/wcc/Wcc.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.wcc;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.core.combiner.Combiner;
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+/**
+ * Wcc stands for Weak Connected Component.
+ */
+public class Wcc implements Computation<Id> {
+
+ @Override
+ public String name() {
+ return "wcc";
+ }
+
+ @Override
+ public String category() {
+ return "community";
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ Id min = vertex.id();
+ for (Edge edge : vertex.edges()) {
+ if (edge.targetId().compareTo(min) < 0) {
+ min = edge.targetId();
+ }
+ }
+ Id value = min;
+ vertex.value(value);
+ vertex.inactivate();
+ context.sendMessageToAllEdgesIf(vertex, value, (result, target) -> {
+ return result.compareTo(target) < 0;
+ });
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<Id> messages) {
+ Id message = Combiner.combineAll(context.combiner(), messages);
+ Id value = vertex.value();
+ if (value.compareTo(message) > 0) {
+ vertex.value(message);
+ context.sendMessageToAllEdges(vertex, message);
+ }
+ vertex.inactivate();
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/wcc/WccParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/wcc/WccParams.java
new file mode 100644
index 00000000..0638cbab
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/community/wcc/WccParams.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.community.wcc;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.combiner.ValueMinCombiner;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+
+public class WccParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ Wcc.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ BYTESID_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ BYTESID_CLASS_NAME);
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS,
+ ValueMinCombiner.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ HUGEGRAPH_ID_OUTPUT_CLASS_NAME);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java
new file mode 100644
index 00000000..33bb755e
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetection.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.IdListList;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+public class RingsDetection implements Computation<IdList> {
+
+ @Override
+ public String name() {
+ return "rings";
+ }
+
+ @Override
+ public String category() {
+ return "path";
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ vertex.value(new IdListList());
+ if (vertex.edges().size() == 0) {
+ return;
+ }
+
+ // Init path
+ Id id = vertex.id();
+ IdList path = new IdList();
+ path.add(id);
+
+ for (Edge edge : vertex.edges()) {
+ /*
+ * Only send path to vertex whose id is larger than
+ * or equals current vertex id
+ */
+ if (id.compareTo(edge.targetId()) <= 0) {
+ context.sendMessage(edge.targetId(), path);
+ }
+ }
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<IdList> messages) {
+ Id id = vertex.id();
+ boolean halt = true;
+ while (messages.hasNext()) {
+ halt = false;
+ IdList sequence = messages.next();
+ if (id.equals(sequence.get(0))) {
+ // Use the smallest vertex record ring
+ boolean isMin = true;
+ for (int i = 1; i < sequence.size(); i++) {
+ Id pathVertexValue = sequence.get(i);
+ if (id.compareTo(pathVertexValue) > 0) {
+ isMin = false;
+ break;
+ }
+ }
+ if (isMin) {
+ sequence.add(id);
+ IdListList sequences = vertex.value();
+ sequences.add(sequence);
+ }
+ } else {
+ boolean contains = false;
+ // Drop sequence if path contains this vertex
+ for (int i = 0; i < sequence.size(); i++) {
+ Id pathVertexValue = sequence.get(i);
+ if (pathVertexValue.equals(vertex.id())) {
+ contains = true;
+ break;
+ }
+ }
+ // Field ringId is smallest vertex id in path
+ Id ringId = sequence.get(0);
+ if (!contains) {
+ sequence.add(vertex.id());
+ for (Edge edge : vertex.edges()) {
+ if (ringId.compareTo(edge.targetId()) <= 0) {
+ context.sendMessage(edge.targetId(), sequence);
+ }
+ }
+ }
+ }
+ }
+ if (halt) {
+ vertex.inactivate();
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java
new file mode 100644
index 00000000..a35f2f50
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hugegraph.computer.core.graph.value.IdListList;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.output.hg.HugeGraphOutput;
+
+public class RingsDetectionOutput extends HugeGraphOutput<List<String>> {
+
+ @Override
+ protected void prepareSchema() {
+ this.client().schema().propertyKey(this.name())
+ .asText()
+ .writeType(this.writeType())
+ .valueList()
+ .ifNotExist()
+ .create();
+ }
+
+ @Override
+ protected List<String> value(Vertex vertex) {
+ IdListList value = vertex.value();
+ List<String> propValues = new ArrayList<>();
+ for (int i = 0; i < value.size(); i++) {
+ propValues.add(value.get(i).toString());
+ }
+ return propValues;
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionParams.java
new file mode 100644
index 00000000..4a8928e3
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/RingsDetectionParams.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.IdListList;
+
+public class RingsDetectionParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ RingsDetection.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ IdList.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ IdListList.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ RingsDetectionOutput.class.getName());
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/FilterDescribe.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/FilterDescribe.java
new file mode 100644
index 00000000..c916e97e
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/FilterDescribe.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings.filter;
+
+import java.util.List;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.hugegraph.util.JsonUtil;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableList;
+
+public class FilterDescribe {
+
+ private final List<DescribeItem> vertexFilter;
+ private final List<DescribeItem> edgeFilter;
+
+ @JsonCreator
+ private FilterDescribe(@JsonProperty("vertex_filter")
+ List<DescribeItem> vertexFilter,
+ @JsonProperty("edge_filter")
+ List<DescribeItem> edgeFilter) {
+ this.vertexFilter = CollectionUtils.isEmpty(vertexFilter) ?
+ ImmutableList.of() :
+ ImmutableList.copyOf(vertexFilter);
+ this.edgeFilter = CollectionUtils.isEmpty(edgeFilter) ?
+ ImmutableList.of() :
+ ImmutableList.copyOf(edgeFilter);
+ }
+
+ public static FilterDescribe of(String describe) {
+ return JsonUtil.fromJson(describe, FilterDescribe.class);
+ }
+
+ public List<DescribeItem> vertexFilter() {
+ return this.vertexFilter;
+ }
+
+ public List<DescribeItem> edgeFilter() {
+ return this.edgeFilter;
+ }
+
+ public static class DescribeItem {
+
+ private final String label;
+ private final String propertyFilter;
+
+ @JsonCreator
+ private DescribeItem(@JsonProperty(value = "label",
+ required = true)
+ String label,
+ @JsonProperty(value = "property_filter",
+ required = true)
+ String propertyFilter) {
+ this.label = label;
+ this.propertyFilter = propertyFilter;
+ }
+
+ public String label() {
+ return this.label;
+ }
+
+ public String propertyFilter() {
+ return this.propertyFilter;
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionMessage.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionMessage.java
new file mode 100644
index 00000000..cd1c6165
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionMessage.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings.filter;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hugegraph.computer.core.common.ComputerContext;
+import org.apache.hugegraph.computer.core.graph.GraphFactory;
+import org.apache.hugegraph.computer.core.graph.properties.DefaultProperties;
+import org.apache.hugegraph.computer.core.graph.properties.Properties;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.Value.CustomizeValue;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.io.RandomAccessInput;
+import org.apache.hugegraph.computer.core.io.RandomAccessOutput;
+
+public class RingsDetectionMessage implements CustomizeValue<List<Object>> {
+
+ private final IdList path;
+ private Properties walkEdgeProps;
+
+ public RingsDetectionMessage() {
+ GraphFactory graphFactory = ComputerContext.instance().graphFactory();
+ this.path = new IdList();
+ this.walkEdgeProps = new DefaultProperties(graphFactory);
+ }
+
+ @Override
+ public void read(RandomAccessInput in) throws IOException {
+ this.path.read(in);
+ this.walkEdgeProps.read(in);
+ }
+
+ @Override
+ public void write(RandomAccessOutput out) throws IOException {
+ this.path.write(out);
+ this.walkEdgeProps.write(out);
+ }
+
+ public IdList path() {
+ return this.path;
+ }
+
+ public void addPath(Vertex vertex) {
+ this.path.add(vertex.id());
+ }
+
+ public Properties walkEdgeProp() {
+ return this.walkEdgeProps;
+ }
+
+ public void walkEdgeProp(Properties properties) {
+ this.walkEdgeProps = properties;
+ }
+
+ @Override
+ public List<Object> value() {
+ return this.path.value();
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilter.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilter.java
new file mode 100644
index 00000000..f9c6d6bc
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilter.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings.filter;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.computer.core.config.Config;
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.id.Id;
+import org.apache.hugegraph.computer.core.graph.value.IdList;
+import org.apache.hugegraph.computer.core.graph.value.IdListList;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.apache.hugegraph.computer.core.worker.Computation;
+import org.apache.hugegraph.computer.core.worker.ComputationContext;
+
+public class RingsDetectionWithFilter
+ implements Computation<RingsDetectionMessage> {
+
+ public static final String OPTION_FILTER = "rings.property_filter";
+
+ private SpreadFilter filter;
+
+ @Override
+ public String name() {
+ return "rings_with_filter";
+ }
+
+ @Override
+ public String category() {
+ return "path";
+ }
+
+ @Override
+ public void init(Config config) {
+ this.filter = new SpreadFilter(config.getString(OPTION_FILTER, "{}"));
+ }
+
+ @Override
+ public void compute0(ComputationContext context, Vertex vertex) {
+ vertex.value(new IdListList());
+ if (vertex.edges().size() == 0 || !this.filter.filter(vertex)) {
+ return;
+ }
+
+ RingsDetectionMessage message = new RingsDetectionMessage();
+ message.addPath(vertex);
+ for (Edge edge : vertex.edges()) {
+ if (this.filter.filter(edge)) {
+ message.walkEdgeProp(edge.properties());
+ context.sendMessage(edge.targetId(), message);
+ }
+ }
+ }
+
+ @Override
+ public void compute(ComputationContext context, Vertex vertex,
+ Iterator<RingsDetectionMessage> messages) {
+ boolean halt = true;
+ if (this.filter.filter(vertex)) {
+ Id vertexId = vertex.id();
+ while (messages.hasNext()) {
+ halt = false;
+ RingsDetectionMessage message = messages.next();
+ IdList path = message.path();
+ if (vertexId.equals(path.get(0))) {
+ // Use the smallest vertex record ring
+ boolean isMin = true;
+ for (int i = 0; i < path.size(); i++) {
+ Id pathVertexValue = path.get(i);
+ if (vertexId.compareTo(pathVertexValue) > 0) {
+ isMin = false;
+ break;
+ }
+ }
+ if (isMin) {
+ path.add(vertexId);
+ IdListList value = vertex.value();
+ value.add(path.copy());
+ }
+ } else {
+ boolean contains = false;
+ // Drop sequence if path contains this vertex
+ for (int i = 0; i < path.size(); i++) {
+ Id pathVertexValue = path.get(i);
+ if (pathVertexValue.equals(vertex.id())) {
+ contains = true;
+ break;
+ }
+ }
+ if (!contains) {
+ path.add(vertex.id());
+ for (Edge edge : vertex.edges()) {
+ if (this.filter.filter(edge, message)) {
+ message.walkEdgeProp(edge.properties());
+ context.sendMessage(edge.targetId(), message);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (halt) {
+ vertex.inactivate();
+ }
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilterParams.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilterParams.java
new file mode 100644
index 00000000..e41768ca
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/RingsDetectionWithFilterParams.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings.filter;
+
+import java.util.Map;
+
+import org.apache.hugegraph.computer.algorithm.AlgorithmParams;
+import org.apache.hugegraph.computer.algorithm.path.rings.RingsDetectionOutput;
+import org.apache.hugegraph.computer.core.config.ComputerOptions;
+import org.apache.hugegraph.computer.core.graph.value.IdListList;
+
+public class RingsDetectionWithFilterParams implements AlgorithmParams {
+
+ @Override
+ public void setAlgorithmParameters(Map<String, String> params) {
+ this.setIfAbsent(params, ComputerOptions.WORKER_COMPUTATION_CLASS,
+ RingsDetectionWithFilter.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS,
+ IdListList.class.getName());
+ this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS,
+ RingsDetectionMessage.class.getName());
+ this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS,
+ RingsDetectionOutput.class.getName());
+ this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS,
+ EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME);
+ }
+}
diff --git a/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java
new file mode 100644
index 00000000..32c111f2
--- /dev/null
+++ b/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm/path/rings/filter/SpreadFilter.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.computer.algorithm.path.rings.filter;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+
+import org.apache.hugegraph.computer.core.graph.edge.Edge;
+import org.apache.hugegraph.computer.core.graph.value.Value;
+import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
+import org.mvel2.MVEL;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+public class SpreadFilter {
+
+ private static final String ALL = "*";
+ private static final String MESSAGE = "$message";
+ private static final String ELEMENT = "$element";
+ private static final List<Serializable> PASS = ImmutableList.of();
+
+ private final Map<String, Serializable> vertexFilter;
+ private final Map<String, Serializable> edgeSpreadFilter;
+ private final Map<String, Serializable> edgeFilter;
+
+ public SpreadFilter(String describe) {
+ FilterDescribe des = FilterDescribe.of(describe);
+
+ this.vertexFilter = new HashMap<>();
+ this.edgeSpreadFilter = new HashMap<>();
+ this.edgeFilter = new HashMap<>();
+
+ this.init(this.vertexFilter, des.vertexFilter(), expression -> true);
+ this.init(this.edgeSpreadFilter, des.edgeFilter(), expression -> true);
+ // TODO: Use a better scheme to parse expressions with only $element
+ this.init(this.edgeFilter, des.edgeFilter(), expression -> {
+ return !expression.contains(MESSAGE);
+ });
+ }
+
+ private void init(Map<String, Serializable> filter,
+ List<FilterDescribe.DescribeItem> describes,
+ Predicate<? super String> predicate) {
+ for (FilterDescribe.DescribeItem describe : describes) {
+ String labelName = describe.label();
+ String propertyFilter = describe.propertyFilter();
+ if (predicate.test(propertyFilter) || ALL.equals(labelName)) {
+ Serializable expression = MVEL.compileExpression(
+ describe.propertyFilter());
+ filter.put(labelName, expression);
+ }
+ }
+ }
+
+ public boolean filter(Vertex vertex) {
+ String label = vertex.label();
+ List<Serializable> expressions = expressions(this.vertexFilter, label);
+
+ if (expressions == PASS) {
+ return true;
+ }
+
+ Map<String, Map<String, Value>> params =
+ ImmutableMap.of(ELEMENT, vertex.properties().get());
+ return filter(params, expressions);
+ }
+
+ public boolean filter(Edge edge) {
+ String label = edge.label();
+ List<Serializable> expressions = expressions(this.edgeFilter, label);
+
+ if (expressions == PASS) {
+ return true;
+ }
+
+ Map<String, Map<String, Value>> params =
+ ImmutableMap.of(ELEMENT, edge.properties().get());
+ return filter(params, expressions);
+ }
+
+ public boolean filter(Edge edge, RingsDetectionMessage message) {
+ String label = edge.label();
+ List<Serializable> expressions = expressions(this.edgeSpreadFilter,
+ label);
+
+ if (expressions == PASS) {
+ return true;
+ }
+
+ Map<String, Map<String, Value>> params =
+ ImmutableMap.of(ELEMENT, edge.properties().get(),
+ MESSAGE, message.walkEdgeProp().get());
+ return filter(params, expressions);
+ }
+
+ private static boolean filter(Map<String, Map<String, Value>> params,
+ List<Serializable> expressions) {
+ Map<String, Object> map = convertParamsValueToObject(params);
+ return expressions.stream()
+ .allMatch(expression -> {
+ return (Boolean) MVEL.executeExpression(
+ expression, map);
+ });
+ }
+
+ private static List<Serializable> expressions(
+ Map<String, Serializable> filter,
+ String label) {
+ if (filter.size() == 0) {
+ return PASS;
+ }
+ List<Serializable> expressions = new ArrayList<>();
+ if (filter.containsKey(ALL)) {
+ expressions.add(filter.get(ALL));
+ }
+ if (filter.containsKey(label)) {
+ expressions.add(filter.get(label));
+ }
+
+ return expressions;
+ }
+
+ private static Map<String, Object> convertParamsValueToObject(
+ Map<String, Map<String, Value>> params) {
+ Map<String, Object> result = new HashMap<>();
+ for (Map.Entry<String, Map<String, Value>> entry : params.entrySet()) {
+ Map<String, Object> subKv = new HashMap<>();
+ Map<String, Value> param = entry.getValue();
+ for (Map.Entry<String, Value> paramItem : param.entrySet()) {
+ subKv.put(paramItem.getKey(), paramItem.getValue().value());
+ }
+ result.put(entry.getKey(), subKv);
+ }
+ return result;
+ }
+}
diff --git a/computer-api/pom.xml b/computer-api/pom.xml
index 3b3e2e9d..d5267e04 100644
--- a/computer-api/pom.xml
+++ b/computer-api/pom.xml
@@ -20,7 +20,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hugegraph-computer</artifactId>
- <groupId>com.baidu.hugegraph</groupId>
+ <groupId>org.apache.hugegraph</groupId>
<version>0.1.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/algorithm/AlgorithmParams.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/algorithm/AlgorithmParams.java
deleted file mode 100644
index 6937593f..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/algorithm/AlgorithmParams.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.algorithm;
-
-import static com.baidu.hugegraph.computer.core.config.ComputerOptions.COMPUTER_PROHIBIT_USER_OPTIONS;
-
-import java.util.Map;
-
-import org.apache.hugegraph.config.ConfigOption;
-import org.apache.hugegraph.util.Log;
-import org.slf4j.Logger;
-
-public interface AlgorithmParams {
-
- Logger LOG = Log.logger(AlgorithmParams.class);
-
- String BYTESID_CLASS_NAME = "com.baidu.hugegraph.computer.core.graph.id.BytesId";
- String HUGEGRAPH_ID_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphIdOutput";
- String LOG_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core.output.LogOutput";
- String HUGEGRAPH_DOUBLE_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphDoubleOutput";
- String HUGEGRAPH_FLOAT_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphFloatOutput";
- String HUGEGRAPH_INT_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphIntOutput";
- String HUGEGRAPH_LONG_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphLongOutput";
- String HUGEGRAPH_STRING_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphStringOutput";
- String HUGEGRAPH_LIST_OUTPUT_CLASS_NAME = "com.baidu.hugegraph.computer.core" +
- ".output.hg.HugeGraphListOutput";
- String DEFAULTINPUTFILTER_CLASS_NAME = "com.baidu.hugegraph.computer" +
- ".core.input.filter" +
- ".DefaultInputFilter";
- String EXTRACTALLPROPERTYINPUTFILTER_CLASS_NAME = "com.baidu.hugegraph.computer" +
- ".core.input.filter" +
- ".ExtractAllPropertyInputFilter";
-
- /**
- * set algorithm's specific configuration
- * @param params
- */
- void setAlgorithmParameters(Map<String, String> params);
-
- default void setIfAbsent(Map<String, String> params, String key,
- String value) {
- if (!params.containsKey(key) && !COMPUTER_PROHIBIT_USER_OPTIONS.contains(key)) {
- LOG.debug("Put parameters key={}, value={}", key, value);
- params.put(key, value);
- }
- }
-
- default void setIfAbsent(Map<String, String> params,
- ConfigOption<?> keyOption,
- String value) {
- this.setIfAbsent(params, keyOption.name(), value);
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator.java
deleted file mode 100644
index ee19cb57..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.aggregator;
-
-import com.baidu.hugegraph.computer.core.common.ComputerContext;
-import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-
-public interface Aggregator<V extends Value> {
-
- /**
- * Used by worker to aggregate a new value when compute a vertex.
- * The combination method needs to be commutative and associative.
- * Can be called in worker computation compute() or afterSuperstep().
- * @param value The value to be aggregated
- */
- void aggregateValue(V value);
-
- /**
- * Used by worker to aggregate an int value. For performance reasons, it
- * can aggregate without create an IntValue object.
- */
- default void aggregateValue(int value) {
- throw new ComputerException("Not implemented: aggregateValue(int)");
- }
-
- /**
- * Used by worker to aggregate a long value. For performance reasons, it
- * can aggregate without create a LongValue object.
- */
- default void aggregateValue(long value) {
- throw new ComputerException("Not implemented: aggregateValue(long)");
- }
-
- /**
- * Used by worker to aggregate a float value. For performance reasons, it
- * can aggregate without create a FloatValue object.
- */
- default void aggregateValue(float value) {
- throw new ComputerException("Not implemented: aggregateValue(float)");
- }
-
- /**
- * Used by worker to aggregate a double value. For performance reasons,
- * it can aggregate without create a DoubleValue object.
- */
- default void aggregateValue(double value) {
- throw new ComputerException("Not implemented: aggregateValue(double)");
- }
-
- /**
- * Used by worker or master to get the aggregated value. The worker
- * get an aggregated value of previous superstep in current superstep.
- * The master can get an aggregated value of current superstep when
- * master-computation compute().
- */
- V aggregatedValue();
-
- /**
- * Used by worker or master to set current aggregated value directly. The
- * worker set aggregated value and then send to master for further
- * aggregation. The master set aggregated value and then used by workers in
- * the next superstep.
- */
- void aggregatedValue(V value);
-
- /**
- * Return cloned object of this instance.
- */
- Aggregator<V> copy();
-
- /**
- * Repair the object because some fields may not be deserialized.
- */
- void repair(ComputerContext context);
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Master.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Master.java
deleted file mode 100644
index 9a15cd1a..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Master.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.aggregator;
-
-import com.baidu.hugegraph.computer.core.combiner.Combiner;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import com.baidu.hugegraph.computer.core.graph.value.ValueType;
-
-/**
- * Aggregator4Master used by algorithm's master-computation. The master must
- * register all aggregators before all supersteps start. Then the workers can
- * aggregate aggregators in superstep, send the aggregators to master when
- * superstep finish. The master aggregates the aggregators sent by workers.
- * The workers can get the aggregated values master aggregated at next
- * superstep. These values are identical among all workers.
- */
-public interface Aggregator4Master {
-
- /**
- * Register the aggregator with specified name. The name must be unique.
- * Used by algorithm's master-computation init() to register aggregators.
- */
- <V extends Value, C extends Aggregator<V>>
- void registerAggregator(String name, Class<C> aggregator);
-
- /**
- * Register aggregator with specified value type and a combiner which can
- * combine values with specified value type. The name must be unique.
- * Used by algorithm's master-computation init() to register aggregators.
- */
- <V extends Value, C extends Combiner<V>>
- void registerAggregator(String name, ValueType type, Class<C> combiner);
-
- /**
- * Register aggregator with specified default value(include type) and
- * a combiner which can combine values with specified value type.
- * The name must be unique.
- * Used by algorithm's master-computation init() to register aggregators.
- */
- <V extends Value, C extends Combiner<V>>
- void registerAggregator(String name, V defaultValue, Class<C> combiner);
-
- /**
- * Set the aggregated value by master-computation, generally users may not
- * need to explicitly set a aggregated value.
- * If the value is set, it will be received by workers at next superstep.
- * Throws ComputerException if master-computation does not register
- * aggregator with specified name.
- */
- <V extends Value> void aggregatedValue(String name, V value);
-
- /**
- * Get the aggregated value. Each worker aggregate the aggregator value
- * locally, then submit to master, then master aggregate the aggregators
- * value from all workers. master-computation can get the aggregated value
- * in master compute(), and worker-computation can get the aggregated value
- * in the next superstep.
- * Used by algorithm's master-computation compute()
- * Throws ComputerException if master-computation does not register
- * aggregator with the specified name.
- */
- <V extends Value> V aggregatedValue(String name);
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Worker.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Worker.java
deleted file mode 100644
index d1053312..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/aggregator/Aggregator4Worker.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.aggregator;
-
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-
-/**
- * Aggregator4Worker used by algorithm's computation. The computation can
- * only use the aggregator with specified name the master registered.
- * See {@link Aggregator4Master} for detailed information about aggregation
- * process.
- */
-public interface Aggregator4Worker {
-
- /**
- * Create aggregator by name in worker-computation, the aggregator is
- * registered by master-computation.
- * Used by algorithm's worker-computation beforeSuperstep(), can be called
- * in each superstep.
- * Throws ComputerException if master-computation does not register
- * aggregator with the specified name.
- */
- <V extends Value> Aggregator<V> createAggregator(String name);
-
- /**
- * Set aggregate value in worker. The value of aggregator will be
- * aggregated locally in worker first, and it would be sent to master when
- * the current superstep finish.
- * Used by algorithm's worker-computation afterSuperstep(), can be called
- * in each superstep.
- * Throws ComputerException if master-computation does not register
- * aggregator with the specified name.
- * @param value The value to be aggregated
- */
- <V extends Value> void aggregateValue(String name, V value);
-
- /**
- * Get the aggregated value in worker-computation, the value is aggregated
- * by master at previous superstep, it won't be changed in a superstep.
- * Each worker aggregate an aggregator value locally, then submit to master,
- * then master aggregate the aggregator values from all workers.
- * master-computation can get the aggregated value in master compute(), and
- * worker-computation can get the aggregated value in the next superstep.
- * Used by algorithm's worker-computation compute(), can be called in
- * each superstep.
- * Throws ComputerException if master-computation does not register
- * aggregator with the specified name.
- */
- <V extends Value> V aggregatedValue(String name);
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/Allocator.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/Allocator.java
deleted file mode 100644
index 3bd94453..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/Allocator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.allocator;
-
-import com.baidu.hugegraph.computer.core.graph.edge.Edge;
-import com.baidu.hugegraph.computer.core.graph.vertex.Vertex;
-
-public interface Allocator {
-
- RecyclerReference<Vertex> newVertex();
-
- void freeVertex(RecyclerReference<Vertex> reference);
-
- RecyclerReference<Edge> newEdge();
-
- void freeEdge(RecyclerReference<Edge> reference);
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/Recyclable.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/Recyclable.java
deleted file mode 100644
index ddae4232..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/Recyclable.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.allocator;
-
-public interface Recyclable {
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/RecyclerReference.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/RecyclerReference.java
deleted file mode 100644
index 30b89126..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/allocator/RecyclerReference.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.allocator;
-
-import java.lang.ref.SoftReference;
-
-public class RecyclerReference<T extends Recyclable> extends SoftReference<T>
- implements AutoCloseable {
-
- private final Handle<RecyclerReference<T>> handle;
-
- // TODO: create interface here and make parameter a interface.
- public RecyclerReference(T referent,
- Handle<RecyclerReference<T>> handle) {
- super(referent);
- this.handle = handle;
- }
-
- @Override
- public void close() {
- this.handle.recycle(this);
- }
-
- // Copy from io.netty.util.Recycler.Handle
- public interface Handle<O> {
- void recycle(O object);
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/Combiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/Combiner.java
deleted file mode 100644
index 0cd27151..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/Combiner.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import java.util.Iterator;
-
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-
-public interface Combiner<T> {
-
- /**
- * @return The name of the combiner.
- * @return class name by default.
- */
- default String name() {
- return this.getClass().getName();
- }
-
- /**
- * Combine v1 and v2 to result. The combined value may
- * take use v1 or v2. The value of v1 and v2 may be updated. Should not
- * use v1 and v2 after combine them.
- */
- void combine(T v1, T v2, T result);
-
- @SuppressWarnings("unchecked")
- static <T extends Value> T combineAll(Combiner<T> combiner,
- Iterator<T> values) {
- if (!values.hasNext()) {
- return null;
- }
- T result = (T) values.next().copy();
- while (values.hasNext()) {
- combiner.combine(result, values.next(), result);
- }
- return result;
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/DoubleValueSumCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/DoubleValueSumCombiner.java
deleted file mode 100644
index bbc6bc6d..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/DoubleValueSumCombiner.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.DoubleValue;
-import org.apache.hugegraph.util.E;
-
-public class DoubleValueSumCombiner implements Combiner<DoubleValue> {
-
- @Override
- public void combine(DoubleValue v1, DoubleValue v2, DoubleValue result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- result.value(v1.doubleValue() + v2.doubleValue());
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/FloatValueSumCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/FloatValueSumCombiner.java
deleted file mode 100644
index d6238866..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/FloatValueSumCombiner.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.FloatValue;
-import org.apache.hugegraph.util.E;
-
-public class FloatValueSumCombiner implements Combiner<FloatValue> {
-
- @Override
- public void combine(FloatValue v1, FloatValue v2, FloatValue result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- result.value(v1.floatValue() + v2.floatValue());
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/IntValueSumCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/IntValueSumCombiner.java
deleted file mode 100644
index 0395b6f6..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/IntValueSumCombiner.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.IntValue;
-import org.apache.hugegraph.util.E;
-
-public class IntValueSumCombiner implements Combiner<IntValue> {
-
- @Override
- public void combine(IntValue v1, IntValue v2, IntValue result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- result.value(v1.intValue() + v2.intValue());
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/LongValueSumCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/LongValueSumCombiner.java
deleted file mode 100644
index 4fa72f4e..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/LongValueSumCombiner.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.LongValue;
-import org.apache.hugegraph.util.E;
-
-public class LongValueSumCombiner implements Combiner<LongValue> {
-
- @Override
- public void combine(LongValue v1, LongValue v2, LongValue result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- result.value(v1.longValue() + v2.longValue());
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeNewPropertiesCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeNewPropertiesCombiner.java
deleted file mode 100644
index e9eb8a76..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeNewPropertiesCombiner.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.core.graph.properties.Properties;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import org.apache.hugegraph.util.E;
-
-public class MergeNewPropertiesCombiner implements PropertiesCombiner {
-
- /**
- * Merge properties v2 and v1 into result. If a property exists in both v1
- * and v2, remain the value in v1.
- */
- @Override
- public void combine(Properties v1, Properties v2, Properties result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- E.checkArgument(v1 != result && v2 != result,
- "The combine parameter result " +
- "can't same with v1 or v2");
-
- result.clear();
-
- Map<String, Value> v1Map = v1.get();
- for (Map.Entry<String, Value> entry : v1Map.entrySet()) {
- result.put(entry.getKey(), entry.getValue());
- }
- Map<String, Value> v2Map = v2.get();
- for (Map.Entry<String, Value> entry : v2Map.entrySet()) {
- result.putIfAbsent(entry.getKey(), entry.getValue());
- }
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeOldPropertiesCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeOldPropertiesCombiner.java
deleted file mode 100644
index 6ea81a23..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/MergeOldPropertiesCombiner.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import java.util.Map;
-
-import com.baidu.hugegraph.computer.core.graph.properties.Properties;
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import org.apache.hugegraph.util.E;
-
-public class MergeOldPropertiesCombiner implements PropertiesCombiner {
-
- /**
- * Merge properties v1 and v2 into result. If a property exists in both v1
- * and v2, remain the value in v2.
- */
- @Override
- public void combine(Properties v1, Properties v2, Properties result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- E.checkArgument(v1 != result && v2 != result,
- "The combine parameter result " +
- "can't same with v1 or v2");
-
- result.clear();
-
- Map<String, Value> v2Map = v2.get();
- for (Map.Entry<String, Value> entry : v2Map.entrySet()) {
- result.put(entry.getKey(), entry.getValue());
- }
- Map<String, Value> v1Map = v1.get();
- for (Map.Entry<String, Value> entry : v1Map.entrySet()) {
- result.putIfAbsent(entry.getKey(), entry.getValue());
- }
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/OverwriteCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/OverwriteCombiner.java
deleted file mode 100644
index 0b0f1c28..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/OverwriteCombiner.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import org.apache.hugegraph.util.E;
-
-public class OverwriteCombiner<T extends Value> implements Combiner<T> {
-
- @Override
- public void combine(T v1, T v2, T result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- result.assign(v2);
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/OverwritePropertiesCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/OverwritePropertiesCombiner.java
deleted file mode 100644
index c9baac7d..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/OverwritePropertiesCombiner.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.properties.Properties;
-import org.apache.hugegraph.util.E;
-
-public class OverwritePropertiesCombiner implements PropertiesCombiner {
-
- @Override
- public void combine(Properties v1, Properties v2, Properties result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
-
- E.checkArgument(v1 != result && v2 != result,
- "The combine parameter result " +
- "can't same with v1 or v2");
-
- result.clear();
- result.putAll(v2.get());
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/PropertiesCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/PropertiesCombiner.java
deleted file mode 100644
index fee77167..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/PropertiesCombiner.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.properties.Properties;
-
-/**
- * When vertex properties with the same vertex id are loaded, this class
- * specifies how to combine their properties.
- */
-public interface PropertiesCombiner extends Combiner<Properties> {
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMaxCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMaxCombiner.java
deleted file mode 100644
index 41c36e74..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMaxCombiner.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import org.apache.hugegraph.util.E;
-
-public class ValueMaxCombiner<T extends Value> implements Combiner<T> {
-
- @Override
- public void combine(T v1, T v2, T result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- if (v1.compareTo(v2) >= 0) {
- result.assign(v1);
- } else {
- result.assign(v2);
- }
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMinCombiner.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMinCombiner.java
deleted file mode 100644
index c21c68fa..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/combiner/ValueMinCombiner.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.combiner;
-
-import com.baidu.hugegraph.computer.core.graph.value.Value;
-import org.apache.hugegraph.util.E;
-
-public class ValueMinCombiner<T extends Value> implements Combiner<T> {
-
- @Override
- public void combine(T v1, T v2, T result) {
- E.checkArgumentNotNull(v1, "The combine parameter v1 can't be null");
- E.checkArgumentNotNull(v2, "The combine parameter v2 can't be null");
- E.checkArgumentNotNull(result,
- "The combine parameter result can't be null");
- if (v1.compareTo(v2) <= 0) {
- result.assign(v1);
- } else {
- result.assign(v2);
- }
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/ComputerContext.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/ComputerContext.java
deleted file mode 100644
index f7530045..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/ComputerContext.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.common;
-
-import com.baidu.hugegraph.computer.core.allocator.Allocator;
-import com.baidu.hugegraph.computer.core.config.Config;
-import com.baidu.hugegraph.computer.core.graph.GraphFactory;
-import org.apache.hugegraph.util.E;
-
-public final class ComputerContext {
-
- private static volatile ComputerContext INSTANCE;
-
- private final Config config;
- private final GraphFactory graphFactory;
- private final Allocator allocator;
-
- private ComputerContext(Config config,
- GraphFactory graphFactory,
- Allocator allocator) {
- this.config = config;
- this.graphFactory = graphFactory;
- this.allocator = allocator;
- }
-
- public static synchronized void initContext(Config config,
- GraphFactory graphFactory,
- Allocator allocator) {
- INSTANCE = new ComputerContext(config, graphFactory, allocator);
- }
-
- public static ComputerContext instance() {
- E.checkNotNull(INSTANCE, "ComputerContext INSTANCE");
- return INSTANCE;
- }
-
- public Config config() {
- return this.config;
- }
-
- public GraphFactory graphFactory() {
- return this.graphFactory;
- }
-
- public Allocator allocator() {
- return this.allocator;
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/Constants.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/Constants.java
deleted file mode 100644
index 62534a6b..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/Constants.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.common;
-
-import org.apache.hugegraph.util.Bytes;
-
-public final class Constants {
-
- public static final byte[] EMPTY_BYTES = new byte[0];
-
- public static final int BOOLEAN_LEN = 1;
- public static final int BYTE_LEN = Byte.BYTES;
- public static final int SHORT_LEN = Short.BYTES;
- public static final int INT_LEN = Integer.BYTES;
- public static final int LONG_LEN = Long.BYTES;
- public static final int CHAR_LEN = Character.BYTES;
- public static final int FLOAT_LEN = Float.BYTES;
- public static final int DOUBLE_LEN = Double.BYTES;
-
- public static final int UINT8_MAX = 0xff;
- public static final int UINT16_MAX = 0xffff;
- public static final long UINT32_MAX = 0xffffffffL;
-
- /*
- * The small buffer size for buffered input & output,
- * mainly used in input & output of memory
- */
- public static final int SMALL_BUF_SIZE = 32;
-
- /*
- * The big buffer size for buffered input & output,
- * mainly used in input & output of file and stream
- */
- public static final int BIG_BUF_SIZE = (int) Bytes.KB * 8;
-
- /*
- * The capacity of message queue
- */
- public static final int QUEUE_CAPACITY = 128;
-
- /*
- * The timeout in second for asynchronous tasks
- */
- public static final int FUTURE_TIMEOUT = 300;
-
- /*
- * The timeout in millisecond for threadpool shutdown
- */
- public static final long SHUTDOWN_TIMEOUT = 5000L;
-
- // The mode to read a file
- public static final String FILE_MODE_READ = "r";
-
- // The mode to write a file
- public static final String FILE_MODE_WRITE = "rw";
-
- public static final String EMPTY_STR = "";
-
- public static final int INPUT_SUPERSTEP = -1;
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/SerialEnum.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/SerialEnum.java
deleted file mode 100644
index 8d073c0d..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/SerialEnum.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.common;
-
-import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
-import org.apache.hugegraph.util.CollectionUtil;
-import com.google.common.collect.HashBasedTable;
-import com.google.common.collect.Table;
-
-public interface SerialEnum {
-
- byte code();
-
- Table<Class<?>, Byte, SerialEnum> TABLE = HashBasedTable.create();
-
- static void register(Class<? extends SerialEnum> clazz) {
- Object enums;
- try {
- enums = clazz.getMethod("values").invoke(null);
- } catch (Exception e) {
- throw new ComputerException("Call method values() error", e);
- }
- for (SerialEnum e : CollectionUtil.<SerialEnum>toList(enums)) {
- TABLE.put(clazz, e.code(), e);
- }
- }
-
- static <T extends SerialEnum> T fromCode(Class<T> clazz, byte code) {
- @SuppressWarnings("unchecked")
- T value = (T) TABLE.get(clazz, code);
- if (value == null) {
- throw new ComputerException("Can't construct %s from code %s",
- clazz.getSimpleName(), code);
- }
- return value;
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/exception/ComputerException.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/exception/ComputerException.java
deleted file mode 100644
index 2f001018..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/common/exception/ComputerException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.common.exception;
-
-/**
- * The base class for all exception types
- */
-public class ComputerException extends RuntimeException {
-
- private static final long serialVersionUID = 3621207523020113277L;
-
- public ComputerException(String message) {
- super(message);
- }
-
- public ComputerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ComputerException(String message, Object... args) {
- super(String.format(message, args));
- }
-
- public ComputerException(String message, Throwable cause, Object... args) {
- super(String.format(message, args), cause);
- }
-
- public Throwable rootCause() {
- return rootCause(this);
- }
-
- public static Throwable rootCause(Throwable e) {
- Throwable cause = e;
- while (cause.getCause() != null) {
- cause = cause.getCause();
- }
- return cause;
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java
deleted file mode 100644
index 85f699ca..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java
+++ /dev/null
@@ -1,937 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.config;
-
-import static com.baidu.hugegraph.computer.algorithm.AlgorithmParams.DEFAULTINPUTFILTER_CLASS_NAME;
-import static com.baidu.hugegraph.computer.algorithm.AlgorithmParams.LOG_OUTPUT_CLASS_NAME;
-import static org.apache.hugegraph.config.OptionChecker.allowValues;
-import static org.apache.hugegraph.config.OptionChecker.disallowEmpty;
-import static org.apache.hugegraph.config.OptionChecker.nonNegativeInt;
-import static org.apache.hugegraph.config.OptionChecker.positiveInt;
-
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hugegraph.config.ConfigConvOption;
-import org.apache.hugegraph.config.ConfigListOption;
-import org.apache.hugegraph.config.ConfigOption;
-import org.apache.hugegraph.config.OptionHolder;
-import org.apache.hugegraph.structure.constant.Direction;
-import org.apache.hugegraph.util.Bytes;
-import org.apache.hugegraph.util.Log;
-import org.slf4j.Logger;
-
-import com.baidu.hugegraph.computer.core.combiner.OverwritePropertiesCombiner;
-import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-public class ComputerOptions extends OptionHolder {
-
- private static final Logger LOG = Log.logger(ComputerOptions.class);
-
- public static final int TRANSPORT_DEFAULT_THREADS = 4;
- public static final String RPC_SERVER_HOST_NAME = "rpc.server_host";
- public static final String RPC_SERVER_PORT_NAME = "rpc.server_port";
- public static final String RPC_REMOTE_URL_NAME = "rpc.remote_url";
-
- private ComputerOptions() {
- super();
- }
-
- private static volatile ComputerOptions INSTANCE;
-
- public static synchronized ComputerOptions instance() {
- if (INSTANCE == null) {
- INSTANCE = new ComputerOptions();
- // Should initialize all static members first, then register.
- INSTANCE.registerOptions();
- }
- return INSTANCE;
- }
-
- public static final ConfigOption<Class<?>> ALGORITHM_PARAMS_CLASS =
- new ConfigOption<>(
- "algorithm.params_class",
- "The class used to transfer algorithms' parameters " +
- "before algorithm been run.",
- disallowEmpty(),
- Null.class
- );
-
- public static final ConfigOption<Class<?>> ALGORITHM_RESULT_CLASS =
- new ConfigOption<>(
- "algorithm.result_class",
- "The class of vertex's value, the instance is used to " +
- "store computation result for the vertex.",
- disallowEmpty(),
- Null.class
- );
-
- public static final ConfigOption<Class<?>> ALGORITHM_MESSAGE_CLASS =
- new ConfigOption<>(
- "algorithm.message_class",
- "The class of message passed when compute vertex.",
- disallowEmpty(),
- Null.class
- );
-
- public static final ConfigOption<String> INPUT_SOURCE_TYPE =
- new ConfigOption<>(
- "input.source_type",
- "The source type to load input data",
- allowValues("hugegraph-server", "hugegraph-loader"),
- "hugegraph-server"
- );
-
- public static final ConfigOption<Integer> INPUT_SPLIT_FETCH_TIMEOUT =
- new ConfigOption<>(
- "input.split_fetch_timeout",
- "The timeout in seconds to fetch input splits",
- positiveInt(),
- 300
- );
-
- public static final ConfigOption<Long> INPUT_SPLITS_SIZE =
- new ConfigOption<>(
- "input.split_size",
- "The input split size in bytes",
- positiveInt(),
- 1024 * 1024L
- );
-
- public static final ConfigOption<Integer> INPUT_MAX_SPLITS =
- new ConfigOption<>(
- "input.split_max_splits",
- "The maximum number of input splits",
- positiveInt(),
- 10_000_000
- );
-
- public static final ConfigOption<Integer> INPUT_SPLIT_PAGE_SIZE =
- new ConfigOption<>(
- "input.split_page_size",
- "The page size for streamed load input split data",
- positiveInt(),
- 500
- );
-
- public static final ConfigOption<Class<?>> INPUT_FILTER_CLASS =
- new ConfigOption<>(
- "input.filter_class",
- "The class to create input-filter object, " +
- "input-filter is used to Filter vertex edges " +
- "according to user needs.",
- disallowEmpty(),
- loadClass(DEFAULTINPUTFILTER_CLASS_NAME)
- );
-
- public static final ConfigConvOption<String, Direction>
- INPUT_EDGE_DIRECTION = new ConfigConvOption<>(
- "input.edge_direction",
- "The data of the edge in which direction is loaded, " +
- "when the value is BOTH, the edges in both OUT and IN " +
- "direction will be loaded.",
- allowValues("OUT", "IN", "BOTH"),
- Direction::valueOf,
- "OUT"
- );
-
- public static final ConfigConvOption<String, EdgeFrequency>
- INPUT_EDGE_FREQ = new ConfigConvOption<>(
- "input.edge_freq",
- "The frequency of edges can exist between a pair of " +
- "vertices, allowed values: [SINGLE, SINGLE_PER_LABEL, " +
- "MULTIPLE]. SINGLE means that only one edge can exist " +
- "between a pair of vertices, use sourceId + targetId to " +
- "identify it; SINGLE_PER_LABEL means that each edge " +
- "label can exist one edge between a pair of vertices, " +
- "use sourceId + edgelabel + targetId to identify it; " +
- "MULTIPLE means that many edge can exist between a pair " +
- "of vertices, use sourceId + edgelabel + sortValues + " +
- "targetId to identify it.",
- allowValues("SINGLE", "SINGLE_PER_LABEL", "MULTIPLE"),
- EdgeFrequency::valueOf,
- "MULTIPLE"
- );
-
- public static final ConfigOption<Integer> INPUT_MAX_EDGES_IN_ONE_VERTEX =
- new ConfigOption<>(
- "input.max_edges_in_one_vertex",
- "The maximum number of adjacent edges allowed to be " +
- "attached to a vertex, the adjacent edges will be " +
- "stored and transferred together as a batch unit.",
- positiveInt(),
- 200
- );
-
- public static final ConfigOption<String> INPUT_LOADER_STRUCT_PATH =
- new ConfigOption<>(
- "input.loader_struct_path",
- "The struct path of loader input, only takes effect when " +
- "the input.source_type=loader is enabled",
- null,
- ""
- );
-
- public static final ConfigOption<String> INPUT_LOADER_SCHEMA_PATH =
- new ConfigOption<>(
- "input.loader_schema_path",
- "The schema path of loader input, only takes effect when " +
- "the input.source_type=loader is enabled",
- null,
- ""
- );
-
- public static final ConfigOption<Integer> SORT_THREAD_NUMS =
- new ConfigOption<>(
- "sort.thread_nums",
- "The number of threads performing internal sorting.",
- positiveInt(),
- 4
- );
-
- public static final ConfigOption<Class<?>> OUTPUT_CLASS =
- new ConfigOption<>(
- "output.output_class",
- "The class to output the computation result of each " +
- "vertex. Be called after iteration computation.",
- disallowEmpty(),
- loadClass(LOG_OUTPUT_CLASS_NAME)
- );
-
- public static final ConfigOption<String> OUTPUT_RESULT_NAME =
- new ConfigOption<>(
- "output.result_name",
- "The value is assigned dynamically by #name() of " +
- "instance created by WORKER_COMPUTATION_CLASS.",
- disallowEmpty(),
- "value"
- );
-
- public static final ConfigOption<Boolean> OUTPUT_WITH_ADJACENT_EDGES =
- new ConfigOption<>(
- "output.with_adjacent_edges",
- "Output the adjacent edges of the vertex or not",
- allowValues(true, false),
- false
- );
-
- public static final ConfigOption<Boolean> OUTPUT_WITH_VERTEX_PROPERTIES =
- new ConfigOption<>(
- "output.with_vertex_properties",
- "Output the properties of the vertex or not",
- allowValues(true, false),
- false
- );
-
- public static final ConfigOption<Boolean> OUTPUT_WITH_EDGE_PROPERTIES =
- new ConfigOption<>(
- "output.with_edge_properties",
- "Output the properties of the edge or not",
- allowValues(true, false),
- false
- );
-
- public static final ConfigOption<String> OUTPUT_RESULT_WRITE_TYPE =
- new ConfigOption<>(
- "output.result_write_type",
- "The result write-type to output to hugegraph, " +
- "allowed values are: " +
- "[OLAP_COMMON, OLAP_SECONDARY, OLAP_RANGE].",
- allowValues("OLAP_COMMON", "OLAP_SECONDARY", "OLAP_RANGE"),
- "OLAP_COMMON"
- );
-
- public static final ConfigOption<Integer> OUTPUT_BATCH_SIZE =
- new ConfigOption<>(
- "output.batch_size",
- "The batch size of output",
- positiveInt(),
- 500
- );
-
- public static final ConfigOption<Integer> OUTPUT_BATCH_THREADS =
- new ConfigOption<>(
- "output.batch_threads",
- "The threads number used to batch output",
- positiveInt(),
- 1
- );
-
- public static final ConfigOption<Integer> OUTPUT_SINGLE_THREADS =
- new ConfigOption<>(
- "output.single_threads",
- "The threads number used to single output",
- positiveInt(),
- 1
- );
-
- public static final ConfigOption<Integer>
- OUTPUT_THREAD_POOL_SHUTDOWN_TIMEOUT =
- new ConfigOption<>(
- "output.thread_pool_shutdown_timeout",
- "The timeout seconds of output threads pool shutdown",
- positiveInt(),
- 60
- );
-
- public static final ConfigOption<Integer> OUTPUT_RETRY_TIMES =
- new ConfigOption<>(
- "output.retry_times",
- "The retry times when output failed",
- positiveInt(),
- 3
- );
-
- public static final ConfigOption<Integer> OUTPUT_RETRY_INTERVAL =
- new ConfigOption<>(
- "output.retry_interval",
- "The retry interval when output failed",
- positiveInt(),
- 10
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_URL =
- new ConfigOption<>(
- "output.hdfs_url",
- "The hdfs url of output.",
- disallowEmpty(),
- "hdfs://127.0.0.1:9000"
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_USER =
- new ConfigOption<>(
- "output.hdfs_user",
- "The hdfs user of output.",
- disallowEmpty(),
- "hadoop"
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_CORE_SITE_PATH =
- new ConfigOption<>(
- "output.hdfs_core_site_path",
- "The hdfs core site path.",
- null,
- ""
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_SITE_PATH =
- new ConfigOption<>(
- "output.hdfs_site_path",
- "The hdfs site path.",
- null,
- ""
- );
-
- public static final ConfigOption<Short> OUTPUT_HDFS_REPLICATION =
- new ConfigOption<>(
- "output.hdfs_replication",
- "The replication number of hdfs.",
- positiveInt(),
- (short) 3
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_DIR =
- new ConfigOption<>(
- "output.hdfs_path_prefix",
- "The directory of hdfs output result.",
- disallowEmpty(),
- "/hugegraph-computer/results"
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_DELIMITER =
- new ConfigOption<>(
- "output.hdfs_delimiter",
- "The delimiter of hdfs output.",
- disallowEmpty(),
- ","
- );
-
- public static final ConfigOption<Boolean> OUTPUT_HDFS_MERGE =
- new ConfigOption<>(
- "output.hdfs_merge_partitions",
- "Whether merge output files of multiple partitions.",
- allowValues(true, false),
- true
- );
-
- public static final ConfigOption<Boolean> OUTPUT_HDFS_KERBEROS_ENABLE =
- new ConfigOption<>(
- "output.hdfs_kerberos_enable",
- "Is Kerberos authentication enabled for Hdfs.",
- allowValues(true, false),
- false
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_KRB5_CONF =
- new ConfigOption<>(
- "output.hdfs_krb5_conf",
- "Kerberos configuration file.",
- disallowEmpty(),
- "/etc/krb5.conf"
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_KERBEROS_PRINCIPAL =
- new ConfigOption<>(
- "output.hdfs_kerberos_principal",
- "The Hdfs's principal for kerberos authentication.",
- null,
- ""
- );
-
- public static final ConfigOption<String> OUTPUT_HDFS_KERBEROS_KEYTAB =
- new ConfigOption<>(
- "output.hdfs_kerberos_keytab",
- "The Hdfs's key tab file for kerberos authentication.",
- null,
- ""
- );
-
- public static final ConfigOption<Integer>
- ALLOCATOR_MAX_VERTICES_PER_THREAD = new ConfigOption<>(
- "allocator.max_vertices_per_thread",
- "Maximum number of vertices per thread processed " +
- "in each memory allocator",
- positiveInt(),
- 10000
- );
-
- public static final ConfigOption<String> JOB_ID =
- new ConfigOption<>(
- "job.id",
- "The job id on Yarn cluster or K8s cluster.",
- disallowEmpty(),
- "local_0001"
- );
-
- public static final ConfigOption<Integer> JOB_WORKERS_COUNT =
- new ConfigOption<>(
- "job.workers_count",
- "The workers count for computing one graph " +
- "algorithm job.",
- positiveInt(),
- 1
- );
-
- public static final ConfigOption<Integer> JOB_PARTITIONS_COUNT =
- new ConfigOption<>(
- "job.partitions_count",
- "The partitions count for computing one graph " +
- "algorithm job.",
- positiveInt(),
- 1
- );
-
- public static final ConfigOption<Integer> PARTITIONS_COMPUTE_THREAD_NUMS =
- new ConfigOption<>(
- "job.partitions_thread_nums",
- "The number of threads for partition parallel compute.",
- positiveInt(),
- 4
- );
-
- public static final ConfigOption<Integer> BSP_MAX_SUPER_STEP =
- new ConfigOption<>(
- "bsp.max_super_step",
- "The max super step of the algorithm.",
- positiveInt(),
- 10
- );
-
- public static final ConfigOption<String> BSP_ETCD_ENDPOINTS =
- new ConfigOption<>(
- "bsp.etcd_endpoints",
- "The end points to access etcd.",
- disallowEmpty(),
- "http://localhost:2379"
- );
-
- public static final ConfigOption<Long> BSP_REGISTER_TIMEOUT =
- new ConfigOption<>(
- "bsp.register_timeout",
- "The max timeout to wait for master and works to register.",
- positiveInt(),
- TimeUnit.MINUTES.toMillis(5L)
- );
-
- public static final ConfigOption<Long> BSP_WAIT_WORKERS_TIMEOUT =
- new ConfigOption<>(
- "bsp.wait_workers_timeout",
- "The max timeout to wait for workers bsp event.",
- positiveInt(),
- TimeUnit.HOURS.toMillis(24L)
- );
-
- public static final ConfigOption<Long> BSP_WAIT_MASTER_TIMEOUT =
- new ConfigOption<>(
- "bsp.wait_master_timeout",
- "The max timeout(in ms) to wait for master bsp event.",
- positiveInt(),
- TimeUnit.HOURS.toMillis(24L)
- );
-
- public static final ConfigOption<Long> BSP_LOG_INTERVAL =
- new ConfigOption<>(
- "bsp.log_interval",
- "The log interval(in ms) to print the log while " +
- "waiting bsp event.",
- positiveInt(),
- TimeUnit.SECONDS.toMillis(30L)
- );
-
- public static final ConfigOption<Class<?>> WORKER_PARTITIONER =
- new ConfigOption<>(
- "worker.partitioner",
- "The partitioner that decides which partition a vertex " +
- "should be in, and which worker a partition should be in.",
- disallowEmpty(),
- loadClass("com.baidu.hugegraph.computer.core.graph.partition.HashPartitioner")
- );
-
- public static final ConfigOption<Class<?>> WORKER_COMPUTATION_CLASS =
- new ConfigOption<>(
- "worker.computation_class",
- "The class to create worker-computation object, " +
- "worker-computation is used to compute each vertex " +
- "in each superstep.",
- disallowEmpty(),
- Null.class
- );
-
- public static final ConfigOption<Class<?>> WORKER_COMBINER_CLASS =
- new ConfigOption<>(
- "worker.combiner_class",
- "Combiner can combine messages into one value for a " +
- "vertex, for example page-rank algorithm can combine " +
- "messages of a vertex to a sum value.",
- disallowEmpty(),
- Null.class
- );
-
- public static final ConfigOption<Class<?>>
- WORKER_VERTEX_PROPERTIES_COMBINER_CLASS =
- new ConfigOption<>(
- "worker.vertex_properties_combiner_class",
- "The combiner can combine several properties of the same " +
- "vertex into one properties at inputstep.",
- disallowEmpty(),
- OverwritePropertiesCombiner.class
- );
-
- public static final ConfigOption<Class<?>>
- WORKER_EDGE_PROPERTIES_COMBINER_CLASS =
- new ConfigOption<>(
- "worker.edge_properties_combiner_class",
- "The combiner can combine several properties of the same " +
- "edge into one properties at inputstep.",
- disallowEmpty(),
- OverwritePropertiesCombiner.class
- );
-
- public static final ConfigOption<Long> WORKER_RECEIVED_BUFFERS_BYTES_LIMIT =
- new ConfigOption<>(
- "worker.received_buffers_bytes_limit",
- "The limit bytes of buffers of received data, " +
- "the total size of all buffers can't excess this limit. " +
- "If received buffers reach this limit, they will be " +
- "merged into a file.",
- positiveInt(),
- 100 * Bytes.MB
- );
-
- public static final ConfigOption<Long> WORKER_WAIT_SORT_TIMEOUT =
- new ConfigOption<>(
- "worker.wait_sort_timeout",
- "The max timeout(in ms) message-handler wait for " +
- "sort-thread to sort one batch of buffers.",
- positiveInt(),
- TimeUnit.MINUTES.toMillis(10)
- );
-
- public static final ConfigOption<Long> WORKER_WAIT_FINISH_MESSAGES_TIMEOUT =
- new ConfigOption<>(
- "worker.wait_finish_messages_timeout",
- "The max timeout(in ms) message-handler wait for " +
- "finish-message of all workers.",
- positiveInt(),
- TimeUnit.HOURS.toMillis(24)
- );
-
- public static final ConfigListOption<String> WORKER_DATA_DIRS =
- new ConfigListOption<>(
- "worker.data_dirs",
- true,
- "The directories separated by ',' that received " +
- "vertices and messages can persist into.",
- disallowEmpty(),
- String.class,
- ImmutableList.of("jobs")
- );
-
- public static final ConfigOption<Integer> WORKER_WRITE_BUFFER_THRESHOLD =
- new ConfigOption<>(
- "worker.write_buffer_threshold",
- "The threshold of write buffer, exceeding it will " +
- "trigger sorting, the write buffer is used to store " +
- "vertex or message.",
- positiveInt(),
- (int) (50 * Bytes.MB)
- );
-
- public static final ConfigOption<Integer>
- WORKER_WRITE_BUFFER_INIT_CAPACITY = new ConfigOption<>(
- "worker.write_buffer_capacity",
- "The initial size of write buffer that used to store " +
- "vertex or message.",
- positiveInt(),
- (int) (50 * Bytes.MB)
- );
-
- public static final ConfigOption<Class<?>> MASTER_COMPUTATION_CLASS =
- new ConfigOption<>(
- "master.computation_class",
- "Master-computation is computation that can determine " +
- "whether to continue next superstep. It runs at the end " +
- "of each superstep on master.",
- disallowEmpty(),
- DefaultMasterComputation.class
- );
-
- public static final ConfigOption<String> HUGEGRAPH_URL =
- new ConfigOption<>(
- "hugegraph.url",
- "The hugegraph url to load data and write results back.",
- disallowEmpty(),
- "http://127.0.0.1:8080"
- );
-
- public static final ConfigOption<String> HUGEGRAPH_GRAPH_NAME =
- new ConfigOption<>(
- "hugegraph.name",
- "The graph name to load data and write results back.",
- disallowEmpty(),
- "hugegraph"
- );
-
- public static final ConfigOption<String> TRANSPORT_SERVER_HOST =
- new ConfigOption<>(
- "transport.server_host",
- "The server hostname or ip to listen on to transfer data.",
- disallowEmpty(),
- "127.0.0.1"
- );
-
- public static final ConfigOption<Integer> TRANSPORT_SERVER_PORT =
- new ConfigOption<>(
- "transport.server_port",
- "The server port to listen on to transfer data. " +
- "The system will assign a random port if it's set to 0.",
- nonNegativeInt(),
- 0
- );
-
- public static final ConfigOption<Integer> TRANSPORT_SERVER_THREADS =
- new ConfigOption<>(
- "transport.server_threads",
- "The number of transport threads for server.",
- positiveInt(),
- TRANSPORT_DEFAULT_THREADS
- );
-
- public static final ConfigOption<Integer> TRANSPORT_CLIENT_THREADS =
- new ConfigOption<>(
- "transport.client_threads",
- "The number of transport threads for client.",
- positiveInt(),
- TRANSPORT_DEFAULT_THREADS
- );
-
- public static final ConfigOption<Class<?>> TRANSPORT_PROVIDER_CLASS =
- new ConfigOption<>(
- "transport.provider_class",
- "The transport provider, currently only supports Netty.",
- disallowEmpty(),
- loadClass("com.baidu.hugegraph.computer.core.network.netty" +
- ".NettyTransportProvider")
- );
-
- public static final ConfigOption<String> TRANSPORT_IO_MODE =
- new ConfigOption<>(
- "transport.io_mode",
- "The network IO Mode, either 'NIO', 'EPOLL', 'AUTO', the " +
- "'AUTO' means selecting the property mode automatically.",
- allowValues("NIO", "EPOLL", "AUTO"),
- "AUTO"
- );
-
- public static final ConfigOption<Boolean> TRANSPORT_EPOLL_LT =
- new ConfigOption<>(
- "transport.transport_epoll_lt",
- "Whether enable EPOLL level-trigger.",
- allowValues(true, false),
- false
- );
-
- public static final ConfigOption<Boolean> TRANSPORT_RECV_FILE_MODE =
- new ConfigOption<>(
- "transport.recv_file_mode",
- "Whether enable receive buffer-file mode, it will " +
- "receive buffer write file from socket by " +
- "zero-copy if enable.",
- allowValues(true, false),
- true
- );
-
- public static final ConfigOption<Boolean> TRANSPORT_TCP_KEEP_ALIVE =
- new ConfigOption<>(
- "transport.tcp_keep_alive",
- "Whether enable TCP keep-alive.",
- allowValues(true, false),
- true
- );
-
- public static final ConfigOption<Integer> TRANSPORT_MAX_SYN_BACKLOG =
- new ConfigOption<>(
- "transport.max_syn_backlog",
- "The capacity of SYN queue on server side, 0 means using " +
- "system default value.",
- nonNegativeInt(),
- 511
- );
-
- public static final ConfigOption<Integer> TRANSPORT_RECEIVE_BUFFER_SIZE =
- new ConfigOption<>(
- "transport.receive_buffer_size",
- "The size of socket receive-buffer in bytes, 0 means " +
- "using system default value.",
- nonNegativeInt(),
- 0
- );
-
- public static final ConfigOption<Integer> TRANSPORT_SEND_BUFFER_SIZE =
- new ConfigOption<>(
- "transport.send_buffer_size",
- "The size of socket send-buffer in bytes, 0 means using " +
- "system default value.",
- nonNegativeInt(),
- // TODO: Test to get an best value
- 0
- );
-
- public static final ConfigOption<Long> TRANSPORT_CLIENT_CONNECT_TIMEOUT =
- new ConfigOption<>(
- "transport.client_connect_timeout",
- "The timeout(in ms) of client connect to server.",
- positiveInt(),
- 3000L
- );
-
- public static final ConfigOption<Long> TRANSPORT_CLOSE_TIMEOUT =
- new ConfigOption<>(
- "transport.close_timeout",
- "The timeout(in ms) of close server or close client.",
- positiveInt(),
- 10_000L
- );
-
- public static final ConfigOption<Long> TRANSPORT_SYNC_REQUEST_TIMEOUT =
- new ConfigOption<>(
- "transport.sync_request_timeout",
- "The timeout(in ms) to wait response after " +
- "sending sync-request.",
- positiveInt(),
- 10_000L
- );
-
- public static final ConfigOption<Long> TRANSPORT_FINISH_SESSION_TIMEOUT =
- new ConfigOption<>(
- "transport.finish_session_timeout",
- "The timeout(in ms) to finish session, " +
- "0 means using (transport.sync_request_timeout * " +
- "transport.max_pending_requests).",
- nonNegativeInt(),
- 0L
- );
-
- public static final ConfigOption<Long> TRANSPORT_WRITE_SOCKET_TIMEOUT =
- new ConfigOption<>(
- "transport.write_socket_timeout",
- "The timeout(in ms) to write data to socket buffer.",
- positiveInt(),
- 3000L
- );
-
- public static final ConfigOption<Integer> TRANSPORT_NETWORK_RETRIES =
- new ConfigOption<>(
- "transport.network_retries",
- "The number of retry attempts for network communication," +
- "if network unstable.",
- nonNegativeInt(),
- 3
- );
-
- public static final ConfigOption<Integer> TRANSPORT_WRITE_BUFFER_HIGH_MARK =
- new ConfigOption<>(
- "transport.write_buffer_high_mark",
- "The high water mark for write buffer in bytes, " +
- "it will trigger the sending unavailable if the number " +
- "of queued bytes > write_buffer_high_mark.",
- nonNegativeInt(),
- 64 * (int) Bytes.MB
- );
-
- public static final ConfigOption<Integer> TRANSPORT_WRITE_BUFFER_LOW_MARK =
- new ConfigOption<>(
- "transport.write_buffer_low_mark",
- "The low water mark for write buffer in bytes, it will " +
- "trigger the sending available if the number of queued " +
- "bytes < write_buffer_low_mark." +
- nonNegativeInt(),
- 32 * (int) Bytes.MB
- );
-
- public static final ConfigOption<Integer> TRANSPORT_MAX_PENDING_REQUESTS =
- new ConfigOption<>(
- "transport.max_pending_requests",
- "The max number of client unreceived ack, " +
- "it will trigger the sending unavailable if the number " +
- "of unreceived ack >= max_pending_requests.",
- positiveInt(),
- 8
- );
-
- public static final ConfigOption<Integer> TRANSPORT_MIN_PENDING_REQUESTS =
- new ConfigOption<>(
- "transport.min_pending_requests",
- "The minimum number of client unreceived ack, " +
- "it will trigger the sending available if the number of " +
- "unreceived ack < min_pending_requests.",
- positiveInt(),
- 6
- );
-
- public static final ConfigOption<Long> TRANSPORT_MIN_ACK_INTERVAL =
- new ConfigOption<>(
- "transport.min_ack_interval",
- "The minimum interval(in ms) of server reply ack.",
- positiveInt(),
- 200L
- );
-
- public static final ConfigOption<Long> TRANSPORT_SERVER_IDLE_TIMEOUT =
- new ConfigOption<>(
- "transport.server_idle_timeout",
- "The max timeout(in ms) of server idle.",
- positiveInt(),
- 360_000L
- );
-
- public static final ConfigOption<Long> TRANSPORT_HEARTBEAT_INTERVAL =
- new ConfigOption<>(
- "transport.heartbeat_interval",
- "The minimum interval(in ms) between heartbeats on " +
- "client side.",
- positiveInt(),
- 20_000L
- );
-
- public static final ConfigOption<Integer>
- TRANSPORT_MAX_TIMEOUT_HEARTBEAT_COUNT =
- new ConfigOption<>(
- "transport.max_timeout_heartbeat_count",
- "The maximum times of timeout heartbeat on client side, " +
- "if the number of timeouts waiting for heartbeat " +
- "response continuously > max_heartbeat_timeouts the " +
- "channel will be closed from client side.",
- positiveInt(),
- 120
- );
-
- public static final ConfigOption<Long> HGKV_MAX_FILE_SIZE =
- new ConfigOption<>(
- "hgkv.max_file_size",
- "The max number of bytes in each hgkv-file.",
- positiveInt(),
- Bytes.GB * 2
- );
-
- public static final ConfigOption<Long> HGKV_DATABLOCK_SIZE =
- new ConfigOption<>(
- "hgkv.max_data_block_size",
- "The max byte size of hgkv-file data block.",
- positiveInt(),
- Bytes.KB * 64
- );
-
- public static final ConfigOption<Integer> HGKV_MERGE_FILES_NUM =
- new ConfigOption<>(
- "hgkv.max_merge_files",
- "The max number of files to merge at one time.",
- positiveInt(),
- // TODO: test if the default value is appropriate.
- 10
- );
-
- public static final ConfigOption<String> HGKV_TEMP_DIR =
- new ConfigOption<>(
- "hgkv.temp_file_dir",
- "This folder is used to store temporary files, temporary " +
- "files will be generated during the file merging process.",
- disallowEmpty(),
- "/tmp/hgkv"
- );
-
- public static final ConfigOption<Long> VALUE_FILE_MAX_SEGMENT_SIZE =
- new ConfigOption<>(
- "valuefile.max_segment_size",
- "The max number of bytes in each segment of value-file.",
- positiveInt(),
- Bytes.GB
- );
-
- public static Set<String> REQUIRED_OPTIONS = ImmutableSet.of(
- );
-
- public static final Set<String> COMPUTER_PROHIBIT_USER_OPTIONS =
- ImmutableSet.of(
- ComputerOptions.BSP_ETCD_ENDPOINTS.name(),
- ComputerOptions.TRANSPORT_SERVER_HOST.name(),
- ComputerOptions.TRANSPORT_SERVER_PORT.name(),
- ComputerOptions.JOB_ID.name(),
- ComputerOptions.JOB_WORKERS_COUNT.name(),
- ComputerOptions.RPC_SERVER_HOST_NAME,
- ComputerOptions.RPC_SERVER_PORT_NAME,
- ComputerOptions.RPC_REMOTE_URL_NAME
- );
-
- public static final Set<String> COMPUTER_REQUIRED_USER_OPTIONS = ImmutableSet.of(
- ComputerOptions.ALGORITHM_PARAMS_CLASS.name()
- );
-
- private static Class<?> loadClass(String className) {
- try {
- return Class.forName(className);
- } catch (ClassNotFoundException e) {
- LOG.warn("Load class {} failed, use Null.class", className);
- return Null.class;
- }
- }
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/Config.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/Config.java
deleted file mode 100644
index dddea7e4..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/Config.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.config;
-
-import org.apache.hugegraph.config.ConfigOption;
-import org.apache.hugegraph.config.HugeConfig;
-import org.apache.hugegraph.config.TypedOption;
-
-public interface Config {
-
- HugeConfig hugeConfig();
-
- <R> R get(TypedOption<?, R> option);
-
- boolean getBoolean(String key, boolean defaultValue);
-
- int getInt(String key, int defaultValue);
-
- long getLong(String key, long defaultValue);
-
- double getDouble(String key, double defaultValue);
-
- String getString(String key, String defaultValue);
-
- <T> T createObject(ConfigOption<Class<?>> clazzOption);
-
- <T> T createObject(ConfigOption<Class<?>> clazzOption,
- boolean requiredNotNull);
-
- Boolean outputVertexAdjacentEdges();
-
- Boolean outputVertexProperties();
-
- Boolean outputEdgeProperties();
-}
diff --git a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/DefaultConfig.java b/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/DefaultConfig.java
deleted file mode 100644
index b74b02cb..00000000
--- a/computer-api/src/main/java/com/baidu/hugegraph/computer/core/config/DefaultConfig.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 2017 HugeGraph Authors
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.baidu.hugegraph.computer.core.config;
-
-import java.util.Map;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.configuration2.MapConfiguration;
-import org.apache.hugegraph.config.ConfigOption;
-import org.apache.hugegraph.config.HugeConfig;
-import org.apache.hugegraph.config.TypedOption;
-import org.apache.hugegraph.util.E;
-
-import com.baidu.hugegraph.computer.core.common.exception.ComputerException;
-
-public final class DefaultConfig implements Config {
-
- private final HugeConfig allConfig;
- private final HotConfig hotConfig;
-
- public DefaultConfig(Map<String, String> options) {
- this.allConfig = this.parseOptions(options);
- this.hotConfig = this.extractHotConfig(this.allConfig);
- this.checkOptions();
- }
-
- private HugeConfig parseOptions(Map<String, String> options) {
- if (!options.keySet().containsAll(ComputerOptions.REQUIRED_OPTIONS)) {
- E.checkArgument(false,
- "All required options must be setted, " +
- "but missing these %s",
- CollectionUtils.subtract(
- ComputerOptions.REQUIRED_OPTIONS,
- options.keySet()));
- }
- MapConfiguration mapConfig = new MapConfiguration(options);
- return new HugeConfig(mapConfig);
- }
-
- private HotConfig extractHotConfig(HugeConfig allConfig) {
- // Populate high frequency accessed options into HotConfig
- HotConfig hotConfig = new HotConfig();
-
- hotConfig.outputVertexAdjacentEdges(
... 128824 lines suppressed ...