- Notifications
You must be signed in to change notification settings - Fork 44
add DefaultPropertiesCombiner and DefaultVertexValueCombiner #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits Select commit Hold shift + click to select a range
99d0197
add DefaultPropertiesCombiner and DefaultVertexValueCombiner
houzhizhen 1553768
add OverwriteValueCombiner, MergeNewPropertiesCombiner and MergeOldPr…
houzhizhen 2a76289
remove DefaultPropertiesCombiner
houzhizhen 24ade14
improve test case
houzhizhen aa2d853
add null check and test case
houzhizhen 486dc9b
add combine in message
houzhizhen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions 30 ...e/src/main/java/com/baidu/hugegraph/computer/core/combiner/DefaultPropertiesCombiner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
| ||
package com.baidu.hugegraph.computer.core.combiner; | ||
| ||
import com.baidu.hugegraph.computer.core.graph.properties.Properties; | ||
| ||
public class DefaultPropertiesCombiner implements PropertiesCombiner { | ||
| ||
@Override | ||
public Properties combine(Properties v1, Properties v2) { | ||
return v2; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions 38 .../src/main/java/com/baidu/hugegraph/computer/core/combiner/DefaultVertexValueCombiner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
| ||
package com.baidu.hugegraph.computer.core.combiner; | ||
| ||
import com.baidu.hugegraph.computer.core.graph.value.Value; | ||
| ||
/** | ||
* When vertex values with the same vertex id are loaded, this class | ||
* specifies how to combine their values. | ||
*/ | ||
public class DefaultVertexValueCombiner<T extends Value> | ||
implements VertexValueCombiner<T> { | ||
| ||
/** | ||
* Just return the second value. | ||
*/ | ||
@Override | ||
public T combine(T v1, T v2) { | ||
return v2; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions 29 ...ter-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/PropertiesCombiner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
| ||
package com.baidu.hugegraph.computer.core.combiner; | ||
| ||
import com.baidu.hugegraph.computer.core.graph.properties.Properties; | ||
| ||
/** | ||
* When vertex properties with the same vertex id are loaded, this class | ||
* specifies how to combine their properties. | ||
*/ | ||
public interface PropertiesCombiner extends Combiner<Properties> { | ||
} |
25 changes: 25 additions & 0 deletions 25 ...er-core/src/main/java/com/baidu/hugegraph/computer/core/combiner/VertexValueCombiner.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
| ||
package com.baidu.hugegraph.computer.core.combiner; | ||
| ||
import com.baidu.hugegraph.computer.core.graph.value.Value; | ||
| ||
public interface VertexValueCombiner<T extends Value> extends Combiner<T> { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -24,6 +24,8 @@ | |
| ||
@RunWith(Suite.class) | ||
@Suite.SuiteClasses({ | ||
DefaultPropertiesCombinerTest.class, | ||
DefaultVertexValueCombinerTest.class, | ||
| ||
DoubleValueSumCombinerTest.class, | ||
LongValueSumCombinerTest.class, | ||
ValueMinCombinerTest.class, | ||
|
44 changes: 44 additions & 0 deletions 44 ...c/main/java/com/baidu/hugegraph/computer/core/combiner/DefaultPropertiesCombinerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
| ||
package com.baidu.hugegraph.computer.core.combiner; | ||
| ||
import org.junit.Test; | ||
| ||
import com.baidu.hugegraph.computer.core.graph.id.Utf8Id; | ||
import com.baidu.hugegraph.computer.core.graph.properties.DefaultProperties; | ||
import com.baidu.hugegraph.computer.core.graph.properties.Properties; | ||
import com.baidu.hugegraph.testutil.Assert; | ||
| ||
public class DefaultPropertiesCombinerTest { | ||
| ||
@Test | ||
public void test() { | ||
Properties properties1 = new DefaultProperties(); | ||
| ||
properties1.put("name", new Utf8Id("marko").idValue()); | ||
properties1.put("city", new Utf8Id("Beijing").idValue()); | ||
| ||
Properties properties2 = new DefaultProperties(); | ||
properties1.put("name", new Utf8Id("josh").idValue()); | ||
| ||
PropertiesCombiner combiner = new DefaultPropertiesCombiner(); | ||
Properties properties = combiner.combine(properties1, properties2); | ||
Assert.assertEquals(properties2, properties); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions 39 .../main/java/com/baidu/hugegraph/computer/core/combiner/DefaultVertexValueCombinerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
| ||
package com.baidu.hugegraph.computer.core.combiner; | ||
| ||
| ||
import org.junit.Test; | ||
| ||
import com.baidu.hugegraph.computer.core.graph.value.LongValue; | ||
import com.baidu.hugegraph.computer.core.graph.value.Value; | ||
import com.baidu.hugegraph.testutil.Assert; | ||
| ||
public class DefaultVertexValueCombinerTest { | ||
| ||
@Test | ||
public void test() { | ||
LongValue value1 = new LongValue(1L); | ||
LongValue value2 = new LongValue(2L); | ||
DefaultVertexValueCombiner combiner = new DefaultVertexValueCombiner(); | ||
Value value = combiner.combine(value1, value2); | ||
Assert.assertEquals(value2, value); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align with 'class' keyword