@Override public IndexResponse getIndexByColumnNames( RpcController controller, GetIndexByColumnNamesRequest request) throws ServiceException { TableIdentifierProto identifier = request.getTableIdentifier(); String databaseName = identifier.getDatabaseName(); String tableName = identifier.getTableName(); List<String> columnNamesList = request.getColumnNamesList(); String[] columnNames = new String[columnNamesList.size()]; columnNames = columnNamesList.toArray(columnNames); rlock.lock(); try { if (!store.existIndexByColumns(databaseName, tableName, columnNames)) { return IndexResponse.newBuilder() .setState(errUndefinedIndex(tableName, columnNamesList)) .build(); } return IndexResponse.newBuilder() .setState(OK) .setIndexDesc(store.getIndexByColumns(databaseName, tableName, columnNames)) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return IndexResponse.newBuilder().setState(returnError(t)).build(); } finally { rlock.unlock(); } }
@Override public IndexResponse getIndexByName(RpcController controller, IndexNameProto request) throws ServiceException { String databaseName = request.getDatabaseName(); String indexName = request.getIndexName(); rlock.lock(); try { if (!store.existIndexByName(databaseName, indexName)) { return IndexResponse.newBuilder().setState(errUndefinedIndexName(indexName)).build(); } return IndexResponse.newBuilder() .setState(OK) .setIndexDesc(store.getIndexByName(databaseName, indexName)) .build(); } catch (Throwable t) { printStackTraceIfError(LOG, t); return IndexResponse.newBuilder().setState(returnError(t)).build(); } finally { rlock.unlock(); } }