Java Code Examples for org.apache.hadoop.hive.metastore.api.Index

The following examples show how to use org.apache.hadoop.hive.metastore.api.Index. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static Index convertTableObjectToIndex(com.amazonaws.services.glue.model.Table catalogTable) {
  Index hiveIndex = new Index();
  Map<String, String> parameters = catalogTable.getParameters();
  hiveIndex.setIndexName(catalogTable.getName());
  hiveIndex.setCreateTime((int) (catalogTable.getCreateTime().getTime() / 1000));
  hiveIndex.setLastAccessTime((int) (catalogTable.getLastAccessTime().getTime() / 1000));
  hiveIndex.setSd(convertStorageDescriptor(catalogTable.getStorageDescriptor()));
  hiveIndex.setParameters(catalogTable.getParameters());

  hiveIndex.setDeferredRebuild(parameters.get(INDEX_DEFERRED_REBUILD).equals("TRUE"));
  hiveIndex.setIndexHandlerClass(parameters.get(INDEX_HANDLER_CLASS));
  hiveIndex.setDbName(parameters.get(INDEX_DB_NAME));
  hiveIndex.setOrigTableName(parameters.get(INDEX_ORIGIN_TABLE_NAME));
  hiveIndex.setIndexTableName(parameters.get(INDEX_TABLE_NAME));

  return hiveIndex;
}
 
Example 2
public static com.amazonaws.services.glue.model.Table convertIndexToTableObject(Index hiveIndex) {
  // convert index object to a table object
  com.amazonaws.services.glue.model.Table catalogIndexTableObject = new com.amazonaws.services.glue.model.Table();
  catalogIndexTableObject.setName(hiveIndex.getIndexName());
  catalogIndexTableObject.setCreateTime(new Date((long) (hiveIndex.getCreateTime()) * 1000));
  catalogIndexTableObject.setLastAccessTime(new Date((long) (hiveIndex.getLastAccessTime()) * 1000));
  catalogIndexTableObject.setStorageDescriptor(convertStorageDescriptor(hiveIndex.getSd()));
  catalogIndexTableObject.setParameters(hiveIndex.getParameters());

  // store rest of fields in index to paramter map
  catalogIndexTableObject.getParameters().put(INDEX_DEFERRED_REBUILD, hiveIndex.isDeferredRebuild() ? "TRUE": "FALSE");
  catalogIndexTableObject.getParameters().put(INDEX_TABLE_NAME, hiveIndex.getIndexTableName());
  catalogIndexTableObject.getParameters().put(INDEX_HANDLER_CLASS, hiveIndex.getIndexHandlerClass());
  catalogIndexTableObject.getParameters().put(INDEX_DB_NAME, hiveIndex.getDbName());
  catalogIndexTableObject.getParameters().put(INDEX_ORIGIN_TABLE_NAME, hiveIndex.getOrigTableName());

  return catalogIndexTableObject;
}
 
Example 3
public List<Index> listIndexes(String dbName, String tblName) throws TException {
  checkArgument(StringUtils.isNotEmpty(dbName), "dbName cannot be null or empty");
  checkArgument(StringUtils.isNotEmpty(tblName), "tblName cannot be null or empty");

  org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
  Map<String, String> parameters = originTable.getParameters();
  List<Table> indexTableObjects = Lists.newArrayList();
  for(String key : parameters.keySet()) {
    if(key.startsWith(INDEX_PREFIX)) {
      String serialisedString = parameters.get(key);
      indexTableObjects.add(stringToCatalogTable(serialisedString));
    }
  }

  List<Index> hiveIndexList = Lists.newArrayList();
  for (Table catalogIndexTableObject : indexTableObjects) {
    hiveIndexList.add(CatalogToHiveConverter.convertTableObjectToIndex(catalogIndexTableObject));
  }
  return hiveIndexList;
}
 
Example 4
@Override
public boolean dropIndex(String dbName, String tblName, String name, boolean deleteData) throws NoSuchObjectException,
      MetaException, TException {
    Index indexToDrop = getIndex(dbName, tblName, name);
    String indexTableName = indexToDrop.getIndexTableName();

    // Drop the index metadata
    org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
    Map<String, String> parameters = originTable.getParameters();
    String indexTableObjectName = INDEX_PREFIX + name;
    if (!parameters.containsKey(indexTableObjectName)) {
        throw new NoSuchObjectException("can not find Index: " + name);
    }
    parameters.remove(indexTableObjectName);

    alter_table(dbName, tblName, originTable);

    // Now drop the data associated with the table used to hold the index data
    if(indexTableName != null && indexTableName.length() > 0) {
        dropTable(dbName, indexTableName, deleteData, true);
    }

    return true;
}
 
Example 5
@Test
public void listIndexesValid() throws TException {
  Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName());
  Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName());

  Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());
  Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());

  index2.setOrigTableName(hiveTable.getTableName());
  index2.setIndexTableName(hiveIndexTable2.getTableName());
  index3.setOrigTableName(hiveTable.getTableName());
  index3.setIndexTableName(hiveIndexTable3.getTableName());

  metastoreClient.createIndex(hiveIndex, hiveIndexTable);
  metastoreClient.createIndex(index2, hiveIndexTable2);
  metastoreClient.createIndex(index3, hiveIndexTable3);
  List<Index> indexList = new ArrayList<>();
  indexList.add(hiveIndex);
  indexList.add(index3);
  indexList.add(index2);

  List<Index> result = metastoreClient.listIndexes(hiveDB.getName(), hiveTable.getTableName(), (short) 2);
  assertTrue(result.containsAll(indexList));
}
 
Example 6
@Test (expected = NoSuchObjectException.class)
public void listIndexesInvalidWithUnknownTable() throws TException {
  Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName());
  Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName());

  Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());
  Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());

  index2.setOrigTableName(hiveTable.getTableName());
  index2.setIndexTableName(hiveIndexTable2.getTableName());
  index3.setOrigTableName(hiveTable.getTableName());
  index3.setIndexTableName(hiveIndexTable3.getTableName());

  metastoreClient.createIndex(hiveIndex, hiveIndexTable);
  metastoreClient.createIndex(index2, hiveIndexTable2);
  metastoreClient.createIndex(index3, hiveIndexTable3);
  metastoreClient.listIndexes(hiveDB.getName(), invalidTable, (short) 2);
}
 
Example 7
@Test (expected = NoSuchObjectException.class)
public void listIndexesInvalidWithUnknownDb() throws TException {
  Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName());
  Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName());

  Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());
  Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());

  index2.setOrigTableName(hiveTable.getTableName());
  index2.setIndexTableName(hiveIndexTable2.getTableName());
  index3.setOrigTableName(hiveTable.getTableName());
  index3.setIndexTableName(hiveIndexTable3.getTableName());

  metastoreClient.createIndex(hiveIndex, hiveIndexTable);
  metastoreClient.createIndex(index2, hiveIndexTable2);
  metastoreClient.createIndex(index3, hiveIndexTable3);
  metastoreClient.listIndexes(invalidDatabase, hiveTable.getTableName(), (short) 2);
}
 
Example 8
@Test
public void listIndexNamesValid() throws TException {
  Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName());
  Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName());

  Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());
  Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());

  index2.setOrigTableName(hiveTable.getTableName());
  index2.setIndexTableName(hiveIndexTable2.getTableName());
  index3.setOrigTableName(hiveTable.getTableName());
  index3.setIndexTableName(hiveIndexTable3.getTableName());

  metastoreClient.createIndex(hiveIndex, hiveIndexTable);
  metastoreClient.createIndex(index2, hiveIndexTable2);
  metastoreClient.createIndex(index3, hiveIndexTable3);
  List<String> indexNameList = new ArrayList<>();
  indexNameList.add(hiveIndex.getIndexName());
  indexNameList.add(index2.getIndexName());
  indexNameList.add(index3.getIndexName());

  List<String> result = metastoreClient.listIndexNames(hiveDB.getName(), hiveTable.getTableName(), (short) 2);

  assertTrue(result.containsAll(indexNameList));
}
 
Example 9
@Test (expected = NoSuchObjectException.class)
public void listIndexNameInvalidWithUnknownTable() throws TException {
  Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName());
  Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName());

  Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());
  Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());

  index2.setOrigTableName(hiveTable.getTableName());
  index2.setIndexTableName(hiveIndexTable2.getTableName());
  index3.setOrigTableName(hiveTable.getTableName());
  index3.setIndexTableName(hiveIndexTable3.getTableName());

  metastoreClient.createIndex(hiveIndex, hiveIndexTable);
  metastoreClient.createIndex(index2, hiveIndexTable2);
  metastoreClient.createIndex(index3, hiveIndexTable3);

  metastoreClient.listIndexNames(hiveDB.getName(), invalidTable, (short) 2);
}
 
Example 10
@Test (expected = NoSuchObjectException.class)
public void listIndexNameInvalidWithUnknownDb() throws TException {
  Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName());
  Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName());

  Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());
  Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName());

  index2.setOrigTableName(hiveTable.getTableName());
  index2.setIndexTableName(hiveIndexTable2.getTableName());
  index3.setOrigTableName(hiveTable.getTableName());
  index3.setIndexTableName(hiveIndexTable3.getTableName());

  metastoreClient.createIndex(hiveIndex, hiveIndexTable);
  metastoreClient.createIndex(index2, hiveIndexTable2);
  metastoreClient.createIndex(index3, hiveIndexTable3);

  metastoreClient.listIndexNames(invalidDatabase, hiveTable.getTableName(), (short) 2);
}
 
Example 11
@Test
public void testListIndexNames() throws Exception{
  Index testIndex2 = getTestHiveIndex(testDB.getName());
  List<String> expectedIndexNameList = ImmutableList.of(testIndex.getIndexName(), testIndex2.getIndexName());
  List<Index> indexList = ImmutableList.of(testIndex, testIndex2);
  for (Index index : indexList) {
    Table catalogIndex = HiveToCatalogConverter.convertIndexToTableObject(index);
    testTable.getParameters().put(INDEX_PREFIX + index.getIndexName(), catalogTableToString(catalogIndex));
  }

  when(glueClient.getTable(any(GetTableRequest.class)))
    .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable)));
  List<String> result = metastoreClient.listIndexNames(testTable.getDbName(), testTable.getTableName(), (short)2);

  verify(glueClient).getTable(any(GetTableRequest.class));
  assertEquals(expectedIndexNameList.size(), result.size());
  for (String indexName : expectedIndexNameList) {
    assertTrue(result.contains(indexName));
  }
}
 
Example 12
@Override
public boolean dropIndex(String dbName, String tblName, String name, boolean deleteData) throws NoSuchObjectException,
      MetaException, TException {
  Index indexToDrop = getIndex(dbName, tblName, name);
  String indexTableName = indexToDrop.getIndexTableName();

  // Drop the index metadata
  org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
  Map<String, String> parameters = originTable.getParameters();
  String indexTableObjectName = INDEX_PREFIX + name;
  if (!parameters.containsKey(indexTableObjectName)) {
    throw new NoSuchObjectException("can not find Index: " + name);
  }
  parameters.remove(indexTableObjectName);

  alter_table(dbName, tblName, originTable);

  // Now drop the data associated with the table used to hold the index data
  if(indexTableName != null && indexTableName.length() > 0) {
    dropTable(dbName, indexTableName, deleteData, true);
  }

  return true;
}
 
Example 13
Source Project: waggle-dance   Source File: FederatedHMSHandlerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void add_index() throws TException {
  Index newIndex = new Index();
  newIndex.setDbName(DB_P);
  Index inboundIndex = new Index();
  Index outboundIndex = new Index();
  Table newTable = new Table();
  newTable.setDbName(DB_P);
  Table inboundTable = new Table();

  when(primaryMapping.transformInboundIndex(newIndex)).thenReturn(inboundIndex);
  when(primaryMapping.transformInboundTable(newTable)).thenReturn(inboundTable);
  when(primaryMapping.transformOutboundIndex(outboundIndex)).thenReturn(newIndex);
  when(primaryClient.add_index(inboundIndex, inboundTable)).thenReturn(outboundIndex);

  Index result = handler.add_index(newIndex, newTable);
  verify(primaryMapping, times(2)).checkWritePermissions(DB_P);
  assertThat(result, is(newIndex));
}
 
Example 14
public static Index getTestHiveIndex(final String dbName) {
  Index index = new Index();
  index.setIndexName("testIndex" + UUID.randomUUID().toString().replaceAll("[^a-zA-Z0-9]+", ""));
  index.setCreateTime((int)(System.currentTimeMillis() / 1000));
  index.setLastAccessTime((int)(System.currentTimeMillis() / 1000));
  index.setDbName(dbName);
  index.setDeferredRebuild(false);
  index.setOrigTableName("OriginalTable");
  index.setIndexTableName("IndexTable");
  index.setIndexHandlerClass("handlerClass");
  index.setParameters(new HashMap<String, String>());
  index.setSd(CatalogToHiveConverter.convertStorageDescriptor(getTestStorageDescriptor()));

  return index;
}
 
Example 15
@Override
public void alter_index(String dbName, String tblName, String indexName, Index index) throws InvalidOperationException,
      MetaException, TException {
    Table catalogIndexTableObject =
          HiveToCatalogConverter.convertIndexToTableObject(index);
    org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
    String indexTableObjectName = INDEX_PREFIX + indexName;
    if (!originTable.getParameters().containsKey(indexTableObjectName)) {
        throw new NoSuchObjectException("can not find index: " + indexName);
    }

    originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject));
    alter_table(dbName, tblName, originTable);
}
 
Example 16
@Override
public void createIndex(Index index, org.apache.hadoop.hive.metastore.api.Table indexTable) throws InvalidObjectException, MetaException, NoSuchObjectException,
      TException, org.apache.hadoop.hive.metastore.api.AlreadyExistsException {
    boolean dirCreated = glueMetastoreClientDelegate.validateNewTableAndCreateDirectory(indexTable);
    boolean indexTableCreated = false;
    String dbName = index.getDbName();
    String indexTableName = index.getIndexTableName();
    String originTableName = index.getOrigTableName();
    Path indexTablePath = new Path(indexTable.getSd().getLocation());
    Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(index);
    String indexTableObjectName = INDEX_PREFIX + index.getIndexName();

    try {
        org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, originTableName);
        Map<String, String> parameters = originTable.getParameters();
        if (parameters.containsKey(indexTableObjectName)){
            throw new org.apache.hadoop.hive.metastore.api.AlreadyExistsException("Index: " + index.getIndexName() + " already exist");
        }
        createTable(indexTable);
        indexTableCreated = true;
        originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject));
        alter_table(dbName, originTableName, originTable);
    } catch (Exception e) {
        if (dirCreated){
            wh.deleteDir(indexTablePath, true);
        }
        if (indexTableCreated) {
            dropTable(dbName, indexTableName);
        }
        String msg = "Unable to create index: ";
        logger.error(msg, e);
        if (e instanceof TException) {
            throw e;
        } else {
            throw new MetaException(msg + e);
        }
    }
}
 
Example 17
@Override
public Index getIndex(String dbName, String tblName, String indexName) throws MetaException, UnknownTableException,
      NoSuchObjectException, TException {
    org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
    Map<String, String> map = originTable.getParameters();
    String indexTableName = INDEX_PREFIX + indexName;
    if(!map.containsKey(indexTableName)) {
        throw new NoSuchObjectException("can not find index: " + indexName);
    }
    Table indexTableObject = stringToCatalogTable(map.get(indexTableName));
    return CatalogToHiveConverter.convertTableObjectToIndex(indexTableObject);
}
 
Example 18
@Override
public List<String> listIndexNames(String db_name, String tbl_name, short max) throws MetaException, TException {
    // In current hive implementation, it ignores fields "max"
    // https://github.com/apache/hive/blob/rel/release-2.3.0/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L3902-L3932
    List<Index> indexes = listIndexes(db_name, tbl_name, max);
    List<String> indexNames = Lists.newArrayList();
    for(Index index : indexes) {
        indexNames.add(index.getIndexName());
    }

    return indexNames;
}
 
Example 19
@Override
public List<Index> listIndexes(String db_name, String tbl_name, short max) throws NoSuchObjectException, MetaException,
      TException {
  // In current hive implementation, it ignores fields "max"
  // https://github.com/apache/hive/blob/rel/release-2.3.0/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L3867-L3899
  return glueMetastoreClientDelegate.listIndexes(db_name, tbl_name);
}
 
Example 20
@Test
public void alterValidIndex() throws TException {
  metastoreClient.createIndex(hiveIndex, hiveIndexTable);

  Index newIndex = TestObjects.getTestHiveIndex(hiveDB.getName());
  newIndex.setIndexTableName(hiveIndexTable.getTableName());
  newIndex.setOrigTableName(hiveTable.getTableName());

  metastoreClient.alter_index(hiveDB.getName(), hiveTable.getTableName(), hiveIndex.getIndexName(), newIndex);

  assertFalse(indexExist(hiveDB.getName(), hiveTable.getTableName(), hiveIndex.getIndexName()));
  assertTrue(indexExist(hiveDB.getName(), hiveTable.getTableName(), newIndex.getIndexName()));
}
 
Example 21
@Test (expected = NoSuchObjectException.class)
public void alterIndexInvalidWithUnknownDatabase() throws TException {
  metastoreClient.createIndex(hiveIndex, hiveIndexTable);

  Index newIndex = TestObjects.getTestHiveIndex(hiveDB.getName());
  metastoreClient.alter_index(invalidDatabase, hiveTable.getTableName(), hiveIndex.getIndexName(), newIndex);
}
 
Example 22
@Test (expected = NoSuchObjectException.class)
public void alterIndexInvalidWithUnknownTable() throws TException {
  metastoreClient.createIndex(hiveIndex, hiveIndexTable);

  Index newIndex = TestObjects.getTestHiveIndex(hiveDB.getName());
  newIndex.setOrigTableName(hiveTable.getTableName());
  newIndex.setIndexTableName(hiveIndexTable.getTableName());

  metastoreClient.alter_index(hiveDB.getName(), invalidTable, hiveIndex.getIndexName(), newIndex);
}
 
Example 23
@Test
public void testGetIndex() throws Exception {
  Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(testIndex);
  testTable.getParameters().put(INDEX_PREFIX + testIndex.getIndexName(), catalogTableToString(catalogIndexTableObject));

  when(glueClient.getTable(any(GetTableRequest.class)))
      .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable)));
  Index index = metastoreClient.getIndex(testTable.getDbName(), testTable.getTableName(), testIndex.getIndexName());

  verify(glueClient).getTable(any(GetTableRequest.class));
  assertEquals(testIndex, index);
}
 
Example 24
@Override
public void alter_index(String dbName, String tblName, String indexName, Index index) throws InvalidOperationException,
      MetaException, TException {
  Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(index);
  org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
  String indexTableObjectName = INDEX_PREFIX + indexName;
  if (!originTable.getParameters().containsKey(indexTableObjectName)) {
    throw new NoSuchObjectException("can not find index: " + indexName);
  }

  originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject));
  alter_table(dbName, tblName, originTable);
}
 
Example 25
@Override
public void createIndex(Index index, org.apache.hadoop.hive.metastore.api.Table indexTable) throws InvalidObjectException, MetaException, NoSuchObjectException,
      TException, org.apache.hadoop.hive.metastore.api.AlreadyExistsException {
  boolean dirCreated = glueMetastoreClientDelegate.validateNewTableAndCreateDirectory(indexTable);
  boolean indexTableCreated = false;
  String dbName = index.getDbName();
  String indexTableName = index.getIndexTableName();
  String originTableName = index.getOrigTableName();
  Path indexTablePath = new Path(indexTable.getSd().getLocation());
  Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(index);
  String indexTableObjectName = INDEX_PREFIX + index.getIndexName();

  try {
    org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, originTableName);
    Map<String, String> parameters = originTable.getParameters();
    if (parameters.containsKey(indexTableObjectName)){
      throw new org.apache.hadoop.hive.metastore.api.AlreadyExistsException("Index: " + index.getIndexName() + " already exist");
    }
    createTable(indexTable);
    indexTableCreated = true;
    originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject));
    alter_table(dbName, originTableName, originTable);
  } catch (Exception e) {
    if (dirCreated){
      wh.deleteDir(indexTablePath, true);
    }
    if (indexTableCreated) {
      dropTable(dbName, indexTableName);
    }
    String msg = "Unable to create index: ";
    logger.error(msg, e);
    if (e instanceof TException) {
      throw e;
    } else {
      throw new MetaException(msg + e);
    }
  }
}
 
Example 26
@Override
public Index getIndex(String dbName, String tblName, String indexName) throws MetaException, UnknownTableException,
      NoSuchObjectException, TException {
  org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName);
  Map<String, String> map = originTable.getParameters();
  String indexTableName = INDEX_PREFIX + indexName;
  if(!map.containsKey(indexTableName)) {
    throw new NoSuchObjectException("can not find index: " + indexName);
  }
  Table indexTableObject = stringToCatalogTable(map.get(indexTableName));
  return CatalogToHiveConverter.convertTableObjectToIndex(indexTableObject);
}
 
Example 27
@Override
public List<String> listIndexNames(String db_name, String tbl_name, short max) throws MetaException, TException {
  // In current hive implementation, it ignores fields "max"
  // https://github.com/apache/hive/blob/rel/release-2.3.0/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L3902-L3932
  List<Index> indexes = listIndexes(db_name, tbl_name, max);
  List<String> indexNames = Lists.newArrayList();
  for(Index index : indexes) {
    indexNames.add(index.getIndexName());
  }

  return indexNames;
}
 
Example 28
@Override
public List<Index> listIndexes(String db_name, String tbl_name, short max) throws NoSuchObjectException, MetaException,
      TException {
  // In current hive implementation, it ignores fields "max"
  // https://github.com/apache/hive/blob/rel/release-2.3.0/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L3867-L3899
  return glueMetastoreClientDelegate.listIndexes(db_name, tbl_name);
}
 
Example 29
Source Project: waggle-dance   Source File: DatabaseMappingImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Index> transformOutboundIndexes(List<Index> indexes) {
  for (Index index : indexes) {
    transformOutboundIndex(index);
  }
  return indexes;
}
 
Example 30
Source Project: waggle-dance   Source File: FederatedHMSHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public Index add_index(Index new_index, Table index_table)
    throws InvalidObjectException, AlreadyExistsException, MetaException, TException {
  DatabaseMapping mapping = checkWritePermissions(new_index.getDbName());
  mapping.checkWritePermissions(index_table.getDbName());
  Index result = mapping
      .getClient()
      .add_index(mapping.transformInboundIndex(new_index), mapping.transformInboundTable(index_table));
  return mapping.transformOutboundIndex(result);
}