incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [3/10] Trying to clean up and fix the jdbc driver, also moved it to a contrib folder.
Date Tue, 29 Jan 2013 01:47:44 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/parser/Parser.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/parser/Parser.java b/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/parser/Parser.java
deleted file mode 100644
index c8b7287..0000000
--- a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/parser/Parser.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package org.apache.blur.jdbc.parser;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Parser {
-
-  private static final String SELECT = "select";
-  private static final String WHERE = "where";
-  private static final String NATURAL = "natural";
-  private static final String FROM = "from";
-  private static final String JOIN = "join";
-  private static final String SEP = new String(new char[] { 1 });
-
-  public static void main(String[] args) {
-    // System.out.println(new
-    // Parser().parse("select * from table where query('person.pn:(nice cool)')"));
-    // System.out.println(new
-    // Parser().parse("select * from table natural join table2 where person.pn = 'coandol''s' and jon='asdndandanda' And person.pf ='niorce' or nice = 'be'"));
-    // System.out.println(new
-    // Parser().parse("select * from table where person.pn = 'coandol''s' and jon='asdndandanda' And person.pf ='niorce' or nice = 'be'"));
-    System.out.println(new Parser().parse("SELECT * FROM TEST_TABLE T WHERE 1 = 0"));
-    System.out.println(new Parser().parse("select * from table t where 1 = 0"));
-    // System.out.println(new
-    // Parser().parse("select id,locationid,score,cf1.* from table where query('+person.pn:(nice cool) AND cool.a:nice')"));
-  }
-
-  private String where;
-  private String tableName;
-  private List<String> columnNames;
-  private String joinTable;
-
-  public Parser parse(String query) {
-    columnNames = getColumnNames(query);
-    tableName = getTableName(query);
-    where = getWhere(query);
-    joinTable = getJoin(query);
-    return this;
-  }
-
-  public String getJoinTable() {
-    return joinTable;
-  }
-
-  private String getJoin(String query) {
-    String table = null;
-    StringTokenizer tokenizer = new StringTokenizer(query);
-    while (tokenizer.hasMoreTokens()) {
-      if (NATURAL.equals(tokenizer.nextToken().toLowerCase())) {
-        if (JOIN.equals(tokenizer.nextToken().toLowerCase())) {
-          table = tokenizer.nextToken();
-        } else {
-          throw new RuntimeException();
-        }
-      }
-    }
-    return table;
-  }
-
-  private String getWhere(String query) {
-    StringBuilder result = new StringBuilder();
-    StringTokenizer tokenizer = new StringTokenizer(query);
-    while (tokenizer.hasMoreTokens()) {
-      if (WHERE.equals(tokenizer.nextToken().toLowerCase())) {
-        while (tokenizer.hasMoreTokens()) {
-          String token = tokenizer.nextToken();
-          result.append(token).append(' ');
-        }
-      }
-    }
-    return getQuery(result.toString().trim());
-  }
-
-  private String getQuery(String query) {
-    Pattern p = Pattern.compile("([qQ][uU][eE][rR][yY]\\s*\\(\\s*')(.*)('\\s*\\).*)");
-    Matcher matcher = p.matcher(query);
-    if (matcher.find()) {
-      if (matcher.groupCount() != 3) {// first one is the whole string
-        throw new RuntimeException("malformed query [" + query + "]");
-      }
-      return matcher.group(2);// 2nd group is the lucene query
-    } else {
-      return changeQueryToLucene(query);
-    }
-  }
-
-  private String changeQueryToLucene(String query) {
-    query = fixAndsOrs(query);
-    query = query.replaceAll("\\s*=\\s*", ":");
-    query = query.replace("''", SEP);
-    query = query.replaceAll("'", "");
-    query = query.replace(SEP, "'");
-    return query;
-  }
-
-  private String fixAndsOrs(String query) {
-    query = fixToUpperToken(query, "AND");
-    query = fixToUpperToken(query, "OR");
-    return query;
-  }
-
-  private String fixToUpperToken(String query, String token) {
-    String queryUpper = query.toUpperCase();
-    int start = 0;
-    int index = queryUpper.indexOf(token, start);
-    while (index != -1) {
-      if (!query.substring(index, index + token.length()).equals(token)) {
-        String everythingInStringToCurrentPosition = query.substring(0, index);
-        if (!isHitInParameter(everythingInStringToCurrentPosition)) {
-          query = query.substring(0, index) + token + query.substring(index + token.length());
-          return fixToUpperToken(query, token);
-        }
-      }
-      start = index + 1;
-      index = queryUpper.indexOf(token, start);
-    }
-    return query;
-  }
-
-  private boolean isHitInParameter(String everythingInStringToCurrentPosition) {
-    char[] charArray = everythingInStringToCurrentPosition.toCharArray();
-    int count = 0;
-    for (int i = 0; i < charArray.length; i++) {
-      if (charArray[i] == '\'') {
-        count++;
-      }
-    }
-    return count % 2 != 0;
-  }
-
-  private String getTableName(String query) {
-    StringTokenizer tokenizer = new StringTokenizer(query);
-    while (tokenizer.hasMoreTokens()) {
-      if (FROM.equals(tokenizer.nextToken().toLowerCase())) {
-        if (tokenizer.hasMoreTokens()) {
-          return tokenizer.nextToken();
-        }
-      }
-    }
-    throw new IllegalArgumentException("Table not found");
-  }
-
-  private List<String> getColumnNames(String query) {
-    StringTokenizer tokenizer = new StringTokenizer(query);
-    List<String> columnNames = new ArrayList<String>();
-    while (tokenizer.hasMoreTokens()) {
-      if (SELECT.equals(tokenizer.nextToken().toLowerCase())) {
-        while (tokenizer.hasMoreTokens()) {
-          String token = tokenizer.nextToken().toLowerCase();
-          if (FROM.equals(token)) {
-            return columnNames;
-          }
-          processColumnToken(columnNames, token);
-        }
-      }
-    }
-    return null;
-  }
-
-  private void processColumnToken(List<String> columnNames, String token) {
-    StringTokenizer tokenizer = new StringTokenizer(token, ",");
-    while (tokenizer.hasMoreTokens()) {
-      columnNames.add(tokenizer.nextToken());
-    }
-  }
-
-  public String getTableName() {
-    return tableName;
-  }
-
-  public List<String> getColumnNames() {
-    return columnNames;
-  }
-
-  public String getWhere() {
-    if (where == null || where.trim().isEmpty()) {
-      return "*";
-    }
-    return where;
-  }
-
-  @Override
-  public String toString() {
-    return "Parser [columnNames=" + columnNames + ", tableName=" + tableName + ", where=" + where + ", joinTable=" + joinTable + "]";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSet.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSet.java b/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSet.java
deleted file mode 100644
index 1483a6b..0000000
--- a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSet.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.blur.jdbc.util;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSet;
-
-
-public class EmptyResultSet extends AbstractBlurResultSet {
-
-  @Override
-  public void close() throws SQLException {
-
-  }
-
-  @Override
-  public boolean next() throws SQLException {
-    return false;
-  }
-
-  @Override
-  public ResultSetMetaData getMetaData() throws SQLException {
-    return new EmptyResultSetMetaData();
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSetMetaData.java b/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSetMetaData.java
deleted file mode 100644
index 0a0c7ab..0000000
--- a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/EmptyResultSetMetaData.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.apache.blur.jdbc.util;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSetMetaData;
-
-
-public class EmptyResultSetMetaData extends AbstractBlurResultSetMetaData implements ResultSetMetaData {
-
-  @Override
-  public int getColumnCount() throws SQLException {
-    return 0;
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/NotImplemented.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/NotImplemented.java b/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/NotImplemented.java
deleted file mode 100644
index cec34ab..0000000
--- a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/NotImplemented.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.apache.blur.jdbc.util;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-public class NotImplemented extends RuntimeException {
-
-  public static final String BLUR_JDBC_DEBUG = "blur.jdbc.debug";
-  private static final long serialVersionUID = 4736975316647139778L;
-  public static final boolean debug = Boolean.getBoolean(BLUR_JDBC_DEBUG);
-
-  public NotImplemented() {
-    this(null);
-  }
-
-  public NotImplemented(String name) {
-    if (debug) {
-      if (name != null) {
-        System.err.println("Method [" + name + "]");
-      }
-      new Throwable().printStackTrace();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/SimpleStringResultSet.java
----------------------------------------------------------------------
diff --git a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/SimpleStringResultSet.java b/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/SimpleStringResultSet.java
deleted file mode 100644
index eff7797..0000000
--- a/src/blur-jdbc/src/main/java/org/apache/blur/jdbc/util/SimpleStringResultSet.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.apache.blur.jdbc.util;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSet;
-import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSetMetaData;
-
-
-public class SimpleStringResultSet extends AbstractBlurResultSet {
-
-  private List<String> columnNames;
-  private List<Map<String, String>> data;
-  private int position = -1;
-  private String lastValue;
-
-  public SimpleStringResultSet(List<String> columnNames, List<Map<String, String>> data) {
-    this.columnNames = columnNames;
-    this.data = data;
-  }
-
-  @Override
-  public ResultSetMetaData getMetaData() throws SQLException {
-    return new SimpleStringResultSetMetaData(columnNames);
-  }
-
-  @Override
-  public boolean next() throws SQLException {
-    if (position + 1 >= data.size()) {
-      return false;
-    }
-    position++;
-    return true;
-  }
-
-  @Override
-  public String getString(int columnIndex) throws SQLException {
-    String name = columnNames.get(columnIndex - 1);
-    Map<String, String> row = data.get(position);
-    return lastValue = row.get(name);
-  }
-
-  @Override
-  public boolean wasNull() throws SQLException {
-    return lastValue == null ? true : false;
-  }
-
-  @Override
-  public void close() throws SQLException {
-
-  }
-
-  public static class SimpleStringResultSetMetaData extends AbstractBlurResultSetMetaData {
-
-    private List<String> columnNames;
-
-    public SimpleStringResultSetMetaData(List<String> columnNames) {
-      this.columnNames = columnNames;
-    }
-
-    @Override
-    public int getColumnCount() throws SQLException {
-      return columnNames.size();
-    }
-
-    @Override
-    public String getColumnName(int column) throws SQLException {
-      return columnNames.get(column - 1);
-    }
-
-    @Override
-    public int getColumnType(int column) throws SQLException {
-      return Types.VARCHAR;
-    }
-
-    @Override
-    public String getColumnTypeName(int column) throws SQLException {
-      return "string";
-    }
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/blur-thrift/src/main/java/org/apache/blur/thrift/BlurThriftUtil.java
----------------------------------------------------------------------
diff --git a/src/blur-thrift/src/main/java/org/apache/blur/thrift/BlurThriftUtil.java b/src/blur-thrift/src/main/java/org/apache/blur/thrift/BlurThriftUtil.java
new file mode 100644
index 0000000..996c897
--- /dev/null
+++ b/src/blur-thrift/src/main/java/org/apache/blur/thrift/BlurThriftUtil.java
@@ -0,0 +1,20 @@
+package org.apache.blur.thrift;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.blur.thrift.generated.ScoreDoc;
+import org.apache.blur.thrift.generated.TopFieldDocs;
+
+public class BlurThriftUtil {
+
+  public static List<Long> toDocLocations(TopFieldDocs topFieldDocs) {
+    List<ScoreDoc> scoreDocs = topFieldDocs.getScoreDocs();
+    List<Long> docLocations = new ArrayList<Long>();
+    for (ScoreDoc scoreDoc : scoreDocs) {
+      docLocations.add(scoreDoc.getDocLocation());
+    }
+    return docLocations;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/jar.sh
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/jar.sh b/src/contrib/blur-jdbc/jar.sh
new file mode 100755
index 0000000..e2f70ae
--- /dev/null
+++ b/src/contrib/blur-jdbc/jar.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+mvn assembly:assembly -DdescriptorId=jar-with-dependencies

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/pom.xml b/src/contrib/blur-jdbc/pom.xml
new file mode 100644
index 0000000..d6fed70
--- /dev/null
+++ b/src/contrib/blur-jdbc/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.blur</groupId>
+		<artifactId>blur</artifactId>
+		<version>0.2.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+	</parent>
+	<groupId>org.apache.blur</groupId>
+	<artifactId>blur-jdbc</artifactId>
+	<packaging>jar</packaging>
+	<name>Blur JDBC</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-thrift</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.blur</groupId>
+			<artifactId>blur-util</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.15</version>
+			<scope>provided</scope>
+			<exclusions>
+				<exclusion>
+					<groupId>javax.mail</groupId>
+					<artifactId>mail</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.jms</groupId>
+					<artifactId>jms</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jdmk</groupId>
+					<artifactId>jmxtools</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jmx</groupId>
+					<artifactId>jmxri</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-dependency-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>copy-dependencies</id>
+						<phase>package</phase>
+						<goals>
+							<goal>copy-dependencies</goal>
+						</goals>
+						<configuration>
+							<outputDirectory>${project.build.directory}/../../../lib
+							</outputDirectory>
+							<overWriteReleases>false</overWriteReleases>
+							<overWriteSnapshots>false</overWriteSnapshots>
+							<overWriteIfNewer>true</overWriteIfNewer>
+							<excludeTransitive>true</excludeTransitive>
+							<excludeArtifactIds>junit,commons-cli,commons-logging,hadoop-core,slf4j-api,slf4j-log4j12</excludeArtifactIds>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+
+				<executions>
+					<execution>
+						<id>make-assembly</id>
+						<phase>package</phase>
+						<goals>
+							<goal>attached</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
new file mode 100644
index 0000000..2ba3500
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurConnection.java
@@ -0,0 +1,118 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurConnection;
+
+
+public class BlurConnection extends AbstractBlurConnection {
+
+  private boolean closed;
+  private int port;
+  private String host;
+  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;
+    this.catalog = catalog;
+    this.url = url;
+    this.username = username;
+  }
+
+  @Override
+  public void close() throws SQLException {
+
+  }
+
+  @Override
+  public String getCatalog() throws SQLException {
+    return catalog;
+  }
+
+  @Override
+  public DatabaseMetaData getMetaData() throws SQLException {
+    return new BlurDatabaseMetaData(url, username, host, port);
+  }
+
+  @Override
+  public Statement createStatement() throws SQLException {
+    return new BlurStatement(this);
+  }
+
+  @Override
+  public PreparedStatement prepareStatement(String sql) throws SQLException {
+    return new BlurPreparedStatement(this, sql);
+  }
+
+  @Override
+  public boolean getAutoCommit() throws SQLException {
+    return false;
+  }
+
+  @Override
+  public SQLWarning getWarnings() throws SQLException {
+    return new BlurWarnings();
+  }
+
+  @Override
+  public boolean isClosed() throws SQLException {
+    return closed;
+  }
+
+  @Override
+  public boolean isReadOnly() throws SQLException {
+    return true;
+  }
+
+  @Override
+  public void setAutoCommit(boolean arg0) throws SQLException {
+
+  }
+
+  @Override
+  public void clearWarnings() throws SQLException {
+
+  }
+
+  @Override
+  public void rollback() throws SQLException {
+
+  }
+
+  public int getPort() {
+    return port;
+  }
+
+  public String getHost() {
+    return host;
+  }
+
+  @Override
+  public int getTransactionIsolation() throws SQLException {
+    return TRANSACTION_NONE;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
new file mode 100644
index 0000000..e4136c4
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurDatabaseMetaData.java
@@ -0,0 +1,415 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurDatabaseMetaData;
+import org.apache.blur.jdbc.util.EmptyResultSet;
+import org.apache.blur.jdbc.util.SimpleStringResultSet;
+import org.apache.blur.thrift.BlurClientManager;
+import org.apache.blur.thrift.commands.BlurCommand;
+import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.Session;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.blur.thrift.generated.TableSchema;
+import org.apache.thrift.TException;
+
+public class BlurDatabaseMetaData extends AbstractBlurDatabaseMetaData {
+
+  private static final String REF_GENERATION = "REF_GENERATION";
+  private static final String SELF_REFERENCING_COL_NAME = "SELF_REFERENCING_COL_NAME";
+  private static final String TYPE_NAME = "TYPE_NAME";
+  private static final String TYPE_SCHEM = "TYPE_SCHEM";
+  private static final String TYPE_CAT = "TYPE_CAT";
+  private static final String REMARKS = "REMARKS";
+  private static final String TABLE_TYPE = "TABLE_TYPE";
+  private static final String TABLE_NAME = "TABLE_NAME";
+  private static final String TABLE_SCHEM = "TABLE_SCHEM";
+  private static final String TABLE_CAT = "TABLE_CAT";
+  private static final String TABLE_CATALOG = "TABLE_CATALOG";
+
+  private int minorVersion = 1;
+  private int majorVersion = 1;
+  private String url;
+  private String username;
+  private int port;
+  private String host;
+  private Map<String, TableSchema> schemaMap = new TreeMap<String, TableSchema>();
+
+  public BlurDatabaseMetaData(String url, String username, String host, int port) {
+    this.url = url;
+    this.username = username;
+    this.host = host;
+    this.port = port;
+    try {
+      BlurClientManager.execute(this.host + ":" + this.port, new BlurCommand<Void>() {
+
+        @Override
+        public Void call(Client client) throws BlurException, TException {
+          List<String> tables = client.tableList();
+          for (String table : tables) {
+            TableDescriptor descriptor = client.describe(table);
+            if (descriptor.isEnabled()) {
+              Session session = client.openReadSession(table);
+              schemaMap.put(table, client.schema(session));
+              client.closeReadSession(session);
+            }
+          }
+          return null;
+        }
+      });
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  @Override
+  public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException {
+    return super.getBestRowIdentifier(catalog, schema, table, scope, nullable);
+  }
+
+  @Override
+  public ResultSet getSchemas() throws SQLException {
+    List<Map<String, String>> data = new ArrayList<Map<String, String>>();
+    for (Entry<String,TableSchema> entry : schemaMap.entrySet()) {
+      Map<String, String> row = new HashMap<String, String>();
+      row.put(TABLE_SCHEM, entry.getKey());
+      data.add(row);
+    }
+    return new SimpleStringResultSet(Arrays.asList(TABLE_SCHEM, TABLE_CATALOG), data);
+  }
+
+  @Override
+  public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
+    List<Map<String, String>> data = new ArrayList<Map<String, String>>();
+    for (Entry<String,TableSchema> entry : schemaMap.entrySet()) {
+      String table = entry.getKey();
+      TableSchema schema = schemaMap.get(table);
+      addTableRow(data, schema.getCluster(), table);
+    }
+    return new TableDescriptorResultSet(data);
+  }
+
+  @Override
+  public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  private void addTableRow(List<Map<String, String>> data, String schem, String table) {
+    Map<String, String> row = new HashMap<String, String>();
+    row.put(TABLE_SCHEM, schem);
+    row.put(TABLE_NAME, table);
+    row.put(TABLE_TYPE, "TABLE");
+    row.put(REMARKS, "");
+    data.add(row);
+  }
+
+  public static class TableDescriptorResultSet extends SimpleStringResultSet {
+    private static final List<String> COL_NAMES = Arrays.asList(TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE, REMARKS, TYPE_CAT, TYPE_SCHEM, TYPE_NAME,
+        SELF_REFERENCING_COL_NAME, REF_GENERATION);
+
+    public TableDescriptorResultSet(List<Map<String, String>> data) {
+      super(COL_NAMES, data);
+    }
+  }
+
+  @Override
+  public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public String getSQLKeywords() throws SQLException {
+    return "";
+  }
+
+  public int getDefaultTransactionIsolation() throws SQLException {
+    return Connection.TRANSACTION_NONE;
+  }
+
+  public ResultSet getTableTypes() throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  public String getDatabaseProductName() throws SQLException {
+    return "blur";
+  }
+
+  public String getCatalogSeparator() throws SQLException {
+    return ",";
+  }
+
+  public String getDriverName() throws SQLException {
+    return "blur";
+  }
+
+  public String getDriverVersion() throws SQLException {
+    return "0.1";
+  }
+
+  public String getIdentifierQuoteString() throws SQLException {
+    return "'";
+  }
+
+  @Override
+  public String getDatabaseProductVersion() throws SQLException {
+    return "0.1";
+  }
+
+  @Override
+  public ResultSet getCatalogs() throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public ResultSet getClientInfoProperties() throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public RowIdLifetime getRowIdLifetime() throws SQLException {
+    return RowIdLifetime.ROWID_UNSUPPORTED;
+  }
+
+  @Override
+  public int getSQLStateType() throws SQLException {
+    return sqlStateSQL;
+  }
+
+  @Override
+  public int getJDBCMajorVersion() throws SQLException {
+    return majorVersion;
+  }
+
+  @Override
+  public int getJDBCMinorVersion() throws SQLException {
+    return minorVersion;
+  }
+
+  @Override
+  public int getDatabaseMajorVersion() throws SQLException {
+    return majorVersion;
+  }
+
+  @Override
+  public int getDatabaseMinorVersion() throws SQLException {
+    return minorVersion;
+  }
+
+  @Override
+  public int getResultSetHoldability() throws SQLException {
+    return ResultSet.CLOSE_CURSORS_AT_COMMIT;
+  }
+
+  @Override
+  public int getMaxTablesInSelect() throws SQLException {
+    return 1;
+  }
+
+  @Override
+  public int getMaxUserNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public String getTimeDateFunctions() throws SQLException {
+    return "";
+  }
+
+  @Override
+  public int getMaxStatementLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxStatements() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxTableNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxRowSize() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public String getStringFunctions() throws SQLException {
+    return "";
+  }
+
+  @Override
+  public int getMaxCatalogNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxProcedureNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxSchemaNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public String getCatalogTerm() throws SQLException {
+    return "catalog";
+  }
+
+  @Override
+  public int getDriverMajorVersion() {
+    return majorVersion;
+  }
+
+  @Override
+  public int getDriverMinorVersion() {
+    return minorVersion;
+  }
+
+  @Override
+  public String getExtraNameCharacters() throws SQLException {
+    return ".";
+  }
+
+  @Override
+  public int getMaxBinaryLiteralLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxCharLiteralLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxColumnNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxColumnsInGroupBy() throws SQLException {
+    return 0;
+  }
+
+  @Override
+  public int getMaxColumnsInIndex() throws SQLException {
+    return 0;
+  }
+
+  @Override
+  public int getMaxColumnsInOrderBy() throws SQLException {
+    return 0;
+  }
+
+  @Override
+  public int getMaxColumnsInSelect() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxColumnsInTable() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxConnections() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxCursorNameLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public int getMaxIndexLength() throws SQLException {
+    return Integer.MAX_VALUE;
+  }
+
+  @Override
+  public String getNumericFunctions() throws SQLException {
+    return "";
+  }
+
+  @Override
+  public String getProcedureTerm() throws SQLException {
+    return "procedure";
+  }
+
+  @Override
+  public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public String getSchemaTerm() throws SQLException {
+    return "schema";
+  }
+
+  @Override
+  public String getSearchStringEscape() throws SQLException {
+    return "\\";
+  }
+
+  @Override
+  public ResultSet getTypeInfo() throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public String getURL() throws SQLException {
+    return url;
+  }
+
+  @Override
+  public String getUserName() throws SQLException {
+    return username;
+  }
+
+  @Override
+  public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
+    return new EmptyResultSet();
+  }
+
+  @Override
+  public String getSystemFunctions() throws SQLException {
+    return "";
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
new file mode 100644
index 0000000..bb099c0
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurJdbc.java
@@ -0,0 +1,88 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+public class BlurJdbc implements Driver {
+
+  static {
+    try {
+      java.sql.DriverManager.registerDriver(new BlurJdbc());
+    } catch (SQLException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  @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;
+      }
+    }
+    return false;
+  }
+
+  @Override
+  public Connection connect(String url, Properties info) throws SQLException {
+    // jdbc:blur:host:port
+    String username = "";
+    String[] split = url.split(":");
+    if (split.length != 4) {
+      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 + "]");
+  }
+
+  @Override
+  public int getMajorVersion() {
+    return 1;
+  }
+
+  @Override
+  public int getMinorVersion() {
+    return 0;
+  }
+
+  @Override
+  public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+    return null;
+  }
+
+  @Override
+  public boolean jdbcCompliant() {
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurPreparedStatement.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurPreparedStatement.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurPreparedStatement.java
new file mode 100644
index 0000000..1e796db
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurPreparedStatement.java
@@ -0,0 +1,45 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurPreparedStatement;
+
+
+public class BlurPreparedStatement extends AbstractBlurPreparedStatement {
+
+  private BlurStatement blurStatement;
+  private String sql;
+
+  public BlurPreparedStatement(BlurConnection connection, String sql) {
+    this.sql = sql;
+    blurStatement = new BlurStatement(connection);
+  }
+
+  @Override
+  public boolean execute() throws SQLException {
+    return blurStatement.execute(sql);
+  }
+
+  @Override
+  public ResultSet getResultSet() throws SQLException {
+    return blurStatement.getResultSet();
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetDocuments.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetDocuments.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetDocuments.java
new file mode 100644
index 0000000..42c1a1f
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetDocuments.java
@@ -0,0 +1,118 @@
+package org.apache.blur.jdbc;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSet;
+import org.apache.blur.jdbc.parser.Parser;
+import org.apache.blur.thrift.generated.Blur.Iface;
+
+public class BlurResultSetDocuments extends AbstractBlurResultSet {
+
+  public BlurResultSetDocuments(Iface client, Parser parser) {
+    
+  }
+
+  @Override
+  public boolean next() throws SQLException {
+    return super.next();
+  }
+
+
+  @Override
+  public boolean wasNull() throws SQLException {
+    // TODO Auto-generated method stub
+    return super.wasNull();
+  }
+
+  @Override
+  public void close() throws SQLException {
+
+  }
+
+  @Override
+  public SQLWarning getWarnings() throws SQLException {
+    return new BlurWarnings();
+  }
+  
+  @Override
+  public ResultSetMetaData getMetaData() throws SQLException {
+    return null;
+  }
+  
+  @Override
+  public double getDouble(int columnIndex) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getDouble(columnIndex);
+  }
+
+  @Override
+  public double getDouble(String columnLabel) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getDouble(columnLabel);
+  }
+
+  @Override
+  public float getFloat(int columnIndex) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getFloat(columnIndex);
+  }
+
+  @Override
+  public float getFloat(String columnLabel) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getFloat(columnLabel);
+  }
+
+  @Override
+  public int getInt(int columnIndex) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getInt(columnIndex);
+  }
+
+  @Override
+  public int getInt(String columnLabel) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getInt(columnLabel);
+  }
+
+  @Override
+  public long getLong(int columnIndex) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getLong(columnIndex);
+  }
+
+  @Override
+  public long getLong(String columnLabel) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getLong(columnLabel);
+  }
+
+  @Override
+  public short getShort(int columnIndex) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getShort(columnIndex);
+  }
+
+  @Override
+  public short getShort(String columnLabel) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getShort(columnLabel);
+  }
+
+  @Override
+  public String getString(int columnIndex) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getString(columnIndex);
+  }
+
+  @Override
+  public String getString(String columnLabel) throws SQLException {
+    // TODO Auto-generated method stub
+    return super.getString(columnLabel);
+  }
+
+  
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetMetaData.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetMetaData.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetMetaData.java
new file mode 100644
index 0000000..f1b9c8d
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetMetaData.java
@@ -0,0 +1,228 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSetMetaData;
+
+
+public class BlurResultSetMetaData extends AbstractBlurResultSetMetaData {
+
+  public static final String RECORDID = "recordid";
+  public static final String FAMILY = "family";
+  public static final String LOCATIONID = "locationid";
+  public static final String SCORE = "score";
+  public static final String ROWID = "rowid";
+
+  public enum QUERY_COLUMN_TYPE {
+    ALL_COLUMNS, ALL_COLUMNS_IN_CF, ONE_COLUMN_IN_CF, ONE_COLUMN_IN_SYSTEM
+  }
+
+  public static Collection<String> systemCols;
+  private List<String> sqlColumnNames;
+  private String tableName;
+  private Map<String, Set<String>> columnFamilies;
+
+  static {
+    systemCols = new HashSet<String>();
+    systemCols.add(ROWID);
+    systemCols.add(SCORE);
+    systemCols.add(LOCATIONID);
+    systemCols.add(FAMILY);
+    systemCols.add(RECORDID);
+  }
+
+  public BlurResultSetMetaData(List<String> queryColumnNames, Map<String, Set<String>> columnFamilies) {
+    this.columnFamilies = columnFamilies;
+    this.sqlColumnNames = new ArrayList<String>();
+    this.sqlColumnNames.add(null);
+    for (String queryColumnName : queryColumnNames) {
+      addReturnColumns(queryColumnName);
+    }
+  }
+
+  private void addReturnColumns(String queryColumnName) {
+    String col = queryColumnName.trim();
+    if ("*".equals(col)) {
+      addAllColumns();
+      return;
+    }
+    int index = col.indexOf('.');
+    if (index < 0) {
+      addSystemColumn(col);
+      return;
+    }
+    String columnFamily = col.substring(0, index);
+    String columnName = col.substring(index + 1);
+    if ("*".equals(columnName)) {
+      addColumnFamily(columnFamily);
+      return;
+    }
+    addColumn(columnFamily, columnName);
+  }
+
+  private void addColumn(String columnFamily, String columnName) {
+    sqlColumnNames.add(columnFamily + "." + columnName);
+  }
+
+  private void addColumnFamily(String columnFamily) {
+    Set<String> columns = columnFamilies.get(columnFamily);
+    if (columns == null) {
+      throw new RuntimeException("Column family [" + columnFamily + "] not found.");
+    }
+    for (String columnName : columns) {
+      addColumn(columnFamily, columnName);
+    }
+  }
+
+  private void addSystemColumn(String col) {
+    String lcCol = col.toLowerCase();
+    if (systemCols.contains(lcCol)) {
+      sqlColumnNames.add(lcCol);
+      return;
+    }
+    throw new RuntimeException("System column [" + col + "] not found.");
+  }
+
+  private void addAllColumns() {
+    sqlColumnNames.add(ROWID);
+    sqlColumnNames.add(FAMILY);
+    sqlColumnNames.add(RECORDID);
+    Map<String, Set<String>> columnFamilies = new TreeMap<String, Set<String>>(this.columnFamilies);
+    for (String family : columnFamilies.keySet()) {
+      Set<String> columnNames = columnFamilies.get(family);
+      for (String columnName : columnNames) {
+        sqlColumnNames.add(family + "." + columnName);
+      }
+    }
+  }
+
+  @Override
+  public String getColumnClassName(int column) throws SQLException {
+    return "java.lang.String";
+  }
+
+  @Override
+  public int getColumnType(int column) throws SQLException {
+    return Types.VARCHAR;
+  }
+
+  @Override
+  public int getColumnCount() throws SQLException {
+    return sqlColumnNames.size() - 1;
+  }
+
+  @Override
+  public String getColumnName(int column) throws SQLException {
+    return sqlColumnNames.get(column);
+  }
+
+  @Override
+  public String getColumnTypeName(int column) throws SQLException {
+    return "string";
+  }
+
+  @Override
+  public int getPrecision(int column) throws SQLException {
+    return 4000;
+  }
+
+  @Override
+  public int getScale(int column) throws SQLException {
+    return 0;
+  }
+
+  @Override
+  public String getCatalogName(int column) throws SQLException {
+    return "";
+  }
+
+  @Override
+  public String getSchemaName(int column) throws SQLException {
+    return "";
+  }
+
+  @Override
+  public String getTableName(int column) throws SQLException {
+    return tableName;
+  }
+
+  @Override
+  public int isNullable(int column) throws SQLException {
+    return ResultSetMetaData.columnNullable;
+  }
+
+  @Override
+  public int getColumnDisplaySize(int column) throws SQLException {
+    return 100;
+  }
+
+  @Override
+  public String getColumnLabel(int column) throws SQLException {
+    return getColumnName(column);
+  }
+
+  @Override
+  public boolean isAutoIncrement(int column) throws SQLException {
+    return false;
+  }
+
+  @Override
+  public boolean isCaseSensitive(int column) throws SQLException {
+    return true;
+  }
+
+  @Override
+  public boolean isCurrency(int column) throws SQLException {
+    return false;
+  }
+
+  @Override
+  public boolean isDefinitelyWritable(int column) throws SQLException {
+    return false;
+  }
+
+  @Override
+  public boolean isReadOnly(int column) throws SQLException {
+    return true;
+  }
+
+  @Override
+  public boolean isSearchable(int column) throws SQLException {
+    return true;
+  }
+
+  @Override
+  public boolean isSigned(int column) throws SQLException {
+    return false;
+  }
+
+  @Override
+  public boolean isWritable(int column) throws SQLException {
+    return false;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
new file mode 100644
index 0000000..c7c54cb
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRecords.java
@@ -0,0 +1,247 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import static org.apache.blur.jdbc.BlurResultSetMetaData.FAMILY;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.LOCATIONID;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.RECORDID;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.ROWID;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.SCORE;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSet;
+import org.apache.blur.jdbc.parser.Parser;
+import org.apache.blur.thrift.generated.BlurException;
+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.FetchResult;
+import org.apache.blur.thrift.generated.Record;
+import org.apache.blur.thrift.generated.Schema;
+import org.apache.blur.thrift.generated.Selector;
+import org.apache.blur.thrift.generated.SimpleQuery;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.thrift.TException;
+
+
+public class BlurResultSetRecords extends AbstractBlurResultSet {
+
+  private Selector selector;
+  private BlurResults results;
+  private int resultPosition = -1;
+  private int size;
+  private String tableName;
+  private FetchResult fetchResult;
+  private BlurResultSetMetaData blurResultSetMetaData;
+  private String lastValue;
+  private List<List<String>> displayRows = new ArrayList<List<String>>();
+  private int displayRowsPosition;
+  private Schema schema;
+  private final Iface client;
+  private long totalResults;
+  private int overallRowPosition;
+  private int currentFetch;
+  private int currentStart;
+  private Parser parser;
+  private List<String> columnNames;
+  private String columnFamily;
+
+  public BlurResultSetRecords(Iface client, Parser parser) throws SQLException {
+    this.client = client;
+    this.parser = parser;
+    String tName = parser.getTableName();
+    int lastIndexOf = tName.lastIndexOf('.');
+    tableName = tName.substring(0, lastIndexOf);
+    columnFamily = tName.substring(lastIndexOf + 1);
+    columnNames = parser.getColumnNames();
+    runSearch(0, 100);
+  }
+
+  private void runSearch(int start, int fetch) throws SQLException {
+    currentStart = start;
+    currentFetch = fetch;
+    BlurQuery blurQuery = new BlurQuery();
+    blurQuery.minimumNumberOfResults = Long.MAX_VALUE;
+    blurQuery.maxQueryTime = Long.MAX_VALUE;
+    blurQuery.uuid = new Random().nextLong();
+    blurQuery.fetch = fetch;
+    blurQuery.start = start;
+    blurQuery.simpleQuery = new SimpleQuery();
+    blurQuery.simpleQuery.queryStr = parser.getWhere();
+    blurQuery.simpleQuery.superQueryOn = false;
+
+    try {
+      schema = client.schema(tableName);
+    } catch (BlurException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    } catch (TException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    }
+
+    selector = new Selector();
+    setupSelector(selector, schema, columnNames);
+    selector.recordOnly = !blurQuery.simpleQuery.superQueryOn;
+    Map<String, Set<String>> columnFamilies = schema.columnFamilies;
+    Set<String> cfSet = columnFamilies.get(columnFamily);
+    columnFamilies.clear();
+    columnFamilies.put(columnFamily, cfSet);
+    blurResultSetMetaData = new BlurResultSetMetaData(columnNames, columnFamilies);
+    try {
+      results = client.query(tableName, blurQuery);
+    } catch (BlurException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    } catch (TException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    }
+    if (results.totalResults > 0) {
+      size = results.results.size();
+    }
+    totalResults = results.totalResults;
+  }
+
+  private void setupSelector(Selector selector, Schema schema, List<String> columnNames) {
+
+  }
+
+  @Override
+  public ResultSetMetaData getMetaData() throws SQLException {
+    return blurResultSetMetaData;
+  }
+
+  @Override
+  public boolean next() throws SQLException {
+    if (displayRows != null && displayRowsPosition + 1 < displayRows.size()) {
+      overallRowPosition++;
+      displayRowsPosition++;
+      return true;
+    } else if (resultPosition + 1 < size) {
+      INNER: while (resultPosition + 1 < size) {
+        displayRows.clear();
+        resultPosition++;
+        displayRowsPosition = 0;
+        overallRowPosition++;
+
+        final BlurResult result = results.results.get(resultPosition);
+        try {
+          selector.setLocationId(result.getLocationId());
+          fetchResult = client.fetchRow(tableName, selector);
+          Record record = fetchResult.recordResult.record;
+          if (!record.family.equals(columnFamily)) {
+            continue INNER;
+          }
+          String rowId = fetchResult.recordResult.rowid;
+          displayRows.add(addColumns(result.getScore(), result.getLocationId(), rowId, record.family, record));
+          return true;
+
+        } catch (Exception e) {
+          e.printStackTrace();
+          throw new SQLException(e);
+        }
+      }
+      return next();
+    } else if (overallRowPosition < totalResults) {
+      currentStart += currentFetch;
+      runSearch(currentStart, currentFetch);
+      displayRowsPosition = 0;
+      resultPosition = -1;
+      return next();
+    }
+    return false;
+  }
+
+  private List<String> addColumns(double score, String locationId, String rowId, String family, Record record) throws SQLException {
+    int columnCount = blurResultSetMetaData.getColumnCount();
+    List<String> result = new ArrayList<String>(columnCount + 1);
+    for (int i = 0; i < columnCount + 1; i++) {
+      result.add(null);
+    }
+    for (int i = 1; i <= columnCount; i++) {
+      String columnName = blurResultSetMetaData.getColumnName(i);
+      if (columnName.equals(ROWID)) {
+        result.set(i, rowId);
+      } else if (columnName.equals(SCORE)) {
+        result.set(i, Double.toString(score));
+      } else if (columnName.equals(LOCATIONID)) {
+        result.set(i, locationId);
+      } else if (columnName.equals(FAMILY)) {
+        result.set(i, family);
+      } else if (columnName.equals(RECORDID)) {
+        result.set(i, record.recordId);
+      } else {
+        String value = getValue(record, columnName, family);
+        result.set(i, value);
+      }
+    }
+    return result;
+  }
+
+  private String getValue(Record record, String columnNameWithFamilyName, String family) {
+    int index = columnNameWithFamilyName.indexOf('.');
+    if (family.equals(columnNameWithFamilyName.substring(0, index))) {
+      String columnName = columnNameWithFamilyName.substring(index + 1);
+      List<String> values = new ArrayList<String>();
+      for (Column col : record.columns) {
+        if (columnName.equals(col.getName())) {
+          values.add(col.getValue());
+        }
+      }
+      if (values.size() == 1) {
+        return values.get(0);
+      } else {
+        return values.toString();
+      }
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public String getString(int columnIndex) throws SQLException {
+    return lastValue = displayRows.get(displayRowsPosition).get(columnIndex);
+  }
+
+  @Override
+  public boolean wasNull() throws SQLException {
+    if (lastValue == null) {
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  public void close() throws SQLException {
+
+  }
+
+  @Override
+  public SQLWarning getWarnings() throws SQLException {
+    return new BlurWarnings();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
new file mode 100644
index 0000000..bb2a510
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetRows.java
@@ -0,0 +1,234 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import static org.apache.blur.jdbc.BlurResultSetMetaData.FAMILY;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.LOCATIONID;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.RECORDID;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.ROWID;
+import static org.apache.blur.jdbc.BlurResultSetMetaData.SCORE;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurResultSet;
+import org.apache.blur.jdbc.parser.Parser;
+import org.apache.blur.thrift.generated.BlurException;
+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.FetchResult;
+import org.apache.blur.thrift.generated.Record;
+import org.apache.blur.thrift.generated.Row;
+import org.apache.blur.thrift.generated.Schema;
+import org.apache.blur.thrift.generated.Selector;
+import org.apache.blur.thrift.generated.SimpleQuery;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.thrift.TException;
+
+
+public class BlurResultSetRows extends AbstractBlurResultSet {
+
+  private Selector selector;
+  private BlurResults results;
+  private int resultPosition = -1;
+  private int size;
+  private String tableName;
+  private FetchResult fetchResult;
+  private BlurResultSetMetaData blurResultSetMetaData;
+  private String lastValue;
+  private List<List<String>> displayRows = new ArrayList<List<String>>();
+  private int displayRowsPosition;
+  private Schema schema;
+  private final Iface client;
+  private long totalResults;
+  private int overallRowPosition;
+  private int currentFetch;
+  private int currentStart;
+  private Parser parser;
+  private List<String> columnNames;
+
+  public BlurResultSetRows(Iface client, Parser parser) throws SQLException {
+    this.client = client;
+    this.parser = parser;
+    tableName = parser.getTableName();
+    columnNames = parser.getColumnNames();
+    System.out.println(columnNames);
+    runSearch(0, 100);
+  }
+
+  private void runSearch(int start, int fetch) throws SQLException {
+    currentStart = start;
+    currentFetch = fetch;
+    BlurQuery blurQuery = new BlurQuery();
+    blurQuery.minimumNumberOfResults = Long.MAX_VALUE;
+    blurQuery.maxQueryTime = Long.MAX_VALUE;
+    blurQuery.uuid = new Random().nextLong();
+    blurQuery.fetch = fetch;
+    blurQuery.start = start;
+    blurQuery.simpleQuery = new SimpleQuery();
+    blurQuery.simpleQuery.queryStr = parser.getWhere();
+    blurQuery.simpleQuery.superQueryOn = true;
+
+    try {
+      schema = client.schema(tableName);
+    } catch (BlurException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    } catch (TException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    }
+
+    selector = new Selector();
+    setupSelector(selector, schema, columnNames);
+    selector.recordOnly = !blurQuery.simpleQuery.superQueryOn;
+    blurResultSetMetaData = new BlurResultSetMetaData(columnNames, schema.columnFamilies);
+    try {
+      results = client.query(tableName, blurQuery);
+    } catch (BlurException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    } catch (TException e) {
+      e.printStackTrace();
+      throw new SQLException(e);
+    }
+    if (results.totalResults > 0) {
+      size = results.results.size();
+    }
+    totalResults = results.totalResults;
+  }
+
+  private void setupSelector(Selector selector, Schema schema, List<String> columnNames) {
+
+  }
+
+  @Override
+  public ResultSetMetaData getMetaData() throws SQLException {
+    return blurResultSetMetaData;
+  }
+
+  @Override
+  public boolean next() throws SQLException {
+    if (displayRows != null && displayRowsPosition + 1 < displayRows.size()) {
+      overallRowPosition++;
+      displayRowsPosition++;
+      return true;
+    } else if (resultPosition + 1 < size) {
+      displayRows.clear();
+      resultPosition++;
+      displayRowsPosition = 0;
+      final BlurResult result = results.results.get(resultPosition);
+      try {
+        selector.setLocationId(result.getLocationId());
+        fetchResult = client.fetchRow(tableName, selector);
+        Row row = fetchResult.rowResult.row;
+        String rowId = row.id;
+        List<Record> records = row.records;
+        for (Record record : records) {
+          displayRows.add(addColumns(result.getScore(), result.getLocationId(), rowId, record.family, record));
+        }
+        overallRowPosition++;
+        return true;
+      } catch (Exception e) {
+        e.printStackTrace();
+        throw new SQLException(e);
+      }
+    } else if (overallRowPosition < totalResults) {
+      currentStart += currentFetch;
+      runSearch(currentStart, currentFetch);
+      displayRowsPosition = 0;
+      resultPosition = -1;
+      return next();
+    }
+    return false;
+  }
+
+  private List<String> addColumns(double score, String locationId, String rowId, String family, Record record) throws SQLException {
+    int columnCount = blurResultSetMetaData.getColumnCount();
+    List<String> result = new ArrayList<String>(columnCount + 1);
+    for (int i = 0; i < columnCount + 1; i++) {
+      result.add(null);
+    }
+    for (int i = 1; i <= columnCount; i++) {
+      String columnName = blurResultSetMetaData.getColumnName(i);
+      if (columnName.equals(ROWID)) {
+        result.set(i, rowId);
+      } else if (columnName.equals(SCORE)) {
+        result.set(i, Double.toString(score));
+      } else if (columnName.equals(LOCATIONID)) {
+        result.set(i, locationId);
+      } else if (columnName.equals(FAMILY)) {
+        result.set(i, family);
+      } else if (columnName.equals(RECORDID)) {
+        result.set(i, record.recordId);
+      } else {
+        String value = getValue(record, columnName, family);
+        result.set(i, value);
+      }
+    }
+    return result;
+  }
+
+  private String getValue(Record record, String columnNameWithFamilyName, String family) {
+    int index = columnNameWithFamilyName.indexOf('.');
+    if (family.equals(columnNameWithFamilyName.substring(0, index))) {
+      String columnName = columnNameWithFamilyName.substring(index + 1);
+      List<String> values = new ArrayList<String>();
+      for (Column col : record.columns) {
+        if (columnName.equals(col.getName())) {
+          values.add(col.getValue());
+        }
+      }
+      if (values.size() == 1) {
+        return values.get(0);
+      } else {
+        return values.toString();
+      }
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public String getString(int columnIndex) throws SQLException {
+    return lastValue = displayRows.get(displayRowsPosition).get(columnIndex);
+  }
+
+  @Override
+  public boolean wasNull() throws SQLException {
+    if (lastValue == null) {
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  public void close() throws SQLException {
+
+  }
+
+  @Override
+  public SQLWarning getWarnings() throws SQLException {
+    return new BlurWarnings();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetTest.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetTest.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetTest.java
new file mode 100644
index 0000000..82b5ecd
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurResultSetTest.java
@@ -0,0 +1,50 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.ResultSetMetaData;
+
+import org.apache.blur.jdbc.parser.Parser;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.Blur.Iface;
+
+
+public class BlurResultSetTest {
+
+  public static void main(String[] args) throws Exception {
+    String sql = "select * from test_table";
+
+    Iface client = BlurClient.getClient("127.0.0.1:40020");
+    Parser parser = new Parser();
+    parser.parse(sql);
+
+    BlurResultSetDocuments resultSet = new BlurResultSetDocuments(client, parser);
+    int c = 0;
+    while (resultSet.next()) {
+      System.out.println(c + " ------------------------");
+      ResultSetMetaData metaData = resultSet.getMetaData();
+      int columnCount = metaData.getColumnCount();
+      for (int i = 1; i <= columnCount; i++) {
+        String value = resultSet.getString(i);
+        String name = metaData.getColumnName(i);
+        System.out.println("\t" + name + ":[" + value + "]");
+      }
+      c++;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
new file mode 100644
index 0000000..7e622f0
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurStatement.java
@@ -0,0 +1,139 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.util.List;
+
+import org.apache.blur.jdbc.abstractimpl.AbstractBlurStatement;
+import org.apache.blur.jdbc.parser.Parser;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.thrift.TException;
+
+
+public class BlurStatement extends AbstractBlurStatement {
+
+  private BlurConnection connection;
+  private int maxRows;
+  private String sql;
+
+  public BlurStatement(BlurConnection connection) {
+    this.connection = connection;
+  }
+
+  public int getMaxRows() throws SQLException {
+    return maxRows;
+  }
+
+  public void setMaxRows(int maxRows) throws SQLException {
+    this.maxRows = maxRows;
+  }
+
+  public int getUpdateCount() throws SQLException {
+    return -1;
+  }
+
+  @Override
+  public ResultSet executeQuery(String sql) throws SQLException {
+    execute(sql);
+    return getResultSet();
+  }
+
+  public boolean execute(String sql) throws SQLException {
+    this.sql = sql;
+    return true;
+  }
+
+  public ResultSet getResultSet() throws SQLException {
+    try {
+      System.out.println(sql);
+      Iface client = BlurClient.getClient(connection.getHost() + ":" + connection.getPort());
+      Parser parser = new Parser();
+      parser.parse(sql);
+      if (isSuperQuery(parser, client)) {
+        return new BlurResultSetRows(client, parser);
+      } else {
+        return new BlurResultSetRecords(client, parser);
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw new SQLException("Unknown Error", e);
+    }
+  }
+
+  private boolean isSuperQuery(Parser parser, Iface client) throws BlurException, TException, SQLException {
+    String tableName = parser.getTableName();
+    List<String> tableList = client.tableList();
+    if (tableList.contains(tableName)) {
+      return true;
+    }
+    int lastIndexOf = tableName.lastIndexOf('.');
+    if (tableList.contains(tableName.substring(0, lastIndexOf))) {
+      return false;
+    }
+    throw new SQLException("Table [" + tableName + "] does not exist.");
+  }
+
+  public void addBatch(String s) throws SQLException {
+
+  }
+
+  public void cancel() throws SQLException {
+
+    // @TODO fix this
+
+    // try {
+    // BlurClientManager.execute(connection.getHost() + ":" +
+    // connection.getPort(), new BlurCommand<Void>() {
+    // @Override
+    // public Void call(Client client) throws Exception {
+    // client.cancelQuery(uuid);
+    // return null;
+    // }
+    // });
+    // } catch (Exception e) {
+    // throw new SQLException(e);
+    // }
+  }
+
+  public void clearBatch() throws SQLException {
+
+  }
+
+  public void clearWarnings() throws SQLException {
+
+  }
+
+  public void close() throws SQLException {
+
+  }
+
+  public Connection getConnection() throws SQLException {
+    return connection;
+  }
+
+  public SQLWarning getWarnings() throws SQLException {
+    return new BlurWarnings();
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurWarnings.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurWarnings.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurWarnings.java
new file mode 100644
index 0000000..da31cb6
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/BlurWarnings.java
@@ -0,0 +1,25 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.sql.SQLWarning;
+
+public class BlurWarnings extends SQLWarning {
+
+  private static final long serialVersionUID = 9142092749428230656L;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/2691117a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/QueryData.java
----------------------------------------------------------------------
diff --git a/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/QueryData.java b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/QueryData.java
new file mode 100644
index 0000000..d95049e
--- /dev/null
+++ b/src/contrib/blur-jdbc/src/main/java/org/apache/blur/jdbc/QueryData.java
@@ -0,0 +1,72 @@
+package org.apache.blur.jdbc;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+public class QueryData {
+
+  protected String name;
+  protected String alias;
+
+  public QueryData(String name, String alias) {
+    this.name = name;
+    this.alias = alias;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public String getAlias() {
+    return alias;
+  }
+
+  @Override
+  public String toString() {
+    return "QueryData [name=" + name + ", alias=" + alias + "]";
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((alias == null) ? 0 : alias.hashCode());
+    result = prime * result + ((name == null) ? 0 : name.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    QueryData other = (QueryData) obj;
+    if (alias == null) {
+      if (other.alias != null)
+        return false;
+    } else if (!alias.equals(other.alias))
+      return false;
+    if (name == null) {
+      if (other.name != null)
+        return false;
+    } else if (!name.equals(other.name))
+      return false;
+    return true;
+  }
+}


Mime
View raw message