public class QueryGraphRequest extends Object implements org.apache.avro.generic.IndexedRecord
GPUdb.queryGraph(QueryGraphRequest)
.
Employs a topological query on a network graph generated a-priori by GPUdb.createGraph(CreateGraphRequest)
and returns a list of
adjacent edge(s) or node(s), also known as an adjacency list, depending on
what's been provided to the endpoint; providing edges will return nodes and
providing nodes will return edges.
To determine the node(s) or edge(s) adjacent to a value from a given column,
provide a list of values to queries
. This field can be populated
with column values from any table as long as the type is supported by the
given identifier. See Query Identifiers for more information.
To return the adjacency list in the response, leave adjacencyTable
empty. To return the adjacency list in a table and not in the response,
provide a value to adjacencyTable
and set export_query_results
to false
. To return the adjacency list both in
a table and the response, provide a value to adjacencyTable
and set
export_query_results
to true
.
IMPORTANT: It's highly recommended that you review the Network Graphs & Solvers concepts documentation, the Graph REST Tutorial, and/or some /query/graph examples before using this endpoint.
Modifier and Type | Class and Description |
---|---|
static class |
QueryGraphRequest.Options
Additional parameters
FORCE_UNDIRECTED : If set to true , all inbound edges and
outbound edges relative to the node will be returned. |
Constructor and Description |
---|
QueryGraphRequest()
Constructs a QueryGraphRequest object with default parameters.
|
QueryGraphRequest(String graphName,
List<String> queries,
List<String> restrictions,
String adjacencyTable,
int rings,
Map<String,String> options)
Constructs a QueryGraphRequest object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Object |
get(int index)
This method supports the Avro framework and is not intended to be called
directly by the user.
|
String |
getAdjacencyTable() |
static org.apache.avro.Schema |
getClassSchema()
This method supports the Avro framework and is not intended to be called
directly by the user.
|
String |
getGraphName() |
Map<String,String> |
getOptions() |
List<String> |
getQueries() |
List<String> |
getRestrictions() |
int |
getRings() |
org.apache.avro.Schema |
getSchema()
This method supports the Avro framework and is not intended to be called
directly by the user.
|
int |
hashCode() |
void |
put(int index,
Object value)
This method supports the Avro framework and is not intended to be called
directly by the user.
|
QueryGraphRequest |
setAdjacencyTable(String adjacencyTable) |
QueryGraphRequest |
setGraphName(String graphName) |
QueryGraphRequest |
setOptions(Map<String,String> options) |
QueryGraphRequest |
setQueries(List<String> queries) |
QueryGraphRequest |
setRestrictions(List<String> restrictions) |
QueryGraphRequest |
setRings(int rings) |
String |
toString() |
public QueryGraphRequest()
public QueryGraphRequest(String graphName, List<String> queries, List<String> restrictions, String adjacencyTable, int rings, Map<String,String> options)
graphName
- Name of the graph resource to query.queries
- Nodes or edges to be queried specified using query identifiers. Identifiers can be
used with existing column names, e.g., 'table.column AS
QUERY_NODE_ID', raw values, e.g., '{0, 2} AS
QUERY_NODE_ID', or expressions, e.g.,
'ST_MAKEPOINT(table.x, table.y) AS QUERY_NODE_WKTPOINT'.
Multiple values can be provided as long as the same
identifier is used for all values. If using raw values
in an identifier combination, the number of values
specified must match across the combination.restrictions
- Additional restrictions to apply to the nodes/edges
of an existing graph. Restrictions must be
specified using identifiers; identifiers are
grouped as combinations. Identifiers can be
used with existing column names, e.g.,
'table.column AS RESTRICTIONS_EDGE_ID',
expressions, e.g., 'column/2 AS
RESTRICTIONS_VALUECOMPARED', or raw values, e.g.,
'{0, 0, 0, 1} AS RESTRICTIONS_ONOFFCOMPARED'. If
using raw values in an identifier combination, the
number of values specified must match across the
combination. The default value is an empty List
.adjacencyTable
- Name of the table to store the resulting
adjacencies. If left blank, the query results are
instead returned in the response even if export_query_results
is set to false
. If
the 'QUERY_TARGET_NODE_LABEL' query identifier is used in
queries
, then two additional columns will
be available: 'PATH_ID' and 'RING_ID'. See
Using Labels for more
information. The default value is ''.rings
- Sets the number of rings around the node to query for
adjacency, with '1' being the edges directly attached to
the queried node. Also known as number of hops. For
example, if it is set to '2', the edge(s) directly
attached to the queried node(s) will be returned; in
addition, the edge(s) attached to the node(s) attached to
the initial ring of edge(s) surrounding the queried
node(s) will be returned. If the value is set to '0', any
nodes that meet the criteria in queries
and restrictions
will be returned. This parameter is only
applicable when querying nodes. The default value is 1.options
- Additional parameters
FORCE_UNDIRECTED
: If set to true
, all inbound
edges and outbound edges relative to the node will be
returned. If set to false
, only outbound edges
relative to the node will be returned. This parameter is
only applicable if the queried graph graphName
is directed and when querying nodes. Consult Directed Graphs for more details.
Supported values:
The default value is FALSE
.
LIMIT
: When specified, limits the number of query
results. Note that if the target_nodes_table
is
provided, the size of the corresponding table will be
limited by the limit
value. The default value
is an empty Map
.
TARGET_NODES_TABLE
: Name of the table to store the list
of the final nodes reached during the traversal. If this
value is left as the default, the table name will
default to the adjacencyTable
value plus a
'_nodes' suffix, e.g., 'RESTRICTION_THRESHOLD_VALUE
: Value-based restriction
comparison. Any node or edge with a
RESTRICTIONS_VALUECOMPARED value greater than the restriction_threshold_value
will not be included in the
solution.
EXPORT_QUERY_RESULTS
: Returns query results in the
response. If set to true
, the adjacencyListIntArray
(if the query was based on IDs),
adjacencyListStringArray
(if the query was based
on names), or adjacencyListWktArray
(if the
query was based on WKTs) will be populated with the
results. If set to false
, none of the arrays
will be populated.
Supported values:
The default value is FALSE
.
ENABLE_GRAPH_DRAW
: If set to true
, adds a
WKT-type column named 'QUERY_EDGE_WKTLINE' to the given
adjacencyTable
and inputs WKT values from the
source graph (if available) or auto-generated WKT values
(if there are no WKT values in the source graph). A
subsequent call to the /wms endpoint can then be made to
display the query results on a map.
Supported values:
The default value is FALSE
.
AND_LABELS
: If set to true
, the result of the
query has entities that satisfy all of the target
labels, instead of any.
Supported values:
The default value is FALSE
.
Map
.public static org.apache.avro.Schema getClassSchema()
public String getGraphName()
public QueryGraphRequest setGraphName(String graphName)
graphName
- Name of the graph resource to query.this
to mimic the builder pattern.public List<String> getQueries()
public QueryGraphRequest setQueries(List<String> queries)
queries
- Nodes or edges to be queried specified using query identifiers. Identifiers can be
used with existing column names, e.g., 'table.column AS
QUERY_NODE_ID', raw values, e.g., '{0, 2} AS
QUERY_NODE_ID', or expressions, e.g.,
'ST_MAKEPOINT(table.x, table.y) AS QUERY_NODE_WKTPOINT'.
Multiple values can be provided as long as the same
identifier is used for all values. If using raw values
in an identifier combination, the number of values
specified must match across the combination.this
to mimic the builder pattern.public List<String> getRestrictions()
List
.public QueryGraphRequest setRestrictions(List<String> restrictions)
restrictions
- Additional restrictions to apply to the nodes/edges
of an existing graph. Restrictions must be
specified using identifiers; identifiers are
grouped as combinations. Identifiers can be
used with existing column names, e.g.,
'table.column AS RESTRICTIONS_EDGE_ID',
expressions, e.g., 'column/2 AS
RESTRICTIONS_VALUECOMPARED', or raw values, e.g.,
'{0, 0, 0, 1} AS RESTRICTIONS_ONOFFCOMPARED'. If
using raw values in an identifier combination, the
number of values specified must match across the
combination. The default value is an empty List
.this
to mimic the builder pattern.public String getAdjacencyTable()
export_query_results
is set to false
. If
the 'QUERY_TARGET_NODE_LABEL' query identifier is used in queries
,
then two additional columns will be available: 'PATH_ID' and
'RING_ID'. See
Using Labels for more information. The
default value is ''.public QueryGraphRequest setAdjacencyTable(String adjacencyTable)
adjacencyTable
- Name of the table to store the resulting
adjacencies. If left blank, the query results are
instead returned in the response even if export_query_results
is set to false
. If
the 'QUERY_TARGET_NODE_LABEL' query identifier is used in
queries
, then two additional columns will
be available: 'PATH_ID' and 'RING_ID'. See
Using Labels for more
information. The default value is ''.this
to mimic the builder pattern.public int getRings()
queries
and restrictions
will be returned. This parameter is only
applicable when querying nodes. The default value is 1.public QueryGraphRequest setRings(int rings)
rings
- Sets the number of rings around the node to query for
adjacency, with '1' being the edges directly attached to
the queried node. Also known as number of hops. For
example, if it is set to '2', the edge(s) directly
attached to the queried node(s) will be returned; in
addition, the edge(s) attached to the node(s) attached to
the initial ring of edge(s) surrounding the queried
node(s) will be returned. If the value is set to '0', any
nodes that meet the criteria in queries
and restrictions
will be returned. This parameter is only
applicable when querying nodes. The default value is 1.this
to mimic the builder pattern.public Map<String,String> getOptions()
FORCE_UNDIRECTED
: If set to true
, all inbound edges and
outbound edges relative to the node will be returned. If set to
false
, only outbound edges relative to the node will be
returned. This parameter is only applicable if the queried graph
graphName
is directed and when querying nodes. Consult
Directed Graphs for more details.
Supported values:
The default value is FALSE
.
LIMIT
: When
specified, limits the number of query results. Note that if the
target_nodes_table
is provided, the size of the
corresponding table will be limited by the limit
value.
The default value is an empty Map
.
TARGET_NODES_TABLE
: Name of the table to store the list of the
final nodes reached during the traversal. If this value is left
as the default, the table name will default to the adjacencyTable
value plus a '_nodes' suffix, e.g.,
'RESTRICTION_THRESHOLD_VALUE
: Value-based restriction
comparison. Any node or edge with a RESTRICTIONS_VALUECOMPARED
value greater than the restriction_threshold_value
will
not be included in the solution.
EXPORT_QUERY_RESULTS
: Returns query results in the response. If
set to true
, the adjacencyListIntArray
(if the
query was based on IDs), adjacencyListStringArray
(if
the query was based on names), or adjacencyListWktArray
(if the query was based on WKTs) will be populated with the
results. If set to false
, none of the arrays will be
populated.
Supported values:
The default value is FALSE
.
ENABLE_GRAPH_DRAW
: If set to true
, adds a WKT-type
column named 'QUERY_EDGE_WKTLINE' to the given adjacencyTable
and inputs WKT values from the source graph (if
available) or auto-generated WKT values (if there are no WKT
values in the source graph). A subsequent call to the /wms endpoint can then be made to display the
query results on a map.
Supported values:
The default value is FALSE
.
AND_LABELS
: If set to true
, the result of the query has
entities that satisfy all of the target labels, instead of any.
Supported values:
The default value is FALSE
.
Map
.public QueryGraphRequest setOptions(Map<String,String> options)
options
- Additional parameters
FORCE_UNDIRECTED
: If set to true
, all inbound
edges and outbound edges relative to the node will be
returned. If set to false
, only outbound edges
relative to the node will be returned. This parameter is
only applicable if the queried graph graphName
is directed and when querying nodes. Consult Directed Graphs for more details.
Supported values:
The default value is FALSE
.
LIMIT
: When specified, limits the number of query
results. Note that if the target_nodes_table
is
provided, the size of the corresponding table will be
limited by the limit
value. The default value
is an empty Map
.
TARGET_NODES_TABLE
: Name of the table to store the list
of the final nodes reached during the traversal. If this
value is left as the default, the table name will
default to the adjacencyTable
value plus a
'_nodes' suffix, e.g., 'RESTRICTION_THRESHOLD_VALUE
: Value-based restriction
comparison. Any node or edge with a
RESTRICTIONS_VALUECOMPARED value greater than the restriction_threshold_value
will not be included in the
solution.
EXPORT_QUERY_RESULTS
: Returns query results in the
response. If set to true
, the adjacencyListIntArray
(if the query was based on IDs),
adjacencyListStringArray
(if the query was based
on names), or adjacencyListWktArray
(if the
query was based on WKTs) will be populated with the
results. If set to false
, none of the arrays
will be populated.
Supported values:
The default value is FALSE
.
ENABLE_GRAPH_DRAW
: If set to true
, adds a
WKT-type column named 'QUERY_EDGE_WKTLINE' to the given
adjacencyTable
and inputs WKT values from the
source graph (if available) or auto-generated WKT values
(if there are no WKT values in the source graph). A
subsequent call to the /wms endpoint can then be made to
display the query results on a map.
Supported values:
The default value is FALSE
.
AND_LABELS
: If set to true
, the result of the
query has entities that satisfy all of the target
labels, instead of any.
Supported values:
The default value is FALSE
.
Map
.this
to mimic the builder pattern.public org.apache.avro.Schema getSchema()
getSchema
in interface org.apache.avro.generic.GenericContainer
public Object get(int index)
get
in interface org.apache.avro.generic.IndexedRecord
index
- the position of the field to getIndexOutOfBoundsException
public void put(int index, Object value)
put
in interface org.apache.avro.generic.IndexedRecord
index
- the position of the field to setvalue
- the value to setIndexOutOfBoundsException
Copyright © 2020. All rights reserved.