This is an automated email from the ASF dual-hosted git repository.
weibin pushed a commit to branch format-definition-dev
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git
The following commit(s) were added to refs/heads/format-definition-dev by this
push:
new cbc7a6c4 feat(format): Add format protocol definitions files with
google protocol buffers (#516)
cbc7a6c4 is described below
commit cbc7a6c4603db0e94fe3e31a7ce893fdc594954b
Author: Weibin Zeng <[email protected]>
AuthorDate: Thu Jun 6 19:02:44 2024 +0800
feat(format): Add format protocol definitions files with google protocol
buffers (#516)
* Initialize the format
Signed-off-by: acezen <[email protected]>
* Fix license error
---------
Signed-off-by: acezen <[email protected]>
---
format/adjacent_list.proto | 38 ++++++++++++++++++++++++++++++
format/edge_info.proto | 46 ++++++++++++++++++++++++++++++++++++
format/graph_info.proto | 45 +++++++++++++++++++++++++++++++++++
format/property_group.proto | 39 +++++++++++++++++++++++++++++++
format/test_vertex_info.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++
format/types.proto | 52 +++++++++++++++++++++++++++++++++++++++++
format/vertex_info.proto | 38 ++++++++++++++++++++++++++++++
7 files changed, 315 insertions(+)
diff --git a/format/adjacent_list.proto b/format/adjacent_list.proto
new file mode 100644
index 00000000..705de694
--- /dev/null
+++ b/format/adjacent_list.proto
@@ -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.
+ */
+
+syntax = "proto3";
+
+package graphar;
+option java_package = "org.apache.graphar.info";
+
+import "types.proto";
+
+message AdjacentList {
+ AdjListType type = 1;
+ FileType file_type = 2;
+ string prefix = 3;
+
+ message Statistics {
+ int64 num_vertices = 1;
+ int64 num_vertex_chunks = 2;
+ repeated int64 edge_nums_of_vertex_chunks = 3;
+ }
+ optional Statistics statistics = 4;
+};
diff --git a/format/edge_info.proto b/format/edge_info.proto
new file mode 100644
index 00000000..8385f4ae
--- /dev/null
+++ b/format/edge_info.proto
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+package graphar;
+option java_package = "org.apache.graphar.info";
+
+import "property_group.proto";
+import "adjacent_list.proto";
+
+message EdgeInfo {
+ string type = 1;
+ string source_vertex_type = 2;
+ string destination_vertex_type = 3;
+ int64 chunk_size = 4;
+ int64 source_vertex_chunk_size = 5;
+ int64 destination_vertex_chunk_size = 6;
+ repeated AdjacentList adjacent_list = 7;
+ repeated PropertyGroup properties = 8;
+ bool is_directed = 9;
+ string prefix = 10;
+
+ message Statistics {
+ int64 num_edges = 1;
+ int64 num_source_vertices = 2;
+ int64 num_destination_vertices = 3;
+ }
+ optional Statistics statistics = 11;
+};
diff --git a/format/graph_info.proto b/format/graph_info.proto
new file mode 100644
index 00000000..6490c570
--- /dev/null
+++ b/format/graph_info.proto
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+package graphar;
+option java_package = "org.apache.graphar.info";
+
+import "vertex_info.proto";
+import "edge_info.proto";
+
+message GraphInfo {
+ string name = 1;
+ repeated VertexInfo vertices = 2;
+ repeated EdgeInfo edges = 3;
+ string prefix = 4;
+
+ message Statistics {
+ int64 num_vertices = 1;
+ int64 num_edges = 2;
+ }
+ optional Statistics statistics = 5;
+
+ message KeyValue {
+ string key = 1;
+ string value = 2;
+ }
+ map<string, string> metadata = 6;
+};
diff --git a/format/property_group.proto b/format/property_group.proto
new file mode 100644
index 00000000..95b8c522
--- /dev/null
+++ b/format/property_group.proto
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+package graphar;
+option java_package = "org.apache.graphar.info";
+
+import "types.proto";
+
+message Property {
+ string name = 1;
+ DataType type = 2;
+ bool is_primary_key = 3;
+ bool nullable = 4;
+ string prefix = 5;
+};
+
+message PropertyGroup {
+ repeated Property properties = 1;
+ FileType file_type = 2;
+ string prefix = 3;
+};
diff --git a/format/test_vertex_info.cc b/format/test_vertex_info.cc
new file mode 100644
index 00000000..df477143
--- /dev/null
+++ b/format/test_vertex_info.cc
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+#include <google/protobuf/util/json_util.h>
+#include <iostream>
+#include "vertex_info.pb.h"
+
+using google::protobuf::util::JsonStringToMessage;
+
+bool proto_to_json(const google::protobuf::Message& message, std::string&
json) {
+ google::protobuf::util::JsonPrintOptions options;
+ options.add_whitespace = true;
+ options.always_print_primitive_fields = true;
+ options.preserve_proto_field_names = true;
+ return MessageToJsonString(message, &json, options).ok();
+}
+
+bool json_to_proto(const std::string& json, google::protobuf::Message&
message) {
+ return JsonStringToMessage(json, &message).ok();
+}
+
+int main() {
+ graphar::VertexInfo vertex;
+ vertex.set_type("person");
+ vertex.set_chunk_size(100);
+ vertex.set_prefix("./person");
+
+ std::string json_string;
+ /* protobuf to json。 */
+ if (!proto_to_json(vertex, json_string)) {
+ std::cout << "protobuf convert json failed!" << std::endl;
+ return 1;
+ }
+ std::cout << "protobuf convert json done!" << std::endl
+ << json_string << std::endl;
+
+ vertex.Clear();
+ std::cout << "-----" << std::endl;
+
+ return 0;
+}
\ No newline at end of file
diff --git a/format/types.proto b/format/types.proto
new file mode 100644
index 00000000..fc152b41
--- /dev/null
+++ b/format/types.proto
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+package graphar;
+option java_package = "org.apache.graphar.info";
+
+enum DataType {
+ BOOL = 0;
+ INT32 = 1;
+ INT64 = 2;
+ FLOAT = 3;
+ DOUBLE = 4;
+ STRING = 5;
+ LIST = 6;
+ DATE = 7;
+ TIMESTAMP = 8;
+ TIME = 9;
+};
+
+enum FileType {
+ CSV = 0;
+ PARQUET = 1;
+ ORC = 2;
+ JSON = 3;
+ AVRO = 4;
+ HDF5 = 5;
+};
+
+enum AdjListType {
+ UNORDERED_BY_SOURCE = 0;
+ UNORDERED_BY_TARGET = 1;
+ ORDERED_BY_SOURCE = 2;
+ ORDERED_BY_TARGET = 3;
+};
diff --git a/format/vertex_info.proto b/format/vertex_info.proto
new file mode 100644
index 00000000..da158674
--- /dev/null
+++ b/format/vertex_info.proto
@@ -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.
+ */
+
+syntax = "proto3";
+
+package graphar;
+option java_package = "org.apache.graphar.info";
+
+import "property_group.proto";
+
+message VertexInfo {
+ string type = 1;
+ int64 chunk_size = 2;
+ repeated PropertyGroup properties = 3;
+ string prefix = 4;
+
+ message Statistics {
+ int64 num_vertices = 5;
+ int64 num_chunks = 6;
+ }
+ optional Statistics statistics = 7;
+};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]