yangxk1 commented on code in PR #743:
URL: https://github.com/apache/incubator-graphar/pull/743#discussion_r2320651660
##########
maven-projects/info/src/main/java/org/apache/graphar/info/EdgeInfo.java:
##########
@@ -51,6 +51,103 @@ public class EdgeInfo {
private final PropertyGroups propertyGroups;
private final VersionInfo version;
+ public static final class EdgeInfoBuilder {
+ private EdgeTriplet edgeTriplet;
+ private long chunkSize;
+ private long srcChunkSize;
+ private long dstChunkSize;
+ private boolean directed;
+ private String prefix;
+ private Map<AdjListType, AdjacentList> adjacentLists;
+ private PropertyGroups propertyGroups;
+ private VersionInfo version;
+
+ public EdgeInfoBuilder edgeTriplet(String srcType, String edgeType,
String dstType) {
+ this.edgeTriplet = new EdgeTriplet(srcType, edgeType, dstType);
+ return this;
+ }
+
+ private EdgeInfoBuilder edgeTriplet(EdgeTriplet edgeTriplet) {
+ this.edgeTriplet = edgeTriplet;
+ return this;
+ }
+
+ public EdgeInfoBuilder chunkSize(long chunkSize) {
+ this.chunkSize = chunkSize;
+ return this;
+ }
+
+ public EdgeInfoBuilder srcChunkSize(long srcChunkSize) {
+ this.srcChunkSize = srcChunkSize;
+ return this;
+ }
+
+ public EdgeInfoBuilder dstChunkSize(long dstChunkSize) {
+ this.dstChunkSize = dstChunkSize;
+ return this;
+ }
+
+ public EdgeInfoBuilder directed(boolean directed) {
+ this.directed = directed;
+ return this;
+ }
+
+ public EdgeInfoBuilder prefix(String prefix) {
+ this.prefix = prefix;
+ return this;
+ }
+
+ public EdgeInfoBuilder adjacentLists(List<AdjacentList>
adjacentListsAsList) {
+ this.adjacentLists =
+ adjacentListsAsList.stream()
+ .collect(
+ Collectors.toUnmodifiableMap(
+ AdjacentList::getType,
Function.identity()));
+ return this;
+ }
+
+ private EdgeInfoBuilder adjecentLists(Map<AdjListType, AdjacentList>
adjacentLists) {
Review Comment:
adjecentLists -> adjacentLists?
Can you add some `addXxx` method to List type fileds? e.g.,
`addAdjacentList()`,`addPropertyGroup()`
##########
maven-projects/info/src/main/java/org/apache/graphar/info/EdgeInfo.java:
##########
@@ -51,6 +51,103 @@ public class EdgeInfo {
private final PropertyGroups propertyGroups;
private final VersionInfo version;
+ public static final class EdgeInfoBuilder {
+ private EdgeTriplet edgeTriplet;
+ private long chunkSize;
+ private long srcChunkSize;
+ private long dstChunkSize;
+ private boolean directed;
+ private String prefix;
+ private Map<AdjListType, AdjacentList> adjacentLists;
+ private PropertyGroups propertyGroups;
+ private VersionInfo version;
+
+ public EdgeInfoBuilder edgeTriplet(String srcType, String edgeType,
String dstType) {
Review Comment:
Can we add method sourceType(String srcType), edgeType(String edgeType),
destinationType(String dstType)?
I am not sure, @Thespica
##########
maven-projects/info/src/test/java/org/apache/graphar/info/TestUtil.java:
##########
@@ -111,19 +111,19 @@ public static GraphInfo getLdbcSampleDataSet() {
new AdjacentList(AdjListType.ordered_by_dest, FileType.CSV,
"ordered_by_dest/");
Property creationDate = new Property("creationDate", DataType.STRING,
false, false);
PropertyGroup pg3 = new PropertyGroup(List.of(creationDate),
FileType.CSV, "creationDate/");
+
EdgeInfo knows =
- new EdgeInfo(
- "person",
- "knows",
- "person",
- 1024,
- 100,
- 100,
- false,
- "edge/person_knows_person/",
- "gar/v1",
- List.of(orderedBySource, orderedByDest),
- List.of(pg3));
+ new EdgeInfo.EdgeInfoBuilder()
Review Comment:
Add a parameterless constructor to `EdgeInfoBuilder` and add a static method
`static EdgeInfoBuilder builder()` to EdgeInfo.
Than it can be changed to
```
EdgeInfo knows = EdgeInfo.builder().edgeTriplet()...build()
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]