warmPool
(Warm a SAM pool)
One way to reduce the amount of time it takes to retrieve results from the 1010data Insights Platform is to "warm" the SAM pool by having pool IDs logged in ahead of time.
An ID from a SAM pool that was warmed is already logged into the Insights Platform. The
warmPool
function logs in available SAM pool user IDs, which can
speed the retrieval of results for users. To this end, you can also provide queries to
run on the warmed IDs when they log in.
warmPool
function takes the following parameters:- The URL of the 1010 gateway (
url
) - Group owner name (
owner
) - Group owner password (
password
) - Group ID (
group
) - List of
BaseQuery
objects -BaseQuery
objects take a table name and 1010data Macro Language query, but are different fromQuery
objects because they are not associated with aSession
object. The default value isNone
. - Path to a log file (
logfile
) - The default value isNone
.
Example without queries or a log file path and with them:
py1010.warmPool(gateway, owner, password, group)
py1010.warmPool(gateway, owner, password, group, queries=None, logfile=None)
You can run warmPool
without logging in.
warmPool
returns the number of IDs warmed.
After the query results are retrieved, the used IDs should be released back into the pool of available IDs. For more information, see Cleaning up a session. These released IDs are not re-warmed automatically. When they are used again, the ID will have to be logged in.
The example below uses warmPool
to warm the SAM pool and
BaseQuery
to provide a query:
#!/usr/bin/env python import py1010 url = "https://www2.1010data.com/prod-latest/gw" owner = "USERNAME" group = "GROUP" password = "PASSWORD" queries = [ py1010.BaseQuery("pub.demo.weather.stations", ""), py1010.BaseQuery("pub.demo.weather.hourly90", '''<sel value="(id=3103)"/>''') ] warmed=py1010.warmPool(url, owner, password, group, queries=queries, logfile="FOOO.log"); print("Warmed: %d"%warmed)
USERNAME
, GROUP
,
and PASSWORD
are placeholders for valid Insights
Platform group owner name. group name, and password.