From aa60010f271498f6508c5966143fe6749bfa2137 Mon Sep 17 00:00:00 2001 From: Julien Lopez <julien.lopez@lri.fr> Date: Wed, 7 Jun 2017 18:06:33 +0200 Subject: [PATCH] Update to new QIR version --- com.oracle.truffle.r.engine/oracle.config | 10 +-- com.oracle.truffle.r.engine/postgre.config | 10 +-- com.oracle.truffle.r.engine/postgre2.config | 10 +-- .../r/nodes/qirinterface/QIRInterface.java | 70 +------------------ com.oracle.truffle.r.test/oracle.config | 10 +-- com.oracle.truffle.r.test/postgre.config | 10 +-- com.oracle.truffle.r.test/postgre2.config | 10 +-- oracle.config | 10 +-- postgre.config | 10 +-- postgre2.config | 10 +-- 10 files changed, 47 insertions(+), 113 deletions(-) diff --git a/com.oracle.truffle.r.engine/oracle.config b/com.oracle.truffle.r.engine/oracle.config index b49e79d8cb..676cc848c3 100644 --- a/com.oracle.truffle.r.engine/oracle.config +++ b/com.oracle.truffle.r.engine/oracle.config @@ -1,5 +1,5 @@ -ora.host = myoracle.com -ora.sid = myview -ora.port = 7658 -ora.user = julilope -ora.passwd = AVONEJ$sartec3 +host = myoracle.com +sid = myview +port = 7658 +user = julilope +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.engine/postgre.config b/com.oracle.truffle.r.engine/postgre.config index e0fd542200..39dd278151 100644 --- a/com.oracle.truffle.r.engine/postgre.config +++ b/com.oracle.truffle.r.engine/postgre.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = postgres -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = postgres +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.engine/postgre2.config b/com.oracle.truffle.r.engine/postgre2.config index 2c7bf36535..8ef8ed55fb 100644 --- a/com.oracle.truffle.r.engine/postgre2.config +++ b/com.oracle.truffle.r.engine/postgre2.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = other -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = other +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java index f11bee2785..9f9bf3485d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java @@ -22,16 +22,11 @@ */ package com.oracle.truffle.r.nodes.qirinterface; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; - import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlot; @@ -48,16 +43,10 @@ import com.oracle.truffle.r.runtime.env.REnvironment; import qir.ast.*; import qir.ast.data.*; import qir.ast.expression.*; -import qir.driver.sql.OracleDriver; -import qir.driver.sql.PostgreSQLDriver; -import qir.driver.ConnectionData; import qir.driver.DBDriver; import qir.driver.QIRDriver; -import qir.driver.hbase.HBaseDriver; public final class QIRInterface { - private static final Map<String, DBDriver<?, ?>> driverCache = new HashMap<>(); - /** * Runs a query in the database pointed by the given driver and returns the results. * @@ -124,65 +113,10 @@ public final class QIRInterface { } /** - * Returns a {@link DBDriver} of a database using a configuration file. This function uses a - * cache for the drivers. - * - * @param dbName The name of the targeted database - * @param fileName The name of the configuration file - * @return A {@link DBDriver} to the given database with the given configuration - */ - public static final DBDriver<?, ?> createDriver(final String dbName, final String fileName) throws UnsupportedOperationException { - final String cacheKey = dbName + '@' + fileName; - DBDriver<?, ?> result = driverCache.get(cacheKey); - - if (result != null) - return result; - switch (dbName) { - case "Oracle": - result = new OracleDriver(createConnectionData("ora", fileName)); - break; - case "PostgreSQL": - result = new PostgreSQLDriver(createConnectionData("pgsql", fileName)); - break; - case "HBase": - result = new HBaseDriver(fileName); - break; - default: - throw new RuntimeException("Unknown database: " + dbName); - } - driverCache.put(cacheKey, result); - return result; - } - - /** - * This function closes the connection of drivers created with the function - * {@link #createDriver(String, String)}. + * This function closes the connection of database drivers. */ public static final void closeDrivers() { - driverCache.values().stream().forEach(driver -> driver.closeConnection()); - } - - /** - * Creates a {@link ConnectionData} object based on the given configuration file. - * - * @param prefix A prefix for properties in the configuration file - * @param fileName The name of the configuration file - * @return A {@link ConnectionData} created from the given configuration file - */ - private static final ConnectionData createConnectionData(final String prefix, final String fileName) { - try { - final Reader dbConfigReader = new FileReader(fileName); - final Properties p = new Properties(); - p.load(dbConfigReader); - final String sessionId = p.getProperty(prefix + ".sid"); - final String serverName = p.getProperty(prefix + ".host"); - final int port = Integer.parseInt(p.getProperty(prefix + ".port")); - final String userName = p.getProperty(prefix + ".user"); - final String passwd = p.getProperty(prefix + ".passwd"); - return new ConnectionData(sessionId, serverName, port, userName, passwd); - } catch (IOException e) { - throw new RuntimeException("Invalid configuration file for connection to a database: " + fileName); - } + DBDriver.closeDrivers(); } /** diff --git a/com.oracle.truffle.r.test/oracle.config b/com.oracle.truffle.r.test/oracle.config index b49e79d8cb..676cc848c3 100644 --- a/com.oracle.truffle.r.test/oracle.config +++ b/com.oracle.truffle.r.test/oracle.config @@ -1,5 +1,5 @@ -ora.host = myoracle.com -ora.sid = myview -ora.port = 7658 -ora.user = julilope -ora.passwd = AVONEJ$sartec3 +host = myoracle.com +sid = myview +port = 7658 +user = julilope +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.test/postgre.config b/com.oracle.truffle.r.test/postgre.config index e0fd542200..39dd278151 100644 --- a/com.oracle.truffle.r.test/postgre.config +++ b/com.oracle.truffle.r.test/postgre.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = postgres -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = postgres +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.test/postgre2.config b/com.oracle.truffle.r.test/postgre2.config index 2c7bf36535..8ef8ed55fb 100644 --- a/com.oracle.truffle.r.test/postgre2.config +++ b/com.oracle.truffle.r.test/postgre2.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = other -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = other +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/oracle.config b/oracle.config index b49e79d8cb..676cc848c3 100644 --- a/oracle.config +++ b/oracle.config @@ -1,5 +1,5 @@ -ora.host = myoracle.com -ora.sid = myview -ora.port = 7658 -ora.user = julilope -ora.passwd = AVONEJ$sartec3 +host = myoracle.com +sid = myview +port = 7658 +user = julilope +passwd = Pa$$w0rd diff --git a/postgre.config b/postgre.config index e0fd542200..39dd278151 100644 --- a/postgre.config +++ b/postgre.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = postgres -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = postgres +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/postgre2.config b/postgre2.config index 2c7bf36535..8ef8ed55fb 100644 --- a/postgre2.config +++ b/postgre2.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = other -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = other +port = 5432 +user = julien +passwd = Pa$$w0rd -- GitLab