Search…
Migrating Vega Code to Dynamic Poly Rendering
In OmniSci release 5.2, the polygon cache for rendering is being deprecated and will be completely removed in a subsequent OmniSci release. Any poly cache rendering in your code must be reworked to use dynamic poly rending. This topic describes how to migrate poly cache code to dynamic, cacheless rendering.
Caching poly buffers has two main drawbacks, both of which have a significant impact on memory:
    The cache cannot span multiple GPUs.
    The entire table is cached, regardless of the filter in the query.
In contrast, dynamic poly rendering can utilize all available GPUs and only uses the data that passes any filters.
To move to dynamic poly rendering, determine if you are using the poly cache, and then adjust your code if needed.
OmniSci strongly recommends that you also remove the render-poly-cache-bytes option from your server configuration file, if used. This will help prevent startup warnings or errors in subsequent releases of OmniSci.

Am I Using the Poly Cache?

It may not be immediately obvious if you are using poly cache rendering because no flag is used to enable it. Instead, poly cache rendering is enabled according to the SQL code used in a poly-formatted data block of Vega code. If the query ultimately projects or results in a POLYGON/MULTIPOLYGON column, the cache is not used and no code changes are requried.
However, if the query does not reference a POLYGON/MULTIPOLYGON column, but projects a rowid column, then poly caching is in use.
The following Vega code has a poly query that uses the cache system:
1
...,
2
"data": [
3
{
4
"name": "polys",
5
"format": "polys",
6
"sql": "SELECT rowid from zipcodes WHERE ST_XMax(omnisci_geo) > -160.0 AND ST_XMin(omnisci_geo) <
7
160.0 AND ST_YMax(omnisci_geo) > -60.0 AND ST_YMin(omnisci_geo) < 60.0"
8
}
9
],
10
...
Copied!
The sql property of the polys data block, which uses "format": "polys", projects a rowid column. This activates poly caching, even though the geo column (omnisci_geo in this case) is used in the filter.
To convert this Vega code to dynamic, cacheless rendering, change the SQL query:
1
"sql": "SELECT omnisci_geo from zipcodes WHERE ST_XMax(omnisci_geo) > -160.0 AND ST_XMin(omnisci_geo) <
2
160.0 AND ST_YMax(omnisci_geo) > -60.0 AND ST_YMin(omnisci_geo) < 60.0"
Copied!
You can keep rowid in this query and use it for later hit-testing. It's presence does not affect dynamic rendering. See the simple projection query in Example 1 for an example.
Alternatively, you can check the INFO logs to see if poly caching is used. Look for a LOG statement similar to the following:
1
Caching <number> bytes (<number> for vbo/ibo) for poly query: <sql> on gpu <number>
2
Poly cache on gpu <number> now using <number> of <number> bytes.
Copied!
or
1
Cannot cache <number> bytes (<number> for vbo/ibo) for poly query: <sql> on gpu <number>.
2
There is currently <number> of <number> total bytes used in the poly cache.
Copied!
If you find either of these, then a poly cache render query is used.

Migrating Your Code

To migrate from poly cache to dynamic poly rendering, you output a POLYGON/MULTIPOLYGON column in the SQL query of a poly-formatted data block of your Vega code. In the following examples, the omnisci_geo column is a MULTIPOLYGON.

Example 1 - Simple projection query

Cached (only rowid is output):
1
...,
2
"data": [
3
{
4
"name": "polys",
5
"format": "polys",
6
"sql": "SELECT rowid from zipcodes WHERE ST_XMax(omnisci_geo) > -160.0 AND ST_XMin(omnisci_geo) <
7
160.0 AND ST_YMax(omnisci_geo) > -60.0 AND ST_YMin(omnisci_geo) < 60.0"
8
}
9
],
10
...
Copied!
Dynamic (omnisci_geo is now projected, along with rowid):
1
...,
2
"data": [
3
{
4
"name": "polys",
5
"format": "polys",
6
"sql": "SELECT omnisci_geo, rowid from zipcodes WHERE ST_XMax(omnisci_geo) > -160.0 AND ST_XMin(omnisci_geo) <
7
160.0 AND ST_YMax(omnisci_geo) > -60.0 AND ST_YMin(omnisci_geo) < 60.0"
8
}
9
],
10
...
Copied!
Example 2 - Join query using a WITH subquery
Cached (no geo column is projected in the outer query of the join):
1
...,
2
"data": [
3
{
4
"name": "choropleth",
5
"format": "polys",
6
"sql": "WITH colors AS (SELECT pickup_building as key0, avg(tip_amount/fare_amount) as color
7
FROM taxi_factual_closestbuilding WHERE (fare_amount > 0 AND tip_amount >= 0 AND tip_amount/fare_amount<1)
8
GROUP BY key0) SELECT nyc_buildings.rowid, colors.key0 as key0, colors.color as color
9
FROM colors, nyc_buildings WHERE (colors.key0 = nyc_buildings.bld_id) AND
10
(ST_XMax(nyc_buildings.omnisci_geo) >= -74.06993970987278 AND
11
ST_XMin(nyc_buildings.omnisci_geo) <= -73.87446838332451 AND
12
ST_YMax(nyc_buildings.omnisci_geo) >= 40.64111330399987 AND
13
ST_YMin(nyc_buildings.omnisci_geo) <= 40.87934187208219)"
14
}
15
],
16
...
Copied!
Dynamic (the geo column is projected in place of rowid):
1
...,
2
"data": [
3
{
4
"name": "backendChoropleth",
5
"format": "polys",
6
"sql": "WITH colors AS (SELECT pickup_building as key0, avg(tip_amount/fare_amount) as color
7
FROM taxi_factual_closestbuilding WHERE (fare_amount > 0 AND tip_amount >= 0 AND tip_amount/fare_amount<1)
8
GROUP BY key0) SELECT nyc_buildings.omnisci_geo as omnisci_geo, colors.key0 as key0, colors.color as color
9
FROM colors, nyc_buildings WHERE (colors.key0 = nyc_buildings.bld_id) AND
10
(ST_XMax(nyc_buildings.omnisci_geo) >= -74.06993970987278 AND
11
ST_XMin(nyc_buildings.omnisci_geo) <= -73.87446838332451 AND
12
ST_YMax(nyc_buildings.omnisci_geo) >= 40.64111330399987 AND
13
ST_YMin(nyc_buildings.omnisci_geo) <= 40.87934187208219)"
14
}
15
],
16
...
Copied!
Last modified 1yr ago