Merging master
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/9838cae6 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/9838cae6 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/9838cae6 Branch: refs/heads/index_support Commit: 9838cae607b1024191cbe5915af2b6b7a8bf3d49 Parents: 0028d7a Author: Jihoon Son <[email protected]> Authored: Tue Jul 21 21:55:23 2015 +0900 Committer: Jihoon Son <[email protected]> Committed: Tue Jul 21 21:55:23 2015 +0900 ---------------------------------------------------------------------- .../tajo/catalog/store/AbstractDBStore.java | 6 +- .../org/apache/tajo/catalog/store/MemStore.java | 7 +- .../java/org/apache/tajo/cli/tsql/TajoCli.java | 24 ------ .../apache/tajo/client/CatalogAdminClient.java | 21 ++--- .../tajo/client/CatalogAdminClientImpl.java | 81 +++++--------------- 5 files changed, 28 insertions(+), 111 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/9838cae6/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java ---------------------------------------------------------------------- diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java index 5dd2b68..2e9c340 100644 --- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java +++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java @@ -2351,11 +2351,7 @@ public abstract class AbstractDBStore extends CatalogConstants implements Catalo pstmt.setString(3, unifiedName); res = pstmt.executeQuery(); if (!res.next()) { -<<<<<<< HEAD - throw new CatalogException("ERROR: there is no index matched to " + unifiedName); -======= - throw new TajoInternalError("ERROR: there is no index matched to " + columnName); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 + throw new TajoInternalError("ERROR: there is no index matched to " + unifiedName); } IndexDescProto.Builder builder = IndexDescProto.newBuilder(); http://git-wip-us.apache.org/repos/asf/tajo/blob/9838cae6/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java ---------------------------------------------------------------------- diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java index 433a309..2ad11a7 100644 --- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java +++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MemStore.java @@ -670,17 +670,12 @@ public class MemStore implements CatalogStore { @Override public IndexDescProto getIndexByColumns(String databaseName, String tableName, String[] columnNames) throws CatalogException { Map<String, IndexDescProto> indexByColumn = checkAndGetDatabaseNS(indexesByColumn, databaseName); -<<<<<<< HEAD String simpleTableName = CatalogUtil.extractSimpleName(tableName); TableDescProto tableDescProto = getTable(databaseName, simpleTableName); String qualifiedColumnName = CatalogUtil.buildFQName(databaseName, simpleTableName, CatalogUtil.getUnifiedSimpleColumnName(new Schema(tableDescProto.getSchema()), columnNames)); if (!indexByColumn.containsKey(qualifiedColumnName)) { - throw new NoSuchIndexException(qualifiedColumnName); -======= - if (!indexByColumn.containsKey(columnName)) { - throw new UndefinedIndexException(CatalogUtil.buildFQName(databaseName, tableName), columnName); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 + throw new UndefinedIndexException(qualifiedColumnName); } return indexByColumn.get(qualifiedColumnName); http://git-wip-us.apache.org/repos/asf/tajo/blob/9838cae6/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java ---------------------------------------------------------------------- diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java index 6ceb4b6..f5f20c1 100644 --- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java +++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/TajoCli.java @@ -491,11 +491,7 @@ public class TajoCli { ClientProtos.SubmitQueryResponse response = client.executeQueryWithJson(json); if (response == null) { onError("response is null", null); -<<<<<<< HEAD - } else if (response.getResult().getResultCode() == ClientProtos.ResultCode.OK) { -======= } else if (ReturnStateUtil.isSuccess(response.getState())) { ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 if (response.getIsForwarded()) { QueryId queryId = new QueryId(response.getQueryId()); waitForQueryCompleted(queryId); @@ -508,13 +504,8 @@ public class TajoCli { } } } else { -<<<<<<< HEAD - if (response.getResult().hasErrorMessage()) { - onError(response.getResult().getErrorMessage(), null); -======= if (ReturnStateUtil.isError(response.getState())) { onError(response.getState().getMessage(), null); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 } } } @@ -529,23 +520,11 @@ public class TajoCli { onError(null, te); } -<<<<<<< HEAD - if (response == null) { - onError("response is null", null); - } else if (response.getResult().getResultCode() == ClientProtos.ResultCode.OK) { - if (response.getIsForwarded()) { - QueryId queryId = new QueryId(response.getQueryId()); - waitForQueryCompleted(queryId); - } else { - if (!response.hasTableDesc() && !response.hasResultSet()) { - displayFormatter.printMessage(sout, "OK"); -======= if (response != null) { if (ReturnStateUtil.isSuccess(response.getState())) { if (response.getIsForwarded()) { QueryId queryId = new QueryId(response.getQueryId()); waitForQueryCompleted(queryId); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 } else { if (!response.hasTableDesc() && !response.hasResultSet()) { displayFormatter.printMessage(sout, "OK"); @@ -557,13 +536,10 @@ public class TajoCli { if (ReturnStateUtil.isError(response.getState())) { onError(response.getState().getMessage(), null); } -<<<<<<< HEAD } } else { if (response.getResult().hasErrorMessage()) { onError(response.getResult().getErrorMessage(), null); -======= ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 } } http://git-wip-us.apache.org/repos/asf/tajo/blob/9838cae6/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java ---------------------------------------------------------------------- diff --git a/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java b/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java index 1044cc9..5e923e0 100644 --- a/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java +++ b/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClient.java @@ -19,7 +19,6 @@ package org.apache.tajo.client; import org.apache.tajo.annotation.Nullable; -import org.apache.tajo.catalog.IndexMeta; import org.apache.tajo.catalog.Schema; import org.apache.tajo.catalog.TableDesc; import org.apache.tajo.catalog.TableMeta; @@ -136,23 +135,19 @@ public interface CatalogAdminClient extends Closeable { */ TableDesc getTableDesc(final String tableName) throws SQLException; -<<<<<<< HEAD - public List<CatalogProtos.FunctionDescProto> getFunctions(final String functionName) throws ServiceException; + List<CatalogProtos.FunctionDescProto> getFunctions(final String functionName) throws SQLException; - public IndexDescProto getIndex(final String indexName) throws ServiceException; + IndexDescProto getIndex(final String indexName) throws SQLException; - public boolean existIndex(final String indexName) throws ServiceException; + boolean existIndex(final String indexName) throws SQLException; - public List<IndexDescProto> getIndexes(final String tableName) throws ServiceException; + List<IndexDescProto> getIndexes(final String tableName) throws SQLException; - public boolean hasIndexes(final String tableName) throws ServiceException; + boolean hasIndexes(final String tableName) throws SQLException; - public IndexDescProto getIndex(final String tableName, final String[] columnNames) throws ServiceException; + IndexDescProto getIndex(final String tableName, final String[] columnNames) throws SQLException; - public boolean existIndex(final String tableName, final String[] columnName) throws ServiceException; + boolean existIndex(final String tableName, final String[] columnName) throws SQLException; - public boolean dropIndex(final String indexName) throws ServiceException; -======= - List<CatalogProtos.FunctionDescProto> getFunctions(final String functionName) throws SQLException; ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 + boolean dropIndex(final String indexName) throws SQLException; } http://git-wip-us.apache.org/repos/asf/tajo/blob/9838cae6/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClientImpl.java ---------------------------------------------------------------------- diff --git a/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClientImpl.java b/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClientImpl.java index 79ba71f..9ef325b 100644 --- a/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClientImpl.java +++ b/tajo-client/src/main/java/org/apache/tajo/client/CatalogAdminClientImpl.java @@ -26,18 +26,14 @@ import org.apache.tajo.catalog.TableDesc; import org.apache.tajo.catalog.TableMeta; import org.apache.tajo.catalog.partition.PartitionMethodDesc; import org.apache.tajo.catalog.proto.CatalogProtos; -<<<<<<< HEAD import org.apache.tajo.catalog.proto.CatalogProtos.IndexDescProto; import org.apache.tajo.ipc.ClientProtos; import org.apache.tajo.ipc.ClientProtos.*; -import org.apache.tajo.jdbc.SQLStates; -======= import org.apache.tajo.catalog.proto.CatalogProtos.FunctionDescProto; import org.apache.tajo.catalog.proto.CatalogProtos.TableResponse; import org.apache.tajo.exception.SQLExceptionUtil; import org.apache.tajo.ipc.ClientProtos; import org.apache.tajo.ipc.ClientProtos.DropTableRequest; ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 import org.apache.tajo.rpc.NettyClientBase; import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.StringListResponse; @@ -140,13 +136,6 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { if (partitionMethodDesc != null) { builder.setPartition(partitionMethodDesc.getProto()); } -<<<<<<< HEAD - ClientProtos.TableResponse res = tajoMasterService.createExternalTable(null, builder.build()); - if (res.getResult().getResultCode() == ClientProtos.ResultCode.OK) { - return CatalogUtil.newTableDesc(res.getTableDesc()); - } else { - throw new SQLException(res.getResult().getErrorMessage(), SQLStates.ER_NO_SUCH_TABLE.getState()); -======= TableResponse res; try { @@ -159,7 +148,6 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { return CatalogUtil.newTableDesc(res.getTable()); } else { throw SQLExceptionUtil.toSQLException(res.getState()); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 } } @@ -202,22 +190,6 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override -<<<<<<< HEAD - public TableDesc getTableDesc(final String tableName) throws ServiceException { - NettyClientBase client = connection.getTajoMasterConnection(); - connection.checkSessionAndGet(client); - BlockingInterface tajoMasterService = client.getStub(); - - SessionedStringProto.Builder builder = SessionedStringProto.newBuilder(); - builder.setSessionId(connection.sessionId); - builder.setValue(tableName); - ClientProtos.TableResponse res = tajoMasterService.getTableDesc(null, builder.build()); - if (res.getResult().getResultCode() == ClientProtos.ResultCode.OK) { - return CatalogUtil.newTableDesc(res.getTableDesc()); - } else { - throw new ServiceException(new SQLException(res.getResult().getErrorMessage(), - SQLStates.ER_NO_SUCH_TABLE.getState())); -======= public TableDesc getTableDesc(final String tableName) throws SQLException { final BlockingInterface stub = conn.getTMStub(); @@ -227,7 +199,6 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { res = stub.getTableDesc(null, conn.getSessionedString(tableName)); } catch (ServiceException e) { throw new RuntimeException(e); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 } throwIfError(res.getState()); @@ -235,24 +206,24 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override -<<<<<<< HEAD - public List<CatalogProtos.FunctionDescProto> getFunctions(final String functionName) throws ServiceException { - NettyClientBase client = connection.getTajoMasterConnection(); - connection.checkSessionAndGet(client); - BlockingInterface tajoMasterService = client.getStub(); + public List<FunctionDescProto> getFunctions(final String functionName) throws SQLException { + + final BlockingInterface stub = conn.getTMStub(); String paramFunctionName = functionName == null ? "" : functionName; - ClientProtos.FunctionResponse res = tajoMasterService.getFunctionList(null, - connection.convertSessionedString(paramFunctionName)); - if (res.getResult().getResultCode() == ClientProtos.ResultCode.OK) { - return res.getFunctionsList(); - } else { - throw new ServiceException(res.getResult().getErrorMessage()); + CatalogProtos.FunctionListResponse res; + try { + res = stub.getFunctionList(null, conn.getSessionedString(paramFunctionName)); + } catch (ServiceException e) { + throw new RuntimeException(e); } + + throwIfError(res.getState()); + return res.getFunctionList(); } @Override - public IndexDescProto getIndex(final String indexName) throws ServiceException { + public IndexDescProto getIndex(final String indexName) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); @@ -261,7 +232,7 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override - public boolean existIndex(final String indexName) throws ServiceException { + public boolean existIndex(final String indexName) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); @@ -270,7 +241,7 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override - public List<IndexDescProto> getIndexes(final String tableName) throws ServiceException { + public List<IndexDescProto> getIndexes(final String tableName) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); @@ -284,7 +255,7 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override - public boolean hasIndexes(final String tableName) throws ServiceException { + public boolean hasIndexes(final String tableName) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); @@ -293,7 +264,7 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override - public IndexDescProto getIndex(final String tableName, final String[] columnNames) throws ServiceException { + public IndexDescProto getIndex(final String tableName, final String[] columnNames) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); @@ -312,7 +283,7 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override - public boolean existIndex(final String tableName, final String[] columnName) throws ServiceException { + public boolean existIndex(final String tableName, final String[] columnName) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); @@ -326,29 +297,13 @@ public class CatalogAdminClientImpl implements CatalogAdminClient { } @Override - public boolean dropIndex(final String indexName) throws ServiceException { + public boolean dropIndex(final String indexName) throws SQLException { NettyClientBase client = connection.getTajoMasterConnection(); connection.checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); return tajoMasterService.dropIndex(null, connection.convertSessionedString(indexName)).getValue(); ======= - public List<FunctionDescProto> getFunctions(final String functionName) throws SQLException { - - final BlockingInterface stub = conn.getTMStub(); - - String paramFunctionName = functionName == null ? "" : functionName; - CatalogProtos.FunctionListResponse res; - try { - res = stub.getFunctionList(null, conn.getSessionedString(paramFunctionName)); - } catch (ServiceException e) { - throw new RuntimeException(e); - } - - throwIfError(res.getState()); - return res.getFunctionList(); ->>>>>>> c50a5dadff90fa90709abbce59856e834baa4867 - } @Override public void close() throws IOException {
