PGX 2.5.0
Documentation

What is New in PGX 2.5


New Green-Marl Compiler

PGX 2.5 introduces a new implementation of the Green-Marl compiler, now based on the Spoofax framework. The new compiler (as usual, available with the OTN package) introduces support for new Green-Marl features:

  • Vertex and Edge filters.
  • Ordered iteration.
  • Iteration over keys and values in maps.

Moreover, the new compiler will work on any system supported by the JDK and it is now possible to compile Green-Marl in a Scala environment.

Notice that foreign syntax is no longer supported by the compiler. You can still get an instance of the old compiler to deal with legacy code; see the changelog for more information.

New Built-in Algorithms

PGX 2.5 introduces new built-in algorithms for cycle detection; see the reference documentation for more details.

Temporal Data Types

With PGX 2.5 you can have more precise control on time-related properties, with support for five temporal data types that map directly to the five temporal types in SQL as well as to the new Java 8 date-time types. The date property type is now deprecated and replaced by local_date, time, timestamp, time_with_timezone and timestamp_with_timezone; the new types are supported both in the PGX API and in PGQL, as the following table summarizes.

Type PGX property type Example plain text Example PGQL literal PGQL ResultSet API
TIMESTAMP WITH TIMEZONE timestamp_with_timezone "2017-08-18 20:15:00+08" TIMESTAMP '2017-08-18 20:15:00+08' java.time.OffsetDateTime getTimestampWithTimezone(..)
TIMESTAMP timestamp "2017-08-18 20:15:00" TIMESTAMP '2017-08-18 20:15:00' java.time.LocalDateTime getTimestamp(..)
TIME WITH TIMEZONE time_with_timezone "20:15:00+08" TIME '20:15:00+08' java.time.OffsetTime getTimeWithTimezone(..)
TIME time "20:15:00" TIME '20:15:00' java.time.LocalTime getTime(..)
DATE local_date "2017-08-18" DATE '2017-08-18' java.time.LocalDate getDate(..)

Spatial Data Type Point2D

PGX 2.5 introduces a new data type to store 2-dimensinal coordinates (e.g., latitude and longitude), as the following table illustrates.

Type PGX property type Example plain text Example PGQL literal PGQL ResultSet API
POINT2D point2d "-64.211157 114.257813" ST_X(vertex1.point2dProp) >= ST_X(vertex2.point2dProp) oracle.pgql.lang.spatial.Point2D getPoint2D(..)

You can refer to the PropertyType class javadoc, the GraphConfig documentation, the PGQL specification, and the pattern matching API reference for more information on Point2D and all the supported data types.

API Improvements

PGX 2.5 introduces several additions and improvements in the Java API:

New Features in PGQL

PGX 2.5 introduces several new features in PGQL; we highlight the most important here.

Prepared Statements

Prepared statements provide a way to safeguard your application from query injection. The use of prepared statements can also speed up query execution as queries do not need to get recompiled every time their bind values change. PGQL uses the question mark symbol (?) to indicate a bind variable. Values for the bind variables are then assigned through the PreparedStatement API, as explained in the reference documentation.

Undirected Edge Queries

PGQL has now support for undirected edge queries, which can be used to query undirected graphs or ignoring edge direction in directed graphs. These two use cases are illustrated in the following two queries:

SELECT d1.name WHERE (d1:Device) -[:connects_to]- (d2:Device), d1.name = 'LoadTransformer 2533'
SELECT m.name WHERE (n:Person) -[:follows]- (m:Person) , n.name = 'Bono'

The first query matches undirected edges labeled connects_to, the second query matches all people that follow or are followed by a person named 'Bono'.

Other Additions and Improvements in PGQL

  • PGQL now has an all_different(a, b, c, ...) function , wich allows to specify that a set of values (typically vertices or edges) are all different from each other.
  • Support for greater than, greater than equal, less than, and less than equal for comparing String values (also works for filter expressions in the Java API).
  • Support the new temporal data types in PGQL queries (see above).
  • Support the new Point2D spatial data type in PGQL queries (see above).
  • Added support for constraints on vertices in PATH patterns, e.g., PATH connects_to_high_volt_dev := (:Device) -> (:Device WITH voltage > 35000) SELECT .... Previously, only constraints on edges in PATH patterns were supported.

Loader improvements

The PGX graph loader has extended capabilities with PGX 2.5:

  • The Apache Spark loader now supports Spark 2.X.
  • Columns names are now configurable when loading from the Oracle RDBMS in two tables format.
  • The two tables format now supports string, integer and long as vertex ID types.
  • Added support for directly loading compressed (gzip) graph data without the need to unpack the archives first.

Distributed Engine Improvements

PGX.D, the scale-out, distributed execution engine included in PGX, gets several improvements that reduce the functionality gap with the single-machine execution engine:

  • PGX.D now supports top-k and bottom-k for string properties.
  • Fixed a bug concering NULL values (Oracle bug #25491165).
  • Added support for edge properties of vector type.
  • Extended the supported endpoints in the client-server API: added support for rename(), getNeighbours(), getEdges(), getRandomVertex(), getRandomEdge(), getSource(), getDestination().

R Client Improvements

The PGX R clients (part of OAAgraph) got some new functionality:

  • The oaa.graph function now supports vertexIdType argument for string, integer and long.
  • The oaa.graph function now supports loadEdgeIds argument.
  • The oaa.create function now supports storeEdgeLabel and storeNodeLabels arguments.

Other Bug Fixes and Improvements

Numerous other improvements and bug fixes aimed at continuously improving the user experience with PGX also made it into this release; an incomplete list follows:

  • When :timing ON is set, the PGX shell now always outputs time in seconds in the fixed format X+.XXXs, where X is [0-9], instead of switching between seconds and milliseconds. This change should make it easier to parse the logs for timing information.
  • Improved log messages from property loading error handling, by adding the corresponding property name.
  • Improved log messages when parsing values for temporal typed properties fails.
  • Added a client configuration field max_client_http_connections for controlling the maximum number of connections between a PGX Client and PGX Server.
  • Reduced the latency of requests to refresh a graph.
  • Improved the performance of BFS-based algorithms on large data-sets.
  • Improved the performance of GROUP BY and ORDER BY in PGQL

Refer to the changelog for a complete list.