From 763b5238accef422ede65eb9eee9986aa6f4a543 Mon Sep 17 00:00:00 2001 From: Thespica Date: Tue, 14 May 2024 16:31:20 +0800 Subject: [PATCH 1/2] Add basic architecture java-info into main --- maven-projects/java-info/.scalafmt.conf | 8 + maven-projects/java-info/README.md | 1 + maven-projects/java-info/pom.xml | 66 +++++++ .../apache/graphar/info/type/AdjListType.java | 50 ++++++ .../apache/graphar/info/type/DataType.java | 69 ++++++++ .../apache/graphar/info/type/FileType.java | 42 +++++ .../info/yaml/AdjacentListYamlParser.java | 75 ++++++++ .../graphar/info/yaml/EdgeYamlParser.java | 161 ++++++++++++++++++ .../graphar/info/yaml/GraphYamlParser.java | 109 ++++++++++++ .../info/yaml/PropertyGroupYamlParser.java | 70 ++++++++ .../graphar/info/yaml/PropertyYamlParser.java | 76 +++++++++ .../graphar/info/yaml/VertexYamlParser.java | 92 ++++++++++ .../apache/graphar/util/GeneralParams.java | 38 +++++ maven-projects/pom.xml | 1 + 14 files changed, 858 insertions(+) create mode 100644 maven-projects/java-info/.scalafmt.conf create mode 100644 maven-projects/java-info/README.md create mode 100644 maven-projects/java-info/pom.xml create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java create mode 100644 maven-projects/java-info/src/main/java/org/apache/graphar/util/GeneralParams.java diff --git a/maven-projects/java-info/.scalafmt.conf b/maven-projects/java-info/.scalafmt.conf new file mode 100644 index 000000000..a79ab2962 --- /dev/null +++ b/maven-projects/java-info/.scalafmt.conf @@ -0,0 +1,8 @@ +version = "3.0.6" + +align.preset = some +runner.dialect = scala212 +maxColumn = 80 +docstrings.style = Asterisk +docstrings.removeEmpty = true +project.git = true diff --git a/maven-projects/java-info/README.md b/maven-projects/java-info/README.md new file mode 100644 index 000000000..75aad176e --- /dev/null +++ b/maven-projects/java-info/README.md @@ -0,0 +1 @@ +This module is under development \ No newline at end of file diff --git a/maven-projects/java-info/pom.xml b/maven-projects/java-info/pom.xml new file mode 100644 index 000000000..fcf863df7 --- /dev/null +++ b/maven-projects/java-info/pom.xml @@ -0,0 +1,66 @@ + + + + + 4.0.0 + + + org.apache.graphar + graphar-root + ${graphar.version} + ../pom.xml + + + java-info + jar + + java-info + + + 11 + 11 + UTF-8 + + + + + junit + junit + 4.13.2 + test + + + org.yaml + snakeyaml + 2.0 + + + org.apache.hadoop + hadoop-common + 3.4.0 + + + + + \ No newline at end of file diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java new file mode 100644 index 000000000..a077d870f --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.type; + +public enum AdjListType { + /** collection of edges by source, but unordered, can represent COO format */ + unordered_by_source, + /** collection of edges by destination, but unordered, can represent COO */ + unordered_by_dest, + /** collection of edges by source, ordered by source, can represent CSR format */ + ordered_by_source, + /** collection of edges by destination, ordered by destination, can represent CSC format */ + ordered_by_dest; + + public static AdjListType fromOrderedAndAlignedBy(boolean ordered, String alignedBy) { + switch (alignedBy) { + case "src": + return ordered ? ordered_by_source : unordered_by_source; + case "dst": + return ordered ? ordered_by_dest : unordered_by_dest; + default: + throw new IllegalArgumentException("Invalid alignedBy: " + alignedBy); + } + } + + public boolean isOrdered() { + return this == ordered_by_source || this == ordered_by_dest; + } + + public String getAlignedBy() { + return this == ordered_by_source || this == unordered_by_source ? "src" : "dst"; + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java new file mode 100644 index 000000000..83c31aec1 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.type; + +public enum DataType { + /** Boolean */ + BOOL, + + /** Signed 32-bit integer */ + INT32, + + /** Signed 64-bit integer */ + INT64, + + /** 4-byte floating point value */ + FLOAT, + + /** 8-byte floating point value */ + DOUBLE, + + /** UTF8 variable-length string */ + STRING, + + /** List of same type */ + LIST; + + public static DataType fromString(String s) { + switch (s) { + case "bool": + return BOOL; + case "int32": + return INT32; + case "int64": + return INT64; + case "float": + return FLOAT; + case "double": + return DOUBLE; + case "string": + return STRING; + case "list": + return LIST; + default: + throw new IllegalArgumentException("Unknown data type: " + s); + } + } + + @Override + public String toString() { + return name().toLowerCase(); + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java new file mode 100644 index 000000000..b45038b84 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.type; + +public enum FileType { + CSV, + PARQUET, + ORC; + + public static FileType fromString(String fileType) { + if (fileType == null) { + return null; + } + switch (fileType) { + case "csv": + return CSV; + case "parquet": + return PARQUET; + case "orc": + return ORC; + default: + throw new IllegalArgumentException("Unknown file type: " + fileType); + } + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java new file mode 100644 index 000000000..a971c03f5 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.yaml; + +import org.apache.graphar.info.AdjacentList; + +public class AdjacentListYamlParser { + private boolean ordered; + private String aligned_by; + private String file_type; + private String prefix; + + public AdjacentListYamlParser() { + this.ordered = false; + this.aligned_by = ""; + this.file_type = ""; + this.prefix = ""; + } + + public AdjacentListYamlParser(AdjacentList adjacentList) { + this.ordered = adjacentList.getType().isOrdered(); + this.aligned_by = adjacentList.getType().getAlignedBy(); + this.file_type = adjacentList.getFileType().toString(); + this.prefix = adjacentList.getPrefix(); + } + + public boolean isOrdered() { + return ordered; + } + + public void setOrdered(boolean ordered) { + this.ordered = ordered; + } + + public String isAligned_by() { + return aligned_by; + } + + public void setAligned_by(String aligned_by) { + this.aligned_by = aligned_by; + } + + public String getFile_type() { + return file_type; + } + + public void setFile_type(String file_type) { + this.file_type = file_type; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java new file mode 100644 index 000000000..0d8813cf1 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.yaml; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.graphar.info.EdgeInfo; + +public class EdgeYamlParser { + private String src_label; + private String edge_label; + private String dst_label; + private long chunk_size; + private long src_chunk_size; + private long dst_chunk_size; + private boolean directed; + private String prefix; + private List adjacent_lists; + private List property_groups; + private String version; + + public EdgeYamlParser() { + this.src_label = ""; + this.edge_label = ""; + this.dst_label = ""; + this.chunk_size = 0; + this.src_chunk_size = 0; + this.dst_chunk_size = 0; + this.directed = false; + this.prefix = ""; + this.adjacent_lists = new ArrayList<>(); + this.property_groups = new ArrayList<>(); + this.version = ""; + } + + public EdgeYamlParser(EdgeInfo edgeInfo) { + this.src_label = edgeInfo.getSrcLabel(); + this.edge_label = edgeInfo.getEdgeLabel(); + this.dst_label = edgeInfo.getDstLabel(); + this.chunk_size = edgeInfo.getChunkSize(); + this.src_chunk_size = edgeInfo.getSrcChunkSize(); + this.dst_chunk_size = edgeInfo.getDstChunkSize(); + this.directed = edgeInfo.isDirected(); + this.prefix = edgeInfo.getPrefix(); + this.adjacent_lists = + edgeInfo.getAdjacentLists().values().stream() + .map(AdjacentListYamlParser::new) + .collect(Collectors.toList()); + this.property_groups = + edgeInfo.getPropertyGroups().stream() + .map(PropertyGroupYamlParser::new) + .collect(Collectors.toList()); + this.version = edgeInfo.getVersion(); + } + + public String getSrc_label() { + return src_label; + } + + public void setSrc_label(String src_label) { + this.src_label = src_label; + } + + public String getEdge_label() { + return edge_label; + } + + public void setEdge_label(String edge_label) { + this.edge_label = edge_label; + } + + public String getDst_label() { + return dst_label; + } + + public void setDst_label(String dst_label) { + this.dst_label = dst_label; + } + + public boolean isDirected() { + return directed; + } + + public void setDirected(boolean directed) { + this.directed = directed; + } + + public long getChunk_size() { + return chunk_size; + } + + public void setChunk_size(long chunk_size) { + this.chunk_size = chunk_size; + } + + public long getSrc_chunk_size() { + return src_chunk_size; + } + + public void setSrc_chunk_size(long src_chunk_size) { + this.src_chunk_size = src_chunk_size; + } + + public long getDst_chunk_size() { + return dst_chunk_size; + } + + public void setDst_chunk_size(long dst_chunk_size) { + this.dst_chunk_size = dst_chunk_size; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public List getAdjacent_lists() { + return adjacent_lists; + } + + public void setAdjacent_lists(List adjacent_lists) { + this.adjacent_lists = adjacent_lists; + } + + public List getProperty_groups() { + return property_groups; + } + + public void setProperty_groups(List property_groups) { + this.property_groups = property_groups; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java new file mode 100644 index 000000000..85fe69777 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.yaml; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.graphar.info.GraphInfo; +import org.yaml.snakeyaml.DumperOptions; + +public class GraphYamlParser { + private String name; + private String prefix; + private List vertices; + private List edges; + private String version; + private static final DumperOptions dumperOption; + + static { + dumperOption = new DumperOptions(); + dumperOption.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + dumperOption.setIndent(4); + dumperOption.setIndicatorIndent(2); + dumperOption.setPrettyFlow(true); + } + + public GraphYamlParser() { + this.name = ""; + this.prefix = ""; + this.vertices = new ArrayList<>(); + this.edges = new ArrayList<>(); + this.version = ""; + } + + public GraphYamlParser(GraphInfo graphInfo) { + this.name = graphInfo.getName(); + this.prefix = graphInfo.getPrefix(); + this.vertices = + graphInfo.getVertexInfos().stream() + .map(vertexInfo -> vertexInfo.getLabel() + ".vertex.yaml") + .collect(Collectors.toList()); + this.edges = + graphInfo.getEdgeInfos().stream() + .map(edgeInfo -> edgeInfo.getConcat() + ".edge.yaml") + .collect(Collectors.toList()); + this.version = graphInfo.getVersion(); + } + + public static DumperOptions getDumperOptions() { + return dumperOption; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public List getVertices() { + return vertices; + } + + public void setVertices(List vertices) { + this.vertices = vertices; + } + + public List getEdges() { + return edges; + } + + public void setEdges(List edges) { + this.edges = edges; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java new file mode 100644 index 000000000..43609df98 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.yaml; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.graphar.info.PropertyGroup; + +public class PropertyGroupYamlParser { + private List properties; + private String file_type; + private String prefix; + + public PropertyGroupYamlParser() { + this.properties = new ArrayList<>(); + this.file_type = ""; + this.prefix = ""; + } + + public PropertyGroupYamlParser(PropertyGroup propertyGroup) { + this.properties = + propertyGroup.getPropertyList().stream() + .map(PropertyYamlParser::new) + .collect(Collectors.toList()); + this.file_type = propertyGroup.getFileType().toString(); + this.prefix = propertyGroup.getPrefix(); + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public String getFile_type() { + return file_type; + } + + public void setFile_type(String file_type) { + this.file_type = file_type; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java new file mode 100644 index 000000000..c511ada10 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.yaml; + +import java.util.Optional; +import org.apache.graphar.info.Property; + +public class PropertyYamlParser { + private String name; + private String data_type; + private boolean is_primary; + private Optional is_nullable; + + public PropertyYamlParser() { + this.name = ""; + this.data_type = ""; + this.is_primary = false; + this.is_nullable = Optional.empty(); + } + + public PropertyYamlParser(Property property) { + this.name = property.getName(); + this.data_type = property.getDataType().toString(); + this.is_primary = property.isPrimary(); + this.is_nullable = Optional.of(property.isNullable()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getData_type() { + return data_type; + } + + public void setData_type(String data_type) { + this.data_type = data_type; + } + + public boolean getIs_primary() { + return is_primary; + } + + public void setIs_primary(boolean is_primary) { + this.is_primary = is_primary; + } + + public boolean getIs_nullable() { + return is_nullable.orElseGet(() -> !is_primary); + } + + public void setIs_nullable(boolean is_nullable) { + this.is_nullable = Optional.of(is_nullable); + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java new file mode 100644 index 000000000..01c098498 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.info.yaml; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import org.apache.graphar.info.VertexInfo; + +public class VertexYamlParser { + private String label; + private long chunk_size; + private List property_groups; + private String prefix; + private String version; + + public VertexYamlParser() { + this.label = ""; + this.chunk_size = 0; + this.property_groups = new ArrayList<>(); + this.prefix = ""; + this.version = ""; + } + + public VertexYamlParser(VertexInfo vertexInfo) { + this.label = vertexInfo.getLabel(); + this.chunk_size = vertexInfo.getChunkSize(); + this.property_groups = + vertexInfo.getPropertyGroups().stream() + .map(PropertyGroupYamlParser::new) + .collect(Collectors.toList()); + this.prefix = vertexInfo.getPrefix(); + this.version = vertexInfo.getVersion(); + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public long getChunk_size() { + return chunk_size; + } + + public void setChunk_size(long chunk_size) { + this.chunk_size = chunk_size; + } + + public List getProperty_groups() { + return property_groups; + } + + public void setProperty_groups(List property_groups) { + this.property_groups = property_groups; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/util/GeneralParams.java b/maven-projects/java-info/src/main/java/org/apache/graphar/util/GeneralParams.java new file mode 100644 index 000000000..a384e0df8 --- /dev/null +++ b/maven-projects/java-info/src/main/java/org/apache/graphar/util/GeneralParams.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.graphar.util; + +public class GeneralParams { + // column name + public static final String vertexIndexCol = "_graphArVertexIndex"; + public static final String srcIndexCol = "_graphArSrcIndex"; + public static final String dstIndexCol = "_graphArDstIndex"; + public static final String offsetCol = "_graphArOffset"; + public static final String primaryCol = "_graphArPrimary"; + public static final String vertexChunkIndexCol = "_graphArVertexChunkIndex"; + public static final String edgeIndexCol = "_graphArEdgeIndex"; + public static final String regularSeparator = "_"; + public static final String offsetStartChunkIndexKey = "_graphar_offset_start_chunk_index"; + public static final String aggNumListOfEdgeChunkKey = "_graphar_agg_num_list_of_edge_chunk"; + public static final Long defaultVertexChunkSize = 262144L; // 2^18 + public static final Long defaultEdgeChunkSize = 4194304L; // 2^22 + public static final String defaultFileType = "parquet"; + public static final String defaultVersion = "v1"; +} diff --git a/maven-projects/pom.xml b/maven-projects/pom.xml index 03f3a28c5..c7ef0a8b6 100644 --- a/maven-projects/pom.xml +++ b/maven-projects/pom.xml @@ -32,6 +32,7 @@ java spark + java-info From 44d5a69d8a4563d9a95deade582c276ba968efd5 Mon Sep 17 00:00:00 2001 From: Thespica Date: Tue, 14 May 2024 22:39:52 +0800 Subject: [PATCH 2/2] Rename java-info to info --- maven-projects/{java-info => info}/.scalafmt.conf | 0 maven-projects/{java-info => info}/README.md | 0 maven-projects/{java-info => info}/pom.xml | 4 ++-- .../main/java/org/apache/graphar/info/type/AdjListType.java | 0 .../src/main/java/org/apache/graphar/info/type/DataType.java | 0 .../src/main/java/org/apache/graphar/info/type/FileType.java | 0 .../org/apache/graphar/info/yaml/AdjacentListYamlParser.java | 0 .../java/org/apache/graphar/info/yaml/EdgeYamlParser.java | 0 .../java/org/apache/graphar/info/yaml/GraphYamlParser.java | 0 .../org/apache/graphar/info/yaml/PropertyGroupYamlParser.java | 0 .../java/org/apache/graphar/info/yaml/PropertyYamlParser.java | 0 .../java/org/apache/graphar/info/yaml/VertexYamlParser.java | 0 .../src/main/java/org/apache/graphar/util/GeneralParams.java | 0 maven-projects/pom.xml | 2 +- 14 files changed, 3 insertions(+), 3 deletions(-) rename maven-projects/{java-info => info}/.scalafmt.conf (100%) rename maven-projects/{java-info => info}/README.md (100%) rename maven-projects/{java-info => info}/pom.xml (97%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/type/AdjListType.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/type/DataType.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/type/FileType.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java (100%) rename maven-projects/{java-info => info}/src/main/java/org/apache/graphar/util/GeneralParams.java (100%) diff --git a/maven-projects/java-info/.scalafmt.conf b/maven-projects/info/.scalafmt.conf similarity index 100% rename from maven-projects/java-info/.scalafmt.conf rename to maven-projects/info/.scalafmt.conf diff --git a/maven-projects/java-info/README.md b/maven-projects/info/README.md similarity index 100% rename from maven-projects/java-info/README.md rename to maven-projects/info/README.md diff --git a/maven-projects/java-info/pom.xml b/maven-projects/info/pom.xml similarity index 97% rename from maven-projects/java-info/pom.xml rename to maven-projects/info/pom.xml index fcf863df7..79d4119e3 100644 --- a/maven-projects/java-info/pom.xml +++ b/maven-projects/info/pom.xml @@ -32,10 +32,10 @@ ../pom.xml - java-info + info jar - java-info + info 11 diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java b/maven-projects/info/src/main/java/org/apache/graphar/info/type/AdjListType.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/type/AdjListType.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/type/AdjListType.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java b/maven-projects/info/src/main/java/org/apache/graphar/info/type/DataType.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/type/DataType.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/type/DataType.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java b/maven-projects/info/src/main/java/org/apache/graphar/info/type/FileType.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/type/FileType.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/type/FileType.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java b/maven-projects/info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/yaml/AdjacentListYamlParser.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java b/maven-projects/info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/yaml/EdgeYamlParser.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java b/maven-projects/info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/yaml/GraphYamlParser.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java b/maven-projects/info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/yaml/PropertyGroupYamlParser.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java b/maven-projects/info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/yaml/PropertyYamlParser.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java b/maven-projects/info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java rename to maven-projects/info/src/main/java/org/apache/graphar/info/yaml/VertexYamlParser.java diff --git a/maven-projects/java-info/src/main/java/org/apache/graphar/util/GeneralParams.java b/maven-projects/info/src/main/java/org/apache/graphar/util/GeneralParams.java similarity index 100% rename from maven-projects/java-info/src/main/java/org/apache/graphar/util/GeneralParams.java rename to maven-projects/info/src/main/java/org/apache/graphar/util/GeneralParams.java diff --git a/maven-projects/pom.xml b/maven-projects/pom.xml index c7ef0a8b6..c7763967a 100644 --- a/maven-projects/pom.xml +++ b/maven-projects/pom.xml @@ -32,7 +32,7 @@ java spark - java-info + info