/* * Copyright (c) 2020 TigerGraph, Inc. * * Licensed 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. */ DROP ALL CREATE VERTEX Comment (PRIMARY_ID id UINT, creation_date DATETIME, location_ip STRING, browser_used STRING, content STRING, length UINT) WITH primary_id_as_attribute="TRUE" CREATE VERTEX Post (PRIMARY_ID id UINT, image_file STRING, creation_date DATETIME, location_ip STRING, browser_used STRING, lang STRING, content STRING, length UINT) WITH primary_id_as_attribute="TRUE" // organization CREATE VERTEX Company (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" CREATE VERTEX University (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" // place CREATE VERTEX City (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" CREATE VERTEX Country (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" CREATE VERTEX Continent (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" // etc CREATE VERTEX Forum (PRIMARY_ID id UINT, title STRING, creation_date DATETIME) WITH primary_id_as_attribute="TRUE" CREATE VERTEX Person (PRIMARY_ID id UINT, first_name STRING, last_name STRING, gender STRING, birthday DATETIME, creation_date DATETIME, location_ip STRING, browser_used STRING, speaks set, email set) WITH primary_id_as_attribute="TRUE" CREATE VERTEX Tag (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" CREATE VERTEX Tag_Class (PRIMARY_ID id UINT, name STRING, url STRING) WITH primary_id_as_attribute="TRUE" // create edge types CREATE DIRECTED EDGE Container_Of (FROM Forum, TO Post) WITH REVERSE_EDGE="Container_Of_Reverse" CREATE DIRECTED EDGE Has_Creator (FROM Comment|Post, TO Person) WITH REVERSE_EDGE="Has_Creator_Reverse" CREATE DIRECTED EDGE Has_Interest (FROM Person, TO Tag) WITH REVERSE_EDGE="Has_Interest_Reverse" CREATE DIRECTED EDGE Has_Member (FROM Forum, TO Person, join_date DATETIME) WITH REVERSE_EDGE="Has_Member_Reverse" CREATE DIRECTED EDGE Has_Moderator (FROM Forum, TO Person) WITH REVERSE_EDGE="Has_Moderator_Reverse" CREATE DIRECTED EDGE Has_Tag (FROM Comment|Post|Forum, TO Tag) WITH REVERSE_EDGE="Has_Tag_Reverse" CREATE DIRECTED EDGE Has_Type (FROM Tag, TO Tag_Class) WITH REVERSE_EDGE="Has_Type_Reverse" CREATE DIRECTED EDGE Is_Located_In (FROM Comment, TO Country | FROM Post, TO Country | FROM Company, TO Country | FROM Person, TO City | FROM University, TO City) WITH REVERSE_EDGE="Is_Located_In_Reverse" CREATE DIRECTED EDGE Is_Part_Of (FROM City, TO Country | FROM Country, TO Continent) WITH REVERSE_EDGE="Is_Part_Of_Reverse" CREATE DIRECTED EDGE Is_Subclass_Of (FROM Tag_Class, TO Tag_Class) WITH REVERSE_EDGE="Is_Subclass_Of_Reverse" CREATE UNDIRECTED EDGE Knows (FROM Person, TO Person, creation_date DATETIME) CREATE DIRECTED EDGE Likes (FROM Person, TO Comment|Post, creation_date DATETIME) WITH REVERSE_EDGE="Likes_Reverse" CREATE DIRECTED EDGE Reply_Of (FROM Comment, TO Comment|Post) WITH REVERSE_EDGE="Reply_Of_Reverse" CREATE DIRECTED EDGE Study_At (FROM Person, TO University, class_year INT) WITH REVERSE_EDGE="Study_At_Reverse" CREATE DIRECTED EDGE Work_At (FROM Person, TO Company, work_from INT) WITH REVERSE_EDGE="Work_At_Reverse" //create graph type CREATE GRAPH ldbc_snb (*) USE GRAPH ldbc_snb CREATE LOADING JOB load_ldbc_snb FOR GRAPH ldbc_snb { // define vertex DEFINE FILENAME v_comment_file; DEFINE FILENAME v_post_file; DEFINE FILENAME v_organisation_file; DEFINE FILENAME v_place_file; DEFINE FILENAME v_forum_file; DEFINE FILENAME v_person_file; DEFINE FILENAME v_tag_file; DEFINE FILENAME v_tagclass_file; // define edge DEFINE FILENAME forum_container_of_post_file; DEFINE FILENAME comment_has_creator_person_file; DEFINE FILENAME post_has_creator_person_file; DEFINE FILENAME person_has_interest_tag_file; DEFINE FILENAME forum_has_member_person_file; DEFINE FILENAME forum_has_moderator_person_file; DEFINE FILENAME comment_has_tag_tag_file; DEFINE FILENAME post_has_tag_tag_file; DEFINE FILENAME forum_has_tag_tag_file; DEFINE FILENAME tag_has_type_tagclass_file; DEFINE FILENAME organisation_is_located_in_place_file; DEFINE FILENAME comment_is_located_in_place_file; DEFINE FILENAME post_is_located_in_place_file; DEFINE FILENAME person_is_located_in_place_file; DEFINE FILENAME place_is_part_of_place_file; DEFINE FILENAME tagclass_is_subclass_of_tagclass_file; DEFINE FILENAME person_knows_person_file; DEFINE FILENAME person_likes_comment_file; DEFINE FILENAME person_likes_post_file; DEFINE FILENAME comment_reply_of_comment_file; DEFINE FILENAME comment_reply_of_post_file; DEFINE FILENAME person_study_at_organisation_file; DEFINE FILENAME person_work_at_organisation_file; // load vertex LOAD v_comment_file TO VERTEX Comment VALUES ($0, $1, $2, $3, $4, $5) USING header="true", separator="|"; LOAD v_post_file TO VERTEX Post VALUES ($0, $1, $2, $3, $4, $5, $6, $7) USING header="true", separator="|"; LOAD v_organisation_file TO VERTEX Company VALUES ($0, $2, $3) WHERE $1=="company", TO VERTEX University VALUES ($0, $2, $3) WHERE $1=="university" USING header="true", separator="|"; LOAD v_place_file TO VERTEX City VALUES ($0, $1, $2) WHERE $3=="city", TO VERTEX Country VALUES ($0, $1, $2) WHERE $3=="country", TO VERTEX Continent VALUES ($0, $1, $2) WHERE $3=="continent" USING header="true", separator="|"; LOAD v_forum_file TO VERTEX Forum VALUES ($0, $1, $2) USING header="true", separator="|"; LOAD v_person_file TO VERTEX Person VALUES ($0, $1, $2, $3, $4, $5, $6, $7, SPLIT($8,";"), SPLIT($9,";")) USING header="true", separator="|"; LOAD v_tag_file TO VERTEX Tag VALUES ($0, $1, $2) USING header="true", separator="|"; LOAD v_tagclass_file TO VERTEX Tag_Class VALUES ($0, $1, $2) USING header="true", separator="|"; // load edge LOAD forum_container_of_post_file TO EDGE Container_Of VALUES ($0, $1) USING header="true", separator="|"; LOAD comment_has_creator_person_file TO EDGE Has_Creator VALUES ($0 Comment, $1) USING header="true", separator="|"; LOAD post_has_creator_person_file TO EDGE Has_Creator VALUES ($0 Post, $1) USING header="true", separator="|"; LOAD person_has_interest_tag_file TO EDGE Has_Interest VALUES ($0, $1) USING header="true", separator="|"; LOAD forum_has_member_person_file TO EDGE Has_Member VALUES ($0, $1, $2) USING header="true", separator="|"; LOAD forum_has_moderator_person_file TO EDGE Has_Moderator VALUES ($0, $1) USING header="true", separator="|"; LOAD comment_has_tag_tag_file TO EDGE Has_Tag VALUES ($0 Comment, $1) USING header="true", separator="|"; LOAD post_has_tag_tag_file TO EDGE Has_Tag VALUES ($0 Post, $1) USING header="true", separator="|"; LOAD forum_has_tag_tag_file TO EDGE Has_Tag VALUES ($0 Forum, $1) USING header="true", separator="|"; LOAD tag_has_type_tagclass_file TO EDGE Has_Type VALUES ($0, $1) USING header="true", separator="|"; LOAD organisation_is_located_in_place_file TO EDGE Is_Located_In VALUES ($0 Company, $1 Country) WHERE to_int($1) < 111, TO EDGE Is_Located_In VALUES ($0 University, $1 City) WHERE to_int($1) > 110 USING header="true", separator="|"; LOAD comment_is_located_in_place_file TO EDGE Is_Located_In VALUES ($0 Comment, $1 Country) USING header="true", separator="|"; LOAD post_is_located_in_place_file TO EDGE Is_Located_In VALUES ($0 Post, $1 Country) USING header="true", separator="|"; LOAD person_is_located_in_place_file TO EDGE Is_Located_In VALUES ($0 Person, $1 City) USING header="true", separator="|"; LOAD place_is_part_of_place_file TO EDGE Is_Part_Of VALUES ($0 Country, $1 Continent) WHERE to_int($0) < 111, TO EDGE Is_Part_Of VALUES ($0 City, $1 Country) WHERE to_int($0) > 110 USING header="true", separator="|"; LOAD tagclass_is_subclass_of_tagclass_file TO EDGE Is_Subclass_Of VALUES ($0, $1) USING header="true", separator="|"; LOAD person_knows_person_file TO EDGE Knows VALUES ($0, $1, $2) USING header="true", separator="|"; LOAD person_likes_comment_file TO EDGE Likes VALUES ($0, $1 Comment, $2) USING header="true", separator="|"; LOAD person_likes_post_file TO EDGE Likes VALUES ($0, $1 Post, $2) USING header="true", separator="|"; LOAD comment_reply_of_comment_file TO EDGE Reply_Of VALUES ($0, $1 Comment) USING header="true", separator="|"; LOAD comment_reply_of_post_file TO EDGE Reply_Of VALUES ($0, $1 Post) USING header="true", separator="|"; LOAD person_study_at_organisation_file TO EDGE Study_At VALUES ($0, $1, $2) USING header="true", separator="|"; LOAD person_work_at_organisation_file TO EDGE Work_At VALUES ($0, $1, $2) USING header="true", separator="|"; }