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 logging in IDs ahead of time.
The warmPool
function logs in available SAM pool user IDs. Additionally, when
warming the pool you can provide queries that are run on the IDs as they are logged in.
This can speed the retrieval of results for users.
warmPool
function takes the following parameters:- URL or gateway of the 1010 connection to use (
url
) - Group owner name (
owner
) - Group owner password (
password
) - Group ID (
group
) - Array of
BaseQuery
objects (queries
) -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:
warmPool(url, owner, password, group)
warmPool(gateway, owner, password, group, queries, logfile)
You can run warmPool
without logging in or from a session that is logged in.
If you are already logged in, you will not have to input your information
(url
, owner
, group
, and
password
) again.
The used IDs should be released at the end of their activity with the platform. When they are released, they are not warmed automatically.
The example below uses warmPool
to warm the SAM pool and
BaseQuery
to provide a query:
import com.tentendata.javasdk1010v2.*; public class Warming { public static void main(String[] args) { String gateway; String queryXML; String tablePath; String username; String password; String group; Session session = null; Query query; BaseQuery[] queries; if (args.length < 3) { System.err.println("usage: PrintTable USERNAME PASSWORD GROUP"); System.exit(1); } username = args[0]; password = args[1]; group = args[2]; System.err.println("Group login to " + group + ", owner " + username); gateway = "https://www2.1010data.com/cgi-bin/gw.k"; queryXML = "<sel value=\"(us_postal_state_code='WA')\"/>"; tablePath = "pub.public_data.fhfa.fhfa"; queries = new BaseQuery[1]; queries[0] = new BaseQuery(tablePath, queryXML); int w=Session.warmPool(gateway, username, password, group, queries, "WarmLog.log"); System.out.println("Warmed " + w + " uids"); System.exit(8); try { session = new Session(gateway, username, password, LoginType.POSSESS); query = new Query(session, tablePath, queryXML); query.setWindowSize(1000); ResultSet results = query.run(); // Limit rows to 5000 for testing purposes. for (long i = 0; i < Math.min(5000,results.numRows()); i++) { Row row = results.row(i); Datum[] data = row.asArray(); for (int j = 0; j < data.length; j++) { if (j > 0) { System.out.print('\t'); } System.out.print(data[j].toString()); } System.out.println(); } } catch (TentenException exc) { System.err.println("1010 Exception occurred: " + exc.toString()); } finally { if (session!=null) { session.close(); } } } }
USERNAME
,
GROUP
, and
PASSWORD
are placeholders for valid
Insights Platform group owner name, group name, and password.