Files
secondo/Algebras/PropertyGraph2/sample-pregel/sample-shakespeare/readme.pd
2026-01-23 17:03:45 +08:00

171 lines
4.7 KiB
Plaintext

/*
----
This file is part of SECONDO.
Copyright (C) 2012, University in Hagen
Faculty of Mathematic and Computer Science,
Database Systems for New Applications.
SECONDO is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
SECONDO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SECONDO; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
----
\tableofcontents
\newpage
1 Overview
The following is a slightly modified example taken from [RWE15].
\begin{figure}[h]
\centerline{
\includegraphics[width=0.7\textwidth]{graph.eps}}
\end{figure}
2 Prepare data
2.1 Create database
Create a SECONDO database named "pgraph1" and enter it.
*/
SECONDO> create database pgraph1;
SECONDO> open database pgraph1;
/*
2.2 Create relations and insert data
The script ~createrels~ will create all node and edge relations and insert
the data to reflect the graph shown above.
*/
SECONDO> @../Algebras/PropertyGraph2/sample-pregel/sample-shakespeare/createrels
/*
This script uses operators from ~RelationAlgebra~ and ~UpdateRelation~.
Edge relations names are in uppercase, node relations are using only
the first character in uppercase. (This convention is used by the PropertyGraphAlgebra)
2.2 Create Ordered-Relations
The Compute-Function will use Ordered-Relations. With these it is also possbile
to query a persistent and non-distributed graph. The Ordered-Realtions can
be created by the following script:
*/
SECONDO> @../Algebras/PropertyGraph2/sample-pregel/sample-shakespeare/create_orel
/*
2.3 Distribute Data
For the use of Secondo-Pregel the relations have to be distributed to the defined Workers.
Therefore you need to define a Workers-Configuration-File an rename it in the script.
It is also possible to change the part-Function for the distribution.
The detailed steps to create different Workers is described in "Distributed Query
Processing in secondo". To distribute the data and define the Workers you can use the script:
*/
SECONDO> @../Algebras/PropertyGraph2/sample-pregel/sample-shakespeare/distribute
/*
3 Creating a property graph
A property graph has to be defined before matching operators can be
used to query the graph. This is done be registering the node and edge
relations. (This defines the schema of the graph)
*/
SECONDO> @../Algebras/PropertyGraph2/sample-pregel/sample-shakespeare/create
/*
At first a PropertyGraph object is created. The argument "p1" is
used to prefix objects in the memory catalog to keep the data
of multiple graphs separated.
*/
let p1=createpgraph("p1");
/*
To define the schema of the graph, the script ~create~ uses the
following operators to register the property graph:
* ~createpgraph(name)~ to create a property graph object
* ~addnodesrel[relname,fromclause,toclause]~ to register node relations
* ~addedgesrel[relanme,propertyname, indexname]~ to register edge relations
* ~addnodeindex[relanme]~ to register node property indexes
This configuration will be saved in the database and will
be available between sessions.
To get information about the configuration of a property graph
objects, use the ~info~ operator.
*/
SECONDO> query p1 info;
/*
4 Loading the graph
To be able to query the property graph, it needs to be loaded with the operator
loadgraphorel.
This will create the statistics of the graph (at the first excecution) and
additional structures to support the match operators.
*/
SECONDO> query p1 loadgraphorel;
/*
After loading the graph, the structure of the graph has to be configured.
For the use of Secondo-Pregel you can configure the structures "pregelpersistent"
and "pregelmemory".
*/
SECONDO> query p2 cfg["structure","pregelpersistent";
/*
5 Querying the property graph
For Querying the property graph with Secondo-Pregel there is the match1b operator.
The following script provides a sample-query:
*/
SECONDO> @../Algebras/PropertyGraph2/sample-pregel/sample-shakespeare/match1b
/*
After running the script the results can be created by the following command:
*/
SECONDO> query createSDArray("Results", Workers) dsummarize consume;
/*
To delete the results and start a new query they can be deleted with the command:
*/
SECONDO> qquery createSDArray("Results", Workers)
dmap["", . feed . deletedirect count] getValue