From 9dff0aad4a7441c9248dd6dc4493f1f42395d19b Mon Sep 17 00:00:00 2001 From: coderzc Date: Wed, 29 Dec 2021 17:08:03 +0800 Subject: [PATCH 1/7] add common hugegraph output implement --- .../BetweennessCentralityParams.java | 3 +- .../closeness/ClosenessCentralityOutput.java | 35 ---------------- .../closeness/ClosenessCentralityParams.java | 3 +- .../degree/DegreeCentralityParams.java | 3 +- .../centrality/pagerank/PageRankParams.java | 3 +- .../community/kcore/KcoreParams.java | 4 +- .../algorithm/community/lpa/LpaParams.java | 4 +- .../trianglecount/TriangleCountParams.java | 3 +- .../algorithm/community/wcc/WccParams.java | 4 +- .../core/output/hg/DoubleHugeGraphOutput.java | 7 ++-- .../core/output/hg/FloatHugeGraphOutput.java | 13 +++--- .../core/output/hg/IdHugeGraphOutput.java | 40 +++++++++++++++++++ .../core/output/hg/IntHugeGraphOutput.java | 13 +++--- .../core/output/hg/LongHugeGraphOutput.java | 13 +++--- .../core/output/hg/StringHugeGraphOutput.java | 34 ++++++++++++++++ .../BetweennessCentralityTest.java | 3 +- .../closeness/ClosenessCentralityTest.java | 5 ++- .../degree/DegreeCentralityTest.java | 3 +- .../trianglecount/TriangleCountTest.java | 5 ++- 19 files changed, 121 insertions(+), 77 deletions(-) delete mode 100644 computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.java rename computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityOutput.java => computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java (81%) rename computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankOutput.java => computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java (74%) create mode 100644 computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java rename computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityOutput.java => computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java (73%) rename computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountOutput.java => computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java (74%) create mode 100644 computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java 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 index 9e6266cd7..13900f681 100644 --- 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 @@ -26,6 +26,7 @@ import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; +import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; public class BetweennessCentralityParams implements AlgorithmParams { @@ -40,7 +41,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS, BetweennessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - BetweennessCentralityOutput.class.getName()); + DoubleHugeGraphOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, ExtractAllPropertyInputFilter.class.getName()); this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE, diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.java deleted file mode 100644 index 121832c59..000000000 --- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityOutput.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.algorithm.centrality.closeness; - -import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput; -import com.baidu.hugegraph.structure.constant.WriteType; - -public class ClosenessCentralityOutput extends HugeGraphOutput { - - @Override - public void prepareSchema() { - this.client().schema().propertyKey(this.name()) - .asDouble() - .writeType(WriteType.OLAP_RANGE) - .ifNotExist() - .create(); - } -} 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 index eded57d20..1d4390fb3 100644 --- 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 @@ -25,6 +25,7 @@ import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; +import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; public class ClosenessCentralityParams implements AlgorithmParams { @@ -39,7 +40,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS, ClosenessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - ClosenessCentralityOutput.class.getName()); + DoubleHugeGraphOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, ExtractAllPropertyInputFilter.class.getName()); this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE, 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 index af6e836be..c3d1410d7 100644 --- 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 @@ -26,6 +26,7 @@ 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; +import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; public class DegreeCentralityParams implements AlgorithmParams { @@ -42,6 +43,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - DegreeCentralityOutput.class.getName()); + DoubleHugeGraphOutput.class.getName()); } } 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 index a8d523090..d124de516 100644 --- 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 @@ -25,6 +25,7 @@ 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.output.hg.DoubleHugeGraphOutput; public class PageRankParams implements AlgorithmParams { @@ -41,6 +42,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - PageRankOutput.class.getName()); + DoubleHugeGraphOutput.class.getName()); } } 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 index 6fd26b927..190532fd1 100644 --- 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 @@ -25,7 +25,7 @@ import com.baidu.hugegraph.computer.core.combiner.ValueMinCombiner; import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.id.BytesId; -import com.baidu.hugegraph.computer.core.output.LimitedLogOutput; +import com.baidu.hugegraph.computer.core.output.hg.IdHugeGraphOutput; public class KcoreParams implements AlgorithmParams { @@ -40,6 +40,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, ValueMinCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - LimitedLogOutput.class.getName()); + IdHugeGraphOutput.class.getName()); } } 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 index 93de697e2..87dc7291b 100644 --- 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 @@ -24,7 +24,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmParams; import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.id.BytesId; -import com.baidu.hugegraph.computer.core.output.LimitedLogOutput; +import com.baidu.hugegraph.computer.core.output.hg.IdHugeGraphOutput; public class LpaParams implements AlgorithmParams { @@ -37,6 +37,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS, BytesId.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - LimitedLogOutput.class.getName()); + IdHugeGraphOutput.class.getName()); } } 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 index 513d94df3..52f7d6773 100644 --- 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 @@ -25,6 +25,7 @@ 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; +import com.baidu.hugegraph.computer.core.output.hg.LongHugeGraphOutput; public class TriangleCountParams implements AlgorithmParams { @@ -37,7 +38,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS, TriangleCountValue.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - TriangleCountOutput.class.getName()); + LongHugeGraphOutput.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/wcc/WccParams.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/wcc/WccParams.java index 232d7bdb8..e076928dd 100644 --- 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 @@ -25,7 +25,7 @@ import com.baidu.hugegraph.computer.core.combiner.ValueMinCombiner; import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.id.BytesId; -import com.baidu.hugegraph.computer.core.output.LimitedLogOutput; +import com.baidu.hugegraph.computer.core.output.hg.IdHugeGraphOutput; public class WccParams implements AlgorithmParams { @@ -40,6 +40,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, ValueMinCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - LimitedLogOutput.class.getName()); + IdHugeGraphOutput.class.getName()); } } diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java similarity index 81% rename from computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java index f17b42567..0b4e8ec72 100644 --- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java @@ -17,15 +17,14 @@ * under the License. */ -package com.baidu.hugegraph.computer.algorithm.centrality.betweenness; +package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput; import com.baidu.hugegraph.structure.constant.WriteType; -public class BetweennessCentralityOutput extends HugeGraphOutput { +public class DoubleHugeGraphOutput extends HugeGraphOutput { @Override - public void prepareSchema() { + protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asDouble() .writeType(WriteType.OLAP_RANGE) diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java similarity index 74% rename from computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java index 667f1e66d..5577d33c3 100644 --- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/pagerank/PageRankOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java @@ -17,19 +17,18 @@ * under the License. */ -package com.baidu.hugegraph.computer.algorithm.centrality.pagerank; +package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput; import com.baidu.hugegraph.structure.constant.WriteType; -public class PageRankOutput extends HugeGraphOutput { +public class FloatHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asDouble() - .writeType(WriteType.OLAP_RANGE) - .ifNotExist() - .create(); + .asFloat() + .writeType(WriteType.OLAP_RANGE) + .ifNotExist() + .create(); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java new file mode 100644 index 000000000..2d554fa94 --- /dev/null +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.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 com.baidu.hugegraph.computer.core.output.hg; + +import com.baidu.hugegraph.computer.core.graph.vertex.Vertex; +import com.baidu.hugegraph.structure.constant.WriteType; + +public class IdHugeGraphOutput extends HugeGraphOutput { + + @Override + protected void prepareSchema() { + this.client().schema().propertyKey(this.name()) + .asText() + .writeType(WriteType.OLAP_COMMON) + .ifNotExist() + .create(); + } + + @Override + protected String value(Vertex vertex) { + return vertex.value().string(); + } +} diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java similarity index 73% rename from computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java index ca3a03de7..fb4296064 100644 --- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java @@ -17,19 +17,18 @@ * under the License. */ -package com.baidu.hugegraph.computer.algorithm.centrality.degree; +package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput; import com.baidu.hugegraph.structure.constant.WriteType; -public class DegreeCentralityOutput extends HugeGraphOutput { +public class IntHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asDouble() - .writeType(WriteType.OLAP_RANGE) - .ifNotExist() - .create(); + .asInt() + .writeType(WriteType.OLAP_RANGE) + .ifNotExist() + .create(); } } diff --git a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java similarity index 74% rename from computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java index 9660817a1..1797971ef 100644 --- a/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java @@ -17,19 +17,18 @@ * under the License. */ -package com.baidu.hugegraph.computer.algorithm.community.trianglecount; +package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.computer.core.output.hg.HugeGraphOutput; import com.baidu.hugegraph.structure.constant.WriteType; -public class TriangleCountOutput extends HugeGraphOutput { +public class LongHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asLong() - .writeType(WriteType.OLAP_RANGE) - .ifNotExist() - .create(); + .asLong() + .writeType(WriteType.OLAP_RANGE) + .ifNotExist() + .create(); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java new file mode 100644 index 000000000..6188c70e9 --- /dev/null +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java @@ -0,0 +1,34 @@ +/* + * 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.output.hg; + +import com.baidu.hugegraph.structure.constant.WriteType; + +public class StringHugeGraphOutput extends HugeGraphOutput { + + @Override + protected void prepareSchema() { + this.client().schema().propertyKey(this.name()) + .asText() + .writeType(WriteType.OLAP_COMMON) + .ifNotExist() + .create(); + } +} diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java index b72f94570..c792d7bdd 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java @@ -27,6 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; +import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.HugeClient; import com.baidu.hugegraph.driver.SchemaManager; @@ -130,7 +131,7 @@ public void testRunAlgorithm() throws InterruptedException { } public static class BetweennessCentralityTestOutput - extends BetweennessCentralityOutput { + extends DoubleHugeGraphOutput { @Override protected Double value( diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java index 4d4537057..eb72cf988 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java @@ -27,6 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; +import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.HugeClient; import com.baidu.hugegraph.driver.SchemaManager; @@ -106,7 +107,7 @@ public void testWithWeightProperty() throws InterruptedException { } public static class ClosenessWithWeightPropertyTestOutput - extends ClosenessCentralityOutput { + extends DoubleHugeGraphOutput { private final Map expectResults = ImmutableMap.builder() @@ -140,7 +141,7 @@ public void testWithoutWeightProperty() throws InterruptedException { } public static class ClosenessWithoutWeightPropertyTestOutput - extends ClosenessCentralityOutput { + extends DoubleHugeGraphOutput { private final Map expectResults = ImmutableMap.builder() diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java index 79ccda145..c86242475 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java @@ -32,6 +32,7 @@ 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.vertex.Vertex; +import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; import com.google.common.collect.Streams; public class DegreeCentralityTest extends AlgorithmTestBase { @@ -58,7 +59,7 @@ public void setAlgorithmParameters(Map params) { } public static class DegreeCentralityTestOutput - extends DegreeCentralityOutput { + extends DoubleHugeGraphOutput { private String weight; private static boolean isRun; diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java index 9d94159c5..728ea2222 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java @@ -27,6 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; +import com.baidu.hugegraph.computer.core.output.hg.LongHugeGraphOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.SchemaManager; import com.baidu.hugegraph.structure.constant.T; @@ -117,12 +118,12 @@ public void testTriangleCountValue() { Assert.assertContains("10", value.toString()); } - public static class TriangleCountOutputTest extends TriangleCountOutput { + public static class TriangleCountOutputTest extends LongHugeGraphOutput { @Override public Long value( com.baidu.hugegraph.computer.core.graph.vertex.Vertex vertex) { - Long value = (Long) super.value(vertex); + Long value = super.value(vertex); Long expected = EXPECTED_RESULTS.get(vertex.id()); if (expected != null) { Assert.assertEquals(expected, value); From c9b869d4fe415b8166c5062cdcf90a80069d700f Mon Sep 17 00:00:00 2001 From: coderzc Date: Wed, 29 Dec 2021 19:09:51 +0800 Subject: [PATCH 2/7] add WriteType config --- .../betweenness/BetweennessCentralityParams.java | 3 +++ .../centrality/closeness/ClosenessCentralityParams.java | 3 +++ .../centrality/degree/DegreeCentralityParams.java | 3 +++ .../algorithm/centrality/pagerank/PageRankParams.java | 3 +++ .../community/trianglecount/TriangleCountParams.java | 3 +++ .../algorithm/path/rings/RingsDetectionOutput.java | 3 +-- .../hugegraph/computer/core/config/ComputerOptions.java | 8 ++++++++ .../computer/core/output/hg/DoubleHugeGraphOutput.java | 4 +--- .../computer/core/output/hg/FloatHugeGraphOutput.java | 6 ++---- .../computer/core/output/hg/HugeGraphOutput.java | 8 ++++++++ .../computer/core/output/hg/IdHugeGraphOutput.java | 3 +-- .../computer/core/output/hg/IntHugeGraphOutput.java | 4 +--- .../computer/core/output/hg/LongHugeGraphOutput.java | 4 +--- .../computer/core/output/hg/StringHugeGraphOutput.java | 4 +--- 14 files changed, 39 insertions(+), 20 deletions(-) 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 index 13900f681..d3e4476ef 100644 --- 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 @@ -27,6 +27,7 @@ import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.structure.constant.WriteType; public class BetweennessCentralityParams implements AlgorithmParams { @@ -42,6 +43,8 @@ public void setAlgorithmParameters(Map params) { BetweennessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, DoubleHugeGraphOutput.class.getName()); + this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, + WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, ExtractAllPropertyInputFilter.class.getName()); this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE, 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 index 1d4390fb3..dc8887a75 100644 --- 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 @@ -26,6 +26,7 @@ import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.structure.constant.WriteType; public class ClosenessCentralityParams implements AlgorithmParams { @@ -41,6 +42,8 @@ public void setAlgorithmParameters(Map params) { ClosenessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, DoubleHugeGraphOutput.class.getName()); + this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, + WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, ExtractAllPropertyInputFilter.class.getName()); this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE, 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 index c3d1410d7..21abcb150 100644 --- 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 @@ -27,6 +27,7 @@ import com.baidu.hugegraph.computer.core.graph.value.DoubleValue; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.structure.constant.WriteType; public class DegreeCentralityParams implements AlgorithmParams { @@ -44,5 +45,7 @@ public void setAlgorithmParameters(Map params) { DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, DoubleHugeGraphOutput.class.getName()); + this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, + WriteType.OLAP_RANGE.name()); } } 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 index d124de516..131fa98f9 100644 --- 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 @@ -26,6 +26,7 @@ import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.value.DoubleValue; import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.structure.constant.WriteType; public class PageRankParams implements AlgorithmParams { @@ -43,5 +44,7 @@ public void setAlgorithmParameters(Map params) { DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, DoubleHugeGraphOutput.class.getName()); + this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, + WriteType.OLAP_RANGE.name()); } } 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 index 52f7d6773..ae3df2414 100644 --- 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 @@ -26,6 +26,7 @@ import com.baidu.hugegraph.computer.core.config.EdgeFrequency; import com.baidu.hugegraph.computer.core.graph.value.IdList; import com.baidu.hugegraph.computer.core.output.hg.LongHugeGraphOutput; +import com.baidu.hugegraph.structure.constant.WriteType; public class TriangleCountParams implements AlgorithmParams { @@ -39,6 +40,8 @@ public void setAlgorithmParameters(Map params) { TriangleCountValue.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, LongHugeGraphOutput.class.getName()); + this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, + WriteType.OLAP_RANGE.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/path/rings/RingsDetectionOutput.java b/computer-algorithm/src/main/java/com/baidu/hugegraph/computer/algorithm/path/rings/RingsDetectionOutput.java index 9014be18f..d74ec6f29 100644 --- 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 @@ -25,7 +25,6 @@ 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; -import com.baidu.hugegraph.structure.constant.WriteType; public class RingsDetectionOutput extends HugeGraphOutput> { @@ -33,7 +32,7 @@ public class RingsDetectionOutput extends HugeGraphOutput> { protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asText() - .writeType(WriteType.OLAP_COMMON) + .writeType(this.writeType()) .valueList() .ifNotExist() .create(); diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java index 7ffb41872..176c959b3 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java @@ -225,6 +225,14 @@ public static synchronized ComputerOptions instance() { false ); + public static final ConfigOption OUTPUT_RESULT_WRITE_TYPE = + new ConfigOption<>( + "output.result_write_type", + "The value is write-type of result output to hugegraph.", + allowValues("OLAP_COMMON", "OLAP_SECONDARY", "OLAP_RANGE"), + "OLAP_COMMON" + ); + public static final ConfigOption OUTPUT_BATCH_SIZE = new ConfigOption<>( "output.batch_size", diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java index 0b4e8ec72..3660890b5 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java @@ -19,15 +19,13 @@ package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.structure.constant.WriteType; - public class DoubleHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asDouble() - .writeType(WriteType.OLAP_RANGE) + .writeType(this.writeType()) .ifNotExist() .create(); } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java index 5577d33c3..be5c68e81 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java @@ -19,15 +19,13 @@ package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.structure.constant.WriteType; - -public class FloatHugeGraphOutput extends HugeGraphOutput { +public class FloatHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asFloat() - .writeType(WriteType.OLAP_RANGE) + .writeType(this.writeType()) .ifNotExist() .create(); } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java index 5fa12e9f6..f8448b494 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java @@ -30,6 +30,7 @@ import com.baidu.hugegraph.computer.core.output.AbstractComputerOutput; import com.baidu.hugegraph.computer.core.output.hg.task.TaskManager; import com.baidu.hugegraph.driver.HugeClient; +import com.baidu.hugegraph.structure.constant.WriteType; import com.baidu.hugegraph.util.Log; public abstract class HugeGraphOutput extends AbstractComputerOutput { @@ -39,6 +40,7 @@ public abstract class HugeGraphOutput extends AbstractComputerOutput { private TaskManager taskManager; private List localVertices; private int batchSize; + private WriteType writeType; @Override public void init(Config config, int partition) { @@ -47,6 +49,8 @@ public void init(Config config, int partition) { this.taskManager = new TaskManager(config); this.batchSize = config.get(ComputerOptions.OUTPUT_BATCH_SIZE); this.localVertices = new ArrayList<>(this.batchSize); + this.writeType = WriteType.valueOf( + config.get(ComputerOptions.OUTPUT_RESULT_WRITE_TYPE)); this.prepareSchema(); } @@ -95,5 +99,9 @@ protected T value(Vertex vertex) { return value; } + public WriteType writeType() { + return this.writeType; + } + protected abstract void prepareSchema(); } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java index 2d554fa94..721db2df2 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java @@ -20,7 +20,6 @@ package com.baidu.hugegraph.computer.core.output.hg; import com.baidu.hugegraph.computer.core.graph.vertex.Vertex; -import com.baidu.hugegraph.structure.constant.WriteType; public class IdHugeGraphOutput extends HugeGraphOutput { @@ -28,7 +27,7 @@ public class IdHugeGraphOutput extends HugeGraphOutput { protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asText() - .writeType(WriteType.OLAP_COMMON) + .writeType(this.writeType()) .ifNotExist() .create(); } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java index fb4296064..4e0e06aa1 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java @@ -19,15 +19,13 @@ package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.structure.constant.WriteType; - public class IntHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asInt() - .writeType(WriteType.OLAP_RANGE) + .writeType(this.writeType()) .ifNotExist() .create(); } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java index 1797971ef..e30545e8e 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java @@ -19,15 +19,13 @@ package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.structure.constant.WriteType; - public class LongHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asLong() - .writeType(WriteType.OLAP_RANGE) + .writeType(this.writeType()) .ifNotExist() .create(); } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java index 6188c70e9..3297573ba 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java @@ -19,15 +19,13 @@ package com.baidu.hugegraph.computer.core.output.hg; -import com.baidu.hugegraph.structure.constant.WriteType; - public class StringHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) .asText() - .writeType(WriteType.OLAP_COMMON) + .writeType(this.writeType()) .ifNotExist() .create(); } From cd4305f71d331b33b062682cfffe88b2a8e53ff1 Mon Sep 17 00:00:00 2001 From: coderzc Date: Wed, 29 Dec 2021 19:17:30 +0800 Subject: [PATCH 3/7] triangleCount use int value --- .../trianglecount/TriangleCount.java | 12 ++++------ .../trianglecount/TriangleCountParams.java | 4 ++-- .../trianglecount/TriangleCountValue.java | 12 +++++----- .../trianglecount/TriangleCountTest.java | 24 +++++++++---------- 4 files changed, 25 insertions(+), 27 deletions(-) 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 index fd2c3ea59..7d3d02225 100644 --- 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 @@ -34,11 +34,9 @@ public class TriangleCount implements Computation { - public static final String ALGORITHM_NAME = "triangle_count"; - @Override public String name() { - return ALGORITHM_NAME; + return "triangle_count"; } @Override @@ -60,15 +58,15 @@ public void compute0(ComputationContext context, Vertex vertex) { @Override public void compute(ComputationContext context, Vertex vertex, Iterator messages) { - Long count = this.triangleCount(context, vertex, messages); + Integer count = this.triangleCount(context, vertex, messages); if (count != null) { ((TriangleCountValue) vertex.value()).count(count); vertex.inactivate(); } } - private Long triangleCount(ComputationContext context, Vertex vertex, - Iterator messages) { + private Integer triangleCount(ComputationContext context, Vertex vertex, + Iterator messages) { IdList neighbors = ((TriangleCountValue) vertex.value()).idList(); if (context.superstep() == 1) { @@ -91,7 +89,7 @@ private Long triangleCount(ComputationContext context, Vertex vertex, context.sendMessage(targetId, neighbors); } } else if (context.superstep() == 2) { - long count = 0L; + int count = 0; Set allNeighbors = new HashSet<>(neighbors.values()); while (messages.hasNext()) { 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 index ae3df2414..9fb47a6dd 100644 --- 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 @@ -25,7 +25,7 @@ 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; -import com.baidu.hugegraph.computer.core.output.hg.LongHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.IntHugeGraphOutput; import com.baidu.hugegraph.structure.constant.WriteType; public class TriangleCountParams implements AlgorithmParams { @@ -39,7 +39,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS, TriangleCountValue.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - LongHugeGraphOutput.class.getName()); + IntHugeGraphOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.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 index e8019ef07..b687b276b 100644 --- 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 @@ -24,19 +24,19 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import com.baidu.hugegraph.computer.core.graph.value.IdList; -import com.baidu.hugegraph.computer.core.graph.value.LongValue; +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 { +public class TriangleCountValue implements CustomizeValue { private IdList idList; - private LongValue count; + private IntValue count; public TriangleCountValue() { this.idList = new IdList(); - this.count = new LongValue(); + this.count = new IntValue(); } public IdList idList() { @@ -47,7 +47,7 @@ public long count() { return this.count.longValue(); } - public void count(long count) { + public void count(int count) { this.count.value(count); } @@ -80,7 +80,7 @@ public String toString() { } @Override - public Long value() { + public Integer value() { return this.count.value(); } } diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java index 728ea2222..7617da08d 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java @@ -27,7 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; -import com.baidu.hugegraph.computer.core.output.hg.LongHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.IntHugeGraphOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.SchemaManager; import com.baidu.hugegraph.structure.constant.T; @@ -42,10 +42,10 @@ public class TriangleCountTest extends AlgorithmTestBase { private static final String EDGE_LABEL = "tc_know"; private static final String PROPERTY_KEY = "tc_weight"; - protected static final Map EXPECTED_RESULTS = - ImmutableMap.of("tc_A", 2L, "tc_B", 1L, - "tc_C", 3L, "tc_D", 2L, - "tc_E", 1L); + protected static final Map EXPECTED_RESULTS = + ImmutableMap.of("tc_A", 2, "tc_B", 1, + "tc_C", 3, "tc_D", 2, + "tc_E", 1); @BeforeClass public static void setup() { @@ -105,26 +105,26 @@ public void testRunAlgorithm() throws InterruptedException { @Test public void testTriangleCountValue() { TriangleCountValue value = new TriangleCountValue(); - value.count(10L); + value.count(10); Assert.assertThrows(UnsupportedOperationException.class, () -> value.assign(null)); Assert.assertThrows(UnsupportedOperationException.class, () -> value.compareTo(new TriangleCountValue())); - TriangleCountValue copy = (TriangleCountValue) value.copy(); - Assert.assertEquals(10L, copy.count()); + TriangleCountValue copy = value.copy(); + Assert.assertEquals(10, copy.count()); Assert.assertNotSame(value.idList(), copy.idList()); Assert.assertContains("10", value.toString()); } - public static class TriangleCountOutputTest extends LongHugeGraphOutput { + public static class TriangleCountOutputTest extends IntHugeGraphOutput { @Override - public Long value( + public Integer value( com.baidu.hugegraph.computer.core.graph.vertex.Vertex vertex) { - Long value = super.value(vertex); - Long expected = EXPECTED_RESULTS.get(vertex.id()); + Integer value = super.value(vertex); + Integer expected = EXPECTED_RESULTS.get(vertex.id()); if (expected != null) { Assert.assertEquals(expected, value); } From a76c8d61fb098405d3c012240a1bbbc5ed2f79ac Mon Sep 17 00:00:00 2001 From: coderzc Date: Wed, 29 Dec 2021 19:20:34 +0800 Subject: [PATCH 4/7] improve code --- .../computer/core/output/hg/DoubleHugeGraphOutput.java | 8 ++++---- .../computer/core/output/hg/FloatHugeGraphOutput.java | 8 ++++---- .../computer/core/output/hg/IdHugeGraphOutput.java | 8 ++++---- .../computer/core/output/hg/IntHugeGraphOutput.java | 8 ++++---- .../computer/core/output/hg/LongHugeGraphOutput.java | 8 ++++---- .../computer/core/output/hg/StringHugeGraphOutput.java | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java index 3660890b5..65cbaab3b 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java @@ -24,9 +24,9 @@ public class DoubleHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asDouble() - .writeType(this.writeType()) - .ifNotExist() - .create(); + .asDouble() + .writeType(this.writeType()) + .ifNotExist() + .create(); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java index be5c68e81..ecd6899f6 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java @@ -24,9 +24,9 @@ public class FloatHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asFloat() - .writeType(this.writeType()) - .ifNotExist() - .create(); + .asFloat() + .writeType(this.writeType()) + .ifNotExist() + .create(); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java index 721db2df2..5efbe3662 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java @@ -26,10 +26,10 @@ public class IdHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asText() - .writeType(this.writeType()) - .ifNotExist() - .create(); + .asText() + .writeType(this.writeType()) + .ifNotExist() + .create(); } @Override diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java index 4e0e06aa1..50cc74610 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java @@ -24,9 +24,9 @@ public class IntHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asInt() - .writeType(this.writeType()) - .ifNotExist() - .create(); + .asInt() + .writeType(this.writeType()) + .ifNotExist() + .create(); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java index e30545e8e..63da8e26c 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java @@ -24,9 +24,9 @@ public class LongHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asLong() - .writeType(this.writeType()) - .ifNotExist() - .create(); + .asLong() + .writeType(this.writeType()) + .ifNotExist() + .create(); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java index 3297573ba..92bc7c6fc 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java @@ -24,9 +24,9 @@ public class StringHugeGraphOutput extends HugeGraphOutput { @Override protected void prepareSchema() { this.client().schema().propertyKey(this.name()) - .asText() - .writeType(this.writeType()) - .ifNotExist() - .create(); + .asText() + .writeType(this.writeType()) + .ifNotExist() + .create(); } } From 29889736a21b56fd051eb0c477e01026bf10d77d Mon Sep 17 00:00:00 2001 From: coderzc Date: Fri, 31 Dec 2021 16:54:22 +0800 Subject: [PATCH 5/7] improve some comment --- .../centrality/betweenness/BetweennessCentralityParams.java | 4 ++-- .../centrality/closeness/ClosenessCentralityParams.java | 4 ++-- .../algorithm/centrality/degree/DegreeCentralityParams.java | 4 ++-- .../algorithm/centrality/pagerank/PageRankParams.java | 4 ++-- .../computer/algorithm/community/kcore/KcoreParams.java | 4 ++-- .../computer/algorithm/community/lpa/LpaParams.java | 4 ++-- .../community/trianglecount/TriangleCountParams.java | 4 ++-- .../computer/algorithm/community/wcc/WccParams.java | 4 ++-- .../hugegraph/computer/core/config/ComputerOptions.java | 4 +++- ...oubleHugeGraphOutput.java => HugeGraphDoubleOutput.java} | 2 +- ...{FloatHugeGraphOutput.java => HugeGraphFloatOutput.java} | 2 +- .../hg/{IdHugeGraphOutput.java => HugeGraphIdOutput.java} | 2 +- .../hg/{IntHugeGraphOutput.java => HugeGraphIntOutput.java} | 2 +- .../{LongHugeGraphOutput.java => HugeGraphLongOutput.java} | 2 +- .../hugegraph/computer/core/output/hg/HugeGraphOutput.java | 2 +- ...tringHugeGraphOutput.java => HugeGraphStringOutput.java} | 2 +- .../centrality/betweenness/BetweennessCentralityTest.java | 4 ++-- .../centrality/closeness/ClosenessCentralityTest.java | 6 +++--- .../algorithm/centrality/degree/DegreeCentralityTest.java | 4 ++-- .../community/trianglecount/TriangleCountTest.java | 6 +++--- 20 files changed, 36 insertions(+), 34 deletions(-) rename computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/{DoubleHugeGraphOutput.java => HugeGraphDoubleOutput.java} (94%) rename computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/{FloatHugeGraphOutput.java => HugeGraphFloatOutput.java} (94%) rename computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/{IdHugeGraphOutput.java => HugeGraphIdOutput.java} (95%) rename computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/{IntHugeGraphOutput.java => HugeGraphIntOutput.java} (94%) rename computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/{LongHugeGraphOutput.java => HugeGraphLongOutput.java} (94%) rename computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/{StringHugeGraphOutput.java => HugeGraphStringOutput.java} (94%) 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 index d3e4476ef..490bc9d04 100644 --- 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 @@ -26,7 +26,7 @@ import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; -import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.baidu.hugegraph.structure.constant.WriteType; public class BetweennessCentralityParams implements AlgorithmParams { @@ -42,7 +42,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS, BetweennessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - DoubleHugeGraphOutput.class.getName()); + HugeGraphDoubleOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, 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 index dc8887a75..43355c88d 100644 --- 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 @@ -25,7 +25,7 @@ import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; -import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.baidu.hugegraph.structure.constant.WriteType; public class ClosenessCentralityParams implements AlgorithmParams { @@ -41,7 +41,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS, ClosenessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - DoubleHugeGraphOutput.class.getName()); + HugeGraphDoubleOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, 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 index 21abcb150..09506aca5 100644 --- 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 @@ -26,7 +26,7 @@ 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; -import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.baidu.hugegraph.structure.constant.WriteType; public class DegreeCentralityParams implements AlgorithmParams { @@ -44,7 +44,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - DoubleHugeGraphOutput.class.getName()); + HugeGraphDoubleOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, WriteType.OLAP_RANGE.name()); } 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 index 131fa98f9..234187112 100644 --- 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 @@ -25,7 +25,7 @@ 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.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.baidu.hugegraph.structure.constant.WriteType; public class PageRankParams implements AlgorithmParams { @@ -43,7 +43,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - DoubleHugeGraphOutput.class.getName()); + HugeGraphDoubleOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, WriteType.OLAP_RANGE.name()); } 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 index 190532fd1..766736d18 100644 --- 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 @@ -25,7 +25,7 @@ import com.baidu.hugegraph.computer.core.combiner.ValueMinCombiner; import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.id.BytesId; -import com.baidu.hugegraph.computer.core.output.hg.IdHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphIdOutput; public class KcoreParams implements AlgorithmParams { @@ -40,6 +40,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, ValueMinCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - IdHugeGraphOutput.class.getName()); + HugeGraphIdOutput.class.getName()); } } 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 index 87dc7291b..12b3710f3 100644 --- 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 @@ -24,7 +24,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmParams; import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.id.BytesId; -import com.baidu.hugegraph.computer.core.output.hg.IdHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphIdOutput; public class LpaParams implements AlgorithmParams { @@ -37,6 +37,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_MESSAGE_CLASS, BytesId.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - IdHugeGraphOutput.class.getName()); + HugeGraphIdOutput.class.getName()); } } 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 index 9fb47a6dd..272ff5bd9 100644 --- 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 @@ -25,7 +25,7 @@ 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; -import com.baidu.hugegraph.computer.core.output.hg.IntHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphIntOutput; import com.baidu.hugegraph.structure.constant.WriteType; public class TriangleCountParams implements AlgorithmParams { @@ -39,7 +39,7 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.ALGORITHM_RESULT_CLASS, TriangleCountValue.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - IntHugeGraphOutput.class.getName()); + HugeGraphIntOutput.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.name(), 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 index e076928dd..bc1ca168a 100644 --- 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 @@ -25,7 +25,7 @@ import com.baidu.hugegraph.computer.core.combiner.ValueMinCombiner; import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.id.BytesId; -import com.baidu.hugegraph.computer.core.output.hg.IdHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphIdOutput; public class WccParams implements AlgorithmParams { @@ -40,6 +40,6 @@ public void setAlgorithmParameters(Map params) { this.setIfAbsent(params, ComputerOptions.WORKER_COMBINER_CLASS, ValueMinCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, - IdHugeGraphOutput.class.getName()); + HugeGraphIdOutput.class.getName()); } } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java index 176c959b3..20b929d49 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/config/ComputerOptions.java @@ -228,7 +228,9 @@ public static synchronized ComputerOptions instance() { public static final ConfigOption OUTPUT_RESULT_WRITE_TYPE = new ConfigOption<>( "output.result_write_type", - "The value is write-type of result output to hugegraph.", + "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" ); diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphDoubleOutput.java similarity index 94% rename from computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphDoubleOutput.java index 65cbaab3b..9337213de 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/DoubleHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphDoubleOutput.java @@ -19,7 +19,7 @@ package com.baidu.hugegraph.computer.core.output.hg; -public class DoubleHugeGraphOutput extends HugeGraphOutput { +public class HugeGraphDoubleOutput extends HugeGraphOutput { @Override protected void prepareSchema() { diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphFloatOutput.java similarity index 94% rename from computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphFloatOutput.java index ecd6899f6..eccf4eb38 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/FloatHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphFloatOutput.java @@ -19,7 +19,7 @@ package com.baidu.hugegraph.computer.core.output.hg; -public class FloatHugeGraphOutput extends HugeGraphOutput { +public class HugeGraphFloatOutput extends HugeGraphOutput { @Override protected void prepareSchema() { diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphIdOutput.java similarity index 95% rename from computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphIdOutput.java index 5efbe3662..82a48fbca 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IdHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphIdOutput.java @@ -21,7 +21,7 @@ import com.baidu.hugegraph.computer.core.graph.vertex.Vertex; -public class IdHugeGraphOutput extends HugeGraphOutput { +public class HugeGraphIdOutput extends HugeGraphOutput { @Override protected void prepareSchema() { diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphIntOutput.java similarity index 94% rename from computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphIntOutput.java index 50cc74610..6f24c20b1 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/IntHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphIntOutput.java @@ -19,7 +19,7 @@ package com.baidu.hugegraph.computer.core.output.hg; -public class IntHugeGraphOutput extends HugeGraphOutput { +public class HugeGraphIntOutput extends HugeGraphOutput { @Override protected void prepareSchema() { diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphLongOutput.java similarity index 94% rename from computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphLongOutput.java index 63da8e26c..1297cc10d 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/LongHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphLongOutput.java @@ -19,7 +19,7 @@ package com.baidu.hugegraph.computer.core.output.hg; -public class LongHugeGraphOutput extends HugeGraphOutput { +public class HugeGraphLongOutput extends HugeGraphOutput { @Override protected void prepareSchema() { diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java index f8448b494..fc829421a 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphOutput.java @@ -99,7 +99,7 @@ protected T value(Vertex vertex) { return value; } - public WriteType writeType() { + protected WriteType writeType() { return this.writeType; } diff --git a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphStringOutput.java similarity index 94% rename from computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java rename to computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphStringOutput.java index 92bc7c6fc..b372b599f 100644 --- a/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/StringHugeGraphOutput.java +++ b/computer-core/src/main/java/com/baidu/hugegraph/computer/core/output/hg/HugeGraphStringOutput.java @@ -19,7 +19,7 @@ package com.baidu.hugegraph.computer.core.output.hg; -public class StringHugeGraphOutput extends HugeGraphOutput { +public class HugeGraphStringOutput extends HugeGraphOutput { @Override protected void prepareSchema() { diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java index c792d7bdd..fc231b1af 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java @@ -27,7 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; -import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.HugeClient; import com.baidu.hugegraph.driver.SchemaManager; @@ -131,7 +131,7 @@ public void testRunAlgorithm() throws InterruptedException { } public static class BetweennessCentralityTestOutput - extends DoubleHugeGraphOutput { + extends HugeGraphDoubleOutput { @Override protected Double value( diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java index eb72cf988..1c135db24 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java @@ -27,7 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; -import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.HugeClient; import com.baidu.hugegraph.driver.SchemaManager; @@ -107,7 +107,7 @@ public void testWithWeightProperty() throws InterruptedException { } public static class ClosenessWithWeightPropertyTestOutput - extends DoubleHugeGraphOutput { + extends HugeGraphDoubleOutput { private final Map expectResults = ImmutableMap.builder() @@ -141,7 +141,7 @@ public void testWithoutWeightProperty() throws InterruptedException { } public static class ClosenessWithoutWeightPropertyTestOutput - extends DoubleHugeGraphOutput { + extends HugeGraphDoubleOutput { private final Map expectResults = ImmutableMap.builder() diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java index c86242475..171fa35ee 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/degree/DegreeCentralityTest.java @@ -32,7 +32,7 @@ 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.vertex.Vertex; -import com.baidu.hugegraph.computer.core.output.hg.DoubleHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; import com.google.common.collect.Streams; public class DegreeCentralityTest extends AlgorithmTestBase { @@ -59,7 +59,7 @@ public void setAlgorithmParameters(Map params) { } public static class DegreeCentralityTestOutput - extends DoubleHugeGraphOutput { + extends HugeGraphDoubleOutput { private String weight; private static boolean isRun; diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java index 7617da08d..25df59b30 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/community/trianglecount/TriangleCountTest.java @@ -27,7 +27,7 @@ import com.baidu.hugegraph.computer.algorithm.AlgorithmTestBase; import com.baidu.hugegraph.computer.core.config.ComputerOptions; -import com.baidu.hugegraph.computer.core.output.hg.IntHugeGraphOutput; +import com.baidu.hugegraph.computer.core.output.hg.HugeGraphIntOutput; import com.baidu.hugegraph.driver.GraphManager; import com.baidu.hugegraph.driver.SchemaManager; import com.baidu.hugegraph.structure.constant.T; @@ -99,7 +99,7 @@ public static void teardown() { public void testRunAlgorithm() throws InterruptedException { runAlgorithm(TriangleCountParams.class.getName(), ComputerOptions.OUTPUT_CLASS.name(), - TriangleCountOutputTest.class.getName()); + TriangleCountIntOutputTest.class.getName()); } @Test @@ -118,7 +118,7 @@ public void testTriangleCountValue() { Assert.assertContains("10", value.toString()); } - public static class TriangleCountOutputTest extends IntHugeGraphOutput { + public static class TriangleCountIntOutputTest extends HugeGraphIntOutput { @Override public Integer value( From 58946b49ca7c0529653ccec0f316012896c0e082 Mon Sep 17 00:00:00 2001 From: coderzc Date: Tue, 11 Jan 2022 16:57:20 +0800 Subject: [PATCH 6/7] improve code style --- .../algorithm/centrality/closeness/ClosenessCentralityTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java index 1c135db24..eaaec5ae6 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/closeness/ClosenessCentralityTest.java @@ -107,7 +107,7 @@ public void testWithWeightProperty() throws InterruptedException { } public static class ClosenessWithWeightPropertyTestOutput - extends HugeGraphDoubleOutput { + extends HugeGraphDoubleOutput { private final Map expectResults = ImmutableMap.builder() From 0f6665859c52b6702e10f51210301c8baf228fb1 Mon Sep 17 00:00:00 2001 From: coderzc Date: Thu, 13 Jan 2022 19:30:23 +0800 Subject: [PATCH 7/7] improve some comment --- .../centrality/betweenness/BetweennessCentralityParams.java | 3 --- .../centrality/closeness/ClosenessCentralityParams.java | 3 --- .../algorithm/centrality/degree/DegreeCentralityParams.java | 3 --- .../computer/algorithm/centrality/pagerank/PageRankParams.java | 3 --- .../algorithm/community/trianglecount/TriangleCountParams.java | 3 --- .../centrality/betweenness/BetweennessCentralityTest.java | 2 +- 6 files changed, 1 insertion(+), 16 deletions(-) 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 index 490bc9d04..f768b1b87 100644 --- 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 @@ -27,7 +27,6 @@ import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; -import com.baidu.hugegraph.structure.constant.WriteType; public class BetweennessCentralityParams implements AlgorithmParams { @@ -43,8 +42,6 @@ public void setAlgorithmParameters(Map params) { BetweennessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, HugeGraphDoubleOutput.class.getName()); - this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, - WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, ExtractAllPropertyInputFilter.class.getName()); this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE, 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 index 43355c88d..869ac4b75 100644 --- 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 @@ -26,7 +26,6 @@ import com.baidu.hugegraph.computer.core.input.filter.ExtractAllPropertyInputFilter; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; -import com.baidu.hugegraph.structure.constant.WriteType; public class ClosenessCentralityParams implements AlgorithmParams { @@ -42,8 +41,6 @@ public void setAlgorithmParameters(Map params) { ClosenessMessage.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, HugeGraphDoubleOutput.class.getName()); - this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, - WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_FILTER_CLASS, ExtractAllPropertyInputFilter.class.getName()); this.setIfAbsent(params, ClosenessCentrality.OPTION_SAMPLE_RATE, 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 index 09506aca5..0935f846b 100644 --- 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 @@ -27,7 +27,6 @@ import com.baidu.hugegraph.computer.core.graph.value.DoubleValue; import com.baidu.hugegraph.computer.core.master.DefaultMasterComputation; import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; -import com.baidu.hugegraph.structure.constant.WriteType; public class DegreeCentralityParams implements AlgorithmParams { @@ -45,7 +44,5 @@ public void setAlgorithmParameters(Map params) { DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, HugeGraphDoubleOutput.class.getName()); - this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, - WriteType.OLAP_RANGE.name()); } } 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 index 234187112..18c668ab2 100644 --- 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 @@ -26,7 +26,6 @@ import com.baidu.hugegraph.computer.core.config.ComputerOptions; import com.baidu.hugegraph.computer.core.graph.value.DoubleValue; import com.baidu.hugegraph.computer.core.output.hg.HugeGraphDoubleOutput; -import com.baidu.hugegraph.structure.constant.WriteType; public class PageRankParams implements AlgorithmParams { @@ -44,7 +43,5 @@ public void setAlgorithmParameters(Map params) { DoubleValueSumCombiner.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, HugeGraphDoubleOutput.class.getName()); - this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, - WriteType.OLAP_RANGE.name()); } } 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 index 272ff5bd9..8cdf5f3ea 100644 --- 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 @@ -26,7 +26,6 @@ import com.baidu.hugegraph.computer.core.config.EdgeFrequency; import com.baidu.hugegraph.computer.core.graph.value.IdList; import com.baidu.hugegraph.computer.core.output.hg.HugeGraphIntOutput; -import com.baidu.hugegraph.structure.constant.WriteType; public class TriangleCountParams implements AlgorithmParams { @@ -40,8 +39,6 @@ public void setAlgorithmParameters(Map params) { TriangleCountValue.class.getName()); this.setIfAbsent(params, ComputerOptions.OUTPUT_CLASS, HugeGraphIntOutput.class.getName()); - this.setIfAbsent(params, ComputerOptions.OUTPUT_RESULT_WRITE_TYPE, - WriteType.OLAP_RANGE.name()); this.setIfAbsent(params, ComputerOptions.INPUT_EDGE_FREQ.name(), EdgeFrequency.SINGLE.name()); } diff --git a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java index fc231b1af..535d213cd 100644 --- a/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java +++ b/computer-test/src/main/java/com/baidu/hugegraph/computer/algorithm/centrality/betweenness/BetweennessCentralityTest.java @@ -131,7 +131,7 @@ public void testRunAlgorithm() throws InterruptedException { } public static class BetweennessCentralityTestOutput - extends HugeGraphDoubleOutput { + extends HugeGraphDoubleOutput { @Override protected Double value(