aboutsummaryrefslogtreecommitdiff
path: root/exec/jdbc
diff options
context:
space:
mode:
authorAditya Kishore <aditya@maprtech.com>2014-09-11 10:43:08 -0700
committerAditya Kishore <aditya@maprtech.com>2014-09-11 19:25:28 -0700
commit676f5df6b14b10ccc3603360e0efee9c745c5b97 (patch)
tree592b02f84e8a6da2ace67f8e6c0e46d4237af20b /exec/jdbc
parent7ae257c42b2eb4e1db778dca9ba64e2516078b38 (diff)
DRILL-1402: Add check-style rules for trailing space, TABs and blocks without braces
Diffstat (limited to 'exec/jdbc')
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java32
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java30
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java17
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/MetaImpl.java34
-rw-r--r--exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestActionBase.java4
-rw-r--r--exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java6
-rw-r--r--exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcDistQuery.java10
-rw-r--r--exec/jdbc/src/test/resources/test-models.json2
8 files changed, 74 insertions, 61 deletions
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
index f4ca79b9b..f31822728 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
@@ -63,40 +63,40 @@ abstract class DrillConnectionImpl extends AvaticaConnection implements org.apac
try{
- if(config.isLocal()){
+ if (config.isLocal()) {
DrillConfig dConfig = DrillConfig.create();
this.allocator = new TopLevelAllocator(dConfig);
RemoteServiceSet set = GlobalServiceSetReference.SETS.get();
- if(set == null){
+ if (set == null) {
// we're embedded, start a local drill bit.
serviceSet = RemoteServiceSet.getLocalServiceSet();
set = serviceSet;
- try{
+ try {
bit = new Drillbit(dConfig, serviceSet);
bit.run();
- }catch(Exception e){
+ } catch (Exception e) {
throw new SQLException("Failure while attempting to start Drillbit in embedded mode.", e);
}
- }else{
+ } else {
serviceSet = null;
bit = null;
}
this.client = new DrillClient(dConfig, set.getCoordinator());
this.client.connect(null, info);
- }else{
+ } else {
DrillConfig dConfig = DrillConfig.createClient();
this.allocator = new TopLevelAllocator(dConfig);
this.client = new DrillClient();
this.client.connect(config.getZookeeperConnectionString(), info);
}
- }catch(RpcException e){
+ } catch (RpcException e) {
throw new SQLException("Failure while attempting to connect to Drill.", e);
}
}
@Override
- public DrillConnectionConfig config(){
+ public DrillConnectionConfig config() {
return config;
}
@@ -109,11 +109,11 @@ abstract class DrillConnectionImpl extends AvaticaConnection implements org.apac
return (MetaImpl) meta;
}
- BufferAllocator getAllocator(){
+ BufferAllocator getAllocator() {
return allocator;
}
- public DrillClient getClient(){
+ public DrillClient getClient() {
return client;
}
@@ -156,15 +156,17 @@ abstract class DrillConnectionImpl extends AvaticaConnection implements org.apac
return factory;
}
- void cleanup(){
+ void cleanup() {
client.close();
allocator.close();
- if(bit != null) bit.close();
+ if (bit != null) {
+ bit.close();
+ }
- if(serviceSet != null){
- try{
+ if (serviceSet != null) {
+ try {
serviceSet.close();
- }catch(IOException e){
+ } catch (IOException e) {
logger.warn("Exception while closing service set.", e);
}
}
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
index 9d4630f7c..bfc1b8a4d 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillCursor.java
@@ -67,24 +67,26 @@ public class DrillCursor implements Cursor{
@Override
public boolean next() throws SQLException {
- if(!started){
+ if (!started) {
started = true;
redoFirstNext = true;
- }else if(redoFirstNext && !finished){
+ } else if(redoFirstNext && !finished) {
redoFirstNext = false;
return true;
}
- if(finished) return false;
+ if (finished) {
+ return false;
+ }
- if(currentRecord+1 < currentBatch.getRecordCount()){
+ if (currentRecord+1 < currentBatch.getRecordCount()) {
currentRecord++;
return true;
- }else{
+ } else {
try {
QueryResultBatch qrb = listener.getNext();
recordBatchCount++;
- while(qrb != null && qrb.getHeader().getRowCount() == 0 && !first){
+ while (qrb != null && qrb.getHeader().getRowCount() == 0 && !first) {
qrb.release();
qrb = listener.getNext();
recordBatchCount++;
@@ -92,14 +94,16 @@ public class DrillCursor implements Cursor{
first = false;
- if(qrb == null){
+ if (qrb == null) {
finished = true;
return false;
- }else{
+ } else {
currentRecord = 0;
boolean changed = currentBatch.load(qrb.getHeader().getDef(), qrb.getData());
schema = currentBatch.getSchema();
- if(changed) updateColumns();
+ if (changed) {
+ updateColumns();
+ }
if (redoFirstNext && currentBatch.getRecordCount() == 0) {
redoFirstNext = false;
}
@@ -112,13 +116,15 @@ public class DrillCursor implements Cursor{
}
}
- void updateColumns(){
+ void updateColumns() {
accessors.generateAccessors(this, currentBatch);
columnMetaDataList.updateColumnMetaData(UNKNOWN, UNKNOWN, UNKNOWN, schema);
- if(results.changeListener != null) results.changeListener.schemaChanged(schema);
+ if (results.changeListener != null) {
+ results.changeListener.schemaChanged(schema);
+ }
}
- public long getRecordBatchCount(){
+ public long getRecordBatchCount() {
return recordBatchCount;
}
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
index bde0d3fac..90d183fa3 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
@@ -68,8 +68,8 @@ public class DrillResultSet extends AvaticaResultSet {
close();
}
- synchronized void cleanup(){
- if (queryId != null && !listener.completed){
+ synchronized void cleanup() {
+ if (queryId != null && !listener.completed) {
client.cancelQuery(queryId);
}
listener.close();
@@ -108,8 +108,8 @@ public class DrillResultSet extends AvaticaResultSet {
final LinkedBlockingDeque<QueryResultBatch> queue = Queues.newLinkedBlockingDeque();
- private boolean releaseIfFirst(){
- if(receivedMessage.compareAndSet(false, true)){
+ private boolean releaseIfFirst() {
+ if (receivedMessage.compareAndSet(false, true)) {
latch.countDown();
return true;
}
@@ -164,8 +164,9 @@ public class DrillResultSet extends AvaticaResultSet {
public QueryResultBatch getNext() throws RpcException, InterruptedException {
while (true) {
- if (ex != null)
+ if (ex != null) {
throw ex;
+ }
if (completed && queue.isEmpty()) {
return null;
} else {
@@ -178,9 +179,7 @@ public class DrillResultSet extends AvaticaResultSet {
}
return q;
}
-
}
-
}
}
@@ -188,7 +187,9 @@ public class DrillResultSet extends AvaticaResultSet {
closed = true;
while (!queue.isEmpty()) {
QueryResultBatch qrb = queue.poll();
- if(qrb != null && qrb.getData() != null) qrb.getData().release();
+ if (qrb != null && qrb.getData() != null) {
+ qrb.getData().release();
+ }
}
completed = true;
}
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/MetaImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/MetaImpl.java
index 86cdefe23..904c0786c 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/MetaImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/MetaImpl.java
@@ -67,14 +67,14 @@ public class MetaImpl implements Meta {
return null;
}
- private ResultSet s(String s){
- try{
+ private ResultSet s(String s) {
+ try {
logger.debug("Running {}", s);
AvaticaStatement statement = connection.createStatement();
statement.execute(s);
return statement.getResultSet();
- }catch(Exception e){
+ } catch (Exception e) {
throw new DrillRuntimeException("Failure while attempting to get DatabaseMetadata.", e);
}
@@ -96,22 +96,24 @@ public class MetaImpl implements Meta {
+ "'' as REF_GENERATION "
+ "FROM INFORMATION_SCHEMA.`TABLES` WHERE 1=1 ");
- if(catalog != null){
+ if (catalog != null) {
sb.append(" AND TABLE_CATALOG = '" + StringEscapeUtils.escapeSql(catalog) + "' ");
}
- if(schemaPattern.s != null){
+ if (schemaPattern.s != null) {
sb.append(" AND TABLE_SCHEMA like '" + StringEscapeUtils.escapeSql(schemaPattern.s) + "'");
}
- if(tableNamePattern.s != null){
+ if (tableNamePattern.s != null) {
sb.append(" AND TABLE_NAME like '" + StringEscapeUtils.escapeSql(tableNamePattern.s) + "'");
}
- if(typeList != null && typeList.size() > 0){
+ if (typeList != null && typeList.size() > 0) {
sb.append("AND (");
- for(int t = 0; t < typeList.size(); t++){
- if(t != 0) sb.append(" OR ");
+ for (int t = 0; t < typeList.size(); t++) {
+ if (t != 0) {
+ sb.append(" OR ");
+ }
sb.append(" TABLE_TYPE LIKE '" + StringEscapeUtils.escapeSql(typeList.get(t)) + "' ");
}
sb.append(")");
@@ -152,18 +154,18 @@ public class MetaImpl implements Meta {
+ "FROM INFORMATION_SCHEMA.COLUMNS "
+ "WHERE 1=1 ");
- if(catalog != null){
+ if (catalog != null) {
sb.append(" AND TABLE_CATALOG = '" + StringEscapeUtils.escapeSql(catalog) + "' ");
}
- if(schemaPattern.s != null){
+ if (schemaPattern.s != null) {
sb.append(" AND TABLE_SCHEMA like '" + StringEscapeUtils.escapeSql(schemaPattern.s) + "'");
}
- if(tableNamePattern.s != null){
+ if (tableNamePattern.s != null) {
sb.append(" AND TABLE_NAME like '" + StringEscapeUtils.escapeSql(tableNamePattern.s) + "'");
}
- if(columnNamePattern.s != null){
+ if (columnNamePattern.s != null) {
sb.append(" AND COLUMN_NAME like '" + StringEscapeUtils.escapeSql(columnNamePattern.s) + "'");
}
@@ -179,10 +181,10 @@ public class MetaImpl implements Meta {
+ "CATALOG_NAME as TABLE_CAT "
+ " FROM INFORMATION_SCHEMA.SCHEMATA WHERE 1=1 ");
- if(catalog != null){
+ if (catalog != null) {
sb.append(" AND CATALOG_NAME = '" + StringEscapeUtils.escapeSql(catalog) + "' ");
}
- if(schemaPattern.s != null){
+ if (schemaPattern.s != null) {
sb.append(" AND SCHEMA_NAME like '" + StringEscapeUtils.escapeSql(schemaPattern.s) + "'");
}
sb.append(" ORDER BY CATALOG_NAME, SCHEMA_NAME");
@@ -300,4 +302,4 @@ public class MetaImpl implements Meta {
String getName();
}
-} \ No newline at end of file
+}
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestActionBase.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestActionBase.java
index 5c0a2e3d9..15fe21954 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestActionBase.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestActionBase.java
@@ -95,8 +95,9 @@ public class JdbcTestActionBase extends JdbcTest {
System.out.println(String.format("Query completed in %d millis.", watch.elapsed(TimeUnit.MILLISECONDS)));
- if (rowcount != -1)
+ if (rowcount != -1) {
Assert.assertEquals((long) rowcount, (long) rows);
+ }
System.out.println("\n\n\n");
@@ -133,4 +134,5 @@ public class JdbcTestActionBase extends JdbcTest {
}
}
};
+
}
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java
index 2dba4029e..4528ceeb5 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java
@@ -76,8 +76,10 @@ public class JdbcTestQueryBase extends JdbcTest {
System.out.println("\n\n\n");
success = true;
- }finally{
- if(!success) Thread.sleep(2000);
+ } finally {
+ if (!success) {
+ Thread.sleep(2000);
+ }
}
}
}
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcDistQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcDistQuery.java
index 58b36159b..0b5e6fc5d 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcDistQuery.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcDistQuery.java
@@ -197,7 +197,7 @@ public class TestJdbcDistQuery extends JdbcTest{
System.out.println();
first = false;
}
- while(r.next()){
+ while (r.next()) {
md = r.getMetaData();
for (int i = 1; i <= md.getColumnCount(); i++) {
@@ -212,11 +212,11 @@ public class TestJdbcDistQuery extends JdbcTest{
System.out.println("\n\n\n");
success = true;
- }finally{
- if(!success) Thread.sleep(2000);
+ } finally {
+ if (!success) {
+ Thread.sleep(2000);
+ }
}
-
-
}
@Test
diff --git a/exec/jdbc/src/test/resources/test-models.json b/exec/jdbc/src/test/resources/test-models.json
index 23895c928..b5b7c90ee 100644
--- a/exec/jdbc/src/test/resources/test-models.json
+++ b/exec/jdbc/src/test/resources/test-models.json
@@ -59,7 +59,6 @@
path: '/donuts.json',
useReferenceInterpreter: 'true'
}
-
},
{
name: 'TIME_BY_DAY',
@@ -69,7 +68,6 @@
path: '/donuts.json',
useReferenceInterpreter: 'true'
}
-
}
]
}