incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/5] git commit: Minor changes to make sure the jdbc driver still works.
Date Mon, 10 Jun 2013 12:28:16 GMT
Minor changes to make sure the jdbc driver still works.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/9573afbb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/9573afbb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/9573afbb

Branch: refs/heads/0.1.5
Commit: 9573afbbdd2c10c6ad9bca5f1c200bc4c6df1ac2
Parents: 7a6a980
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Jun 10 08:27:24 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Jun 10 08:27:24 2013 -0400

----------------------------------------------------------------------
 .../org/apache/blur/jdbc/BlurConnection.java    | 18 +++------
 .../apache/blur/jdbc/BlurDatabaseMetaData.java  |  9 +----
 .../java/org/apache/blur/jdbc/BlurJdbc.java     | 41 ++++++++------------
 .../apache/blur/jdbc/BlurResultSetRecords.java  |  5 ++-
 .../org/apache/blur/jdbc/BlurResultSetRows.java |  2 +-
 .../org/apache/blur/jdbc/BlurStatement.java     |  2 +-
 6 files changed, 30 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9573afbb/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
----------------------------------------------------------------------
diff --git a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
index ea4e145..ae1bee6 100644
--- a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
+++ b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
@@ -27,15 +27,13 @@ import org.apache.blur.jdbc.abstractimpl.AbstractBlurConnection;
 public class BlurConnection extends AbstractBlurConnection {
 
   private boolean closed;
-  private int port;
-  private String host;
+  private String connectionString;
   private String catalog;
   private String url;
   private String username;
 
-  public BlurConnection(String url, String username, String host, int port, String catalog)
{
-    this.host = host;
-    this.port = port;
+  public BlurConnection(String url, String username, String connectionString, String catalog)
{
+    this.connectionString = connectionString;
     this.catalog = catalog;
     this.url = url;
     this.username = username;
@@ -53,7 +51,7 @@ public class BlurConnection extends AbstractBlurConnection {
 
   @Override
   public DatabaseMetaData getMetaData() throws SQLException {
-    return new BlurDatabaseMetaData(url, username, host, port);
+    return new BlurDatabaseMetaData(url, username, connectionString);
   }
 
   @Override
@@ -101,12 +99,8 @@ public class BlurConnection extends AbstractBlurConnection {
 
   }
 
-  public int getPort() {
-    return port;
-  }
-
-  public String getHost() {
-    return host;
+  public String getConnectionString() {
+    return connectionString;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9573afbb/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
index fd3098a..3859a66 100644
--- a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
+++ b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
@@ -58,19 +58,14 @@ public class BlurDatabaseMetaData extends AbstractBlurDatabaseMetaData
{
   private int majorVersion = 1;
   private String url;
   private String username;
-  private int port;
-  private String host;
   private List<String> tables;
   private Map<String, Schema> schemaMap = new TreeMap<String, Schema>();
 
-  public BlurDatabaseMetaData(String url, String username, String host, int port) {
+  public BlurDatabaseMetaData(String url, String username, String connectionString) {
     this.url = url;
     this.username = username;
-    this.host = host;
-    this.port = port;
     try {
-      BlurClientManager.execute(this.host + ":" + this.port, new BlurCommand<Void>()
{
-
+      BlurClientManager.execute(connectionString, new BlurCommand<Void>() {
         @Override
         public Void call(Client client) throws BlurException, TException {
           tables = client.tableList();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9573afbb/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
----------------------------------------------------------------------
diff --git a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
index 861fe45..bd0ae47 100644
--- a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
+++ b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
@@ -24,6 +24,8 @@ import java.util.Properties;
 
 public class BlurJdbc implements Driver {
 
+  public static final String PREFIX = "jdbc:blur:";
+
   static {
     try {
       java.sql.DriverManager.registerDriver(new BlurJdbc());
@@ -34,35 +36,24 @@ public class BlurJdbc implements Driver {
 
   @Override
   public boolean acceptsURL(String url) throws SQLException {
-    // jdbc:blur:host:port
-    String[] split = url.split(":");
-    if (split.length != 4) {
-      return false;
-    }
-    if ("jdbc".equals(split[0])) {
-      if ("blur".equals(split[1])) {
-        return true;
-      }
+    // jdbc:blur:<connection string>
+    url = url.trim();
+    if (url.startsWith(PREFIX)) {
+      return true;
     }
     return false;
   }
 
   @Override
   public Connection connect(String url, Properties info) throws SQLException {
-    // jdbc:blur:host:port
+    // jdbc:blur:<connection string>
     String username = "";
-    String[] split = url.split(":");
-    if (split.length != 4) {
+    url = url.trim();
+    if (!acceptsURL(url)) {
       throw new SQLException("Invalid url [" + url + "]");
     }
-    if ("jdbc".equals(split[0])) {
-      if ("blur".equals(split[1])) {
-        String host = split[2];
-        int port = Integer.parseInt(split[3]);
-        return new BlurConnection(url, username, host, port, host);
-      }
-    }
-    throw new SQLException("Invalid url [" + url + "]");
+    String connectionString = url.substring(PREFIX.length());
+    return new BlurConnection(url, username, connectionString, "unknown");
   }
 
   @Override
@@ -84,11 +75,11 @@ public class BlurJdbc implements Driver {
   public boolean jdbcCompliant() {
     return false;
   }
-  
-  //java 7
 
-//  public Logger getParentLogger() throws SQLFeatureNotSupportedException {
-//    throw new SQLFeatureNotSupportedException();
-//  }
+  // java 7
+
+  // public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+  // throw new SQLFeatureNotSupportedException();
+  // }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9573afbb/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
----------------------------------------------------------------------
diff --git a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
index c86e574..b4ffb24 100644
--- a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
+++ b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
@@ -40,6 +40,7 @@ import org.apache.blur.thrift.generated.BlurQuery;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.thrift.generated.BlurResults;
 import org.apache.blur.thrift.generated.Column;
+import org.apache.blur.thrift.generated.FetchRecordResult;
 import org.apache.blur.thrift.generated.FetchResult;
 import org.apache.blur.thrift.generated.Record;
 import org.apache.blur.thrift.generated.Schema;
@@ -150,7 +151,9 @@ public class BlurResultSetRecords extends AbstractBlurResultSet {
 
         final BlurResult result = results.results.get(resultPosition);
         try {
-          selector.setLocationId(result.getLocationId());
+          FetchRecordResult recordResult = result.getFetchResult().getRecordResult();
+          selector.setRecordId(recordResult.getRowid());
+          selector.setRecordId(recordResult.getRecord().getRecordId());
           fetchResult = client.fetchRow(tableName, selector);
           Record record = fetchResult.recordResult.record;
           if (!record.family.equals(columnFamily)) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9573afbb/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
----------------------------------------------------------------------
diff --git a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
index 662864f..2422609 100644
--- a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
+++ b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
@@ -139,7 +139,7 @@ public class BlurResultSetRows extends AbstractBlurResultSet {
       displayRowsPosition = 0;
       final BlurResult result = results.results.get(resultPosition);
       try {
-        selector.setLocationId(result.getLocationId());
+        selector.setRowId(result.getFetchResult().getRowResult().getRow().getId());
         fetchResult = client.fetchRow(tableName, selector);
         Row row = fetchResult.rowResult.row;
         String rowId = row.id;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9573afbb/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
----------------------------------------------------------------------
diff --git a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
index 274e16d..eed24a2 100644
--- a/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
+++ b/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
@@ -66,7 +66,7 @@ public class BlurStatement extends AbstractBlurStatement {
   public ResultSet getResultSet() throws SQLException {
     try {
       System.out.println(sql);
-      Iface client = BlurClient.getClient(connection.getHost() + ":" + connection.getPort());
+      Iface client = BlurClient.getClient(connection.getConnectionString());
       Parser parser = new Parser();
       parser.parse(sql);
       if (isSuperQuery(parser, client)) {


Mime
View raw message