• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MetaStoreUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hive.metastore.MetaStoreUtils的典型用法代码示例。如果您正苦于以下问题:Java MetaStoreUtils类的具体用法?Java MetaStoreUtils怎么用?Java MetaStoreUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetaStoreUtils类属于org.apache.hadoop.hive.metastore包,在下文中一共展示了MetaStoreUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: transform

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public Table transform(Table table) {
  if (!MetaStoreUtils.isView(table)) {
    return table;
  }

  LOG.info("Translating HQL of view {}.{}", table.getDbName(), table.getTableName());
  String tableQualifiedName = Warehouse.getQualifiedName(table);
  String hql = hqlTranslator.translate(tableQualifiedName, table.getViewOriginalText());
  String expandedHql = hqlTranslator.translate(tableQualifiedName, table.getViewExpandedText());

  Table transformedView = new Table(table);
  transformedView.setViewOriginalText(hql);
  transformedView.setViewExpandedText(expandedHql);

  if (!replicaHiveConf.getBoolean(SKIP_TABLE_EXIST_CHECKS, false)) {
    LOG.info("Validating that tables used by the view {}.{} exist in the replica catalog", table.getDbName(),
        table.getTableName());
    validateReferencedTables(transformedView);
  }

  return transformedView;
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:24,代码来源:ViewTransformation.java


示例2: getLocationManager

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
public SourceLocationManager getLocationManager(
    Table table,
    List<Partition> partitions,
    String eventId,
    Map<String, Object> copierOptions)
  throws IOException {
  if (MetaStoreUtils.isView(table)) {
    return new ViewLocationManager();
  }
  HdfsSnapshotLocationManager hdfsSnapshotLocationManager = new HdfsSnapshotLocationManager(getHiveConf(), eventId,
      table, partitions, snapshotsDisabled, sourceTableLocation, sourceCatalogListener);
  boolean ignoreMissingFolder = MapUtils.getBooleanValue(copierOptions,
      CopierOptions.IGNORE_MISSING_PARTITION_FOLDER_ERRORS, false);
  if (ignoreMissingFolder) {
    return new FilterMissingPartitionsLocationManager(hdfsSnapshotLocationManager, getHiveConf());
  }
  return hdfsSnapshotLocationManager;
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:19,代码来源:Source.java


示例3: partition_name_has_valid_characters

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean partition_name_has_valid_characters(final List<String> partVals, final boolean throwException)
    throws TException {
    return requestWrapper("partition_name_has_valid_characters", new Object[]{partVals, throwException},
        () -> {
            Pattern pattern = null;
            final String partitionPattern = config.getHivePartitionWhitelistPattern();
            if (!Strings.isNullOrEmpty(partitionPattern)) {
                pattern = PATTERNS.getUnchecked(partitionPattern);
            }
            if (throwException) {
                MetaStoreUtils.validatePartitionNameCharacters(partVals, pattern);
                return true;
            } else {
                return MetaStoreUtils.partitionNameHasValidCharacters(partVals, pattern);
            }
        });
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:22,代码来源:CatalogThriftHiveMetastore.java


示例4: preCreateTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public void preCreateTable(Table table) throws MetaException {
  DynamoDBClient client = createDynamoDBClient(table);
  try {

    boolean isExternal = MetaStoreUtils.isExternalTable(table);

    if (!isExternal) {
      throw new MetaException("Only EXTERNAL tables are supported for DynamoDB.");
    }

    String tableName = HiveDynamoDBUtil.getDynamoDBTableName(table.getParameters()
        .get(DynamoDBConstants.TABLE_NAME), table.getTableName());
    TableDescription tableDescription = client.describeTable(tableName);

    checkTableStatus(tableDescription);
    checkTableSchemaMapping(tableDescription, table);
    checkTableSchemaType(tableDescription, table);
  } finally {
    client.close();
  }
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:23,代码来源:DynamoDBStorageHandler.java


示例5: getPartitionMetadata

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
/**
 * Wrapper around {@link MetaStoreUtils#getPartitionMetadata(Partition, Table)} which also adds parameters from table
 * to properties returned by {@link MetaStoreUtils#getPartitionMetadata(Partition, Table)}.
 *
 * @param partition the source of partition level parameters
 * @param table     the source of table level parameters
 * @return properties
 */
public static Properties getPartitionMetadata(final HivePartition partition, final HiveTableWithColumnCache table) {
  final Properties properties;
  restoreColumns(table, partition);
  properties = MetaStoreUtils.getPartitionMetadata(partition, table);

  // SerDe expects properties from Table, but above call doesn't add Table properties.
  // Include Table properties in final list in order to not to break SerDes that depend on
  // Table properties. For example AvroSerDe gets the schema from properties (passed as second argument)
  for (Map.Entry<String, String> entry : table.getParameters().entrySet()) {
    if (entry.getKey() != null && entry.getKey() != null) {
      properties.put(entry.getKey(), entry.getValue());
    }
  }

  return properties;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:HiveUtilities.java


示例6: commitDropTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public void commitDropTable(Table tbl, boolean deleteData)
        throws MetaException {
    KuduClient client = getKuduClient(tbl.getParameters().get(HiveKuduConstants.MASTER_ADDRESS_NAME));
    String tablename = getKuduTableName(tbl);
    boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
    try {
        if (deleteData && !isExternal) {
            client.deleteTable(tablename);
        }
    } catch (Exception ioe) {
        throw new MetaException("Error dropping table:" +tablename);
    } finally {
        try {
            client.shutdown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:BimalTandel,项目名称:HiveKudu-Handler,代码行数:21,代码来源:KuduStorageHandler.java


示例7: rollbackCreateTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public void rollbackCreateTable(Table tbl) throws MetaException {
    KuduClient client = getKuduClient(tbl.getParameters().get(HiveKuduConstants.MASTER_ADDRESS_NAME));
    String tablename = getKuduTableName(tbl);
    boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
    try {
        if ( client.tableExists(tablename) && !isExternal) {
            client.deleteTable(tablename);
        }
    } catch (Exception ioe) {
        throw new MetaException("Error dropping table while rollback of create table:" +tablename);
    } finally {
        try {
            client.shutdown();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:BimalTandel,项目名称:HiveKudu-Handler,代码行数:20,代码来源:KuduStorageHandler.java


示例8: start

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
public void start(Map<String, String> confOverlay) throws Exception {
  if (isMetastoreRemote) {
    int metaStorePort = MetaStoreUtils.findFreePort();
    getHiveConf().setVar(ConfVars.METASTOREURIS, "thrift://localhost:" + metaStorePort);
    MetaStoreUtils.startMetaStore(metaStorePort,
    ShimLoader.getHadoopThriftAuthBridge(), getHiveConf());
  }

  hiveServer2 = new HiveServer2();
  // Set confOverlay parameters
  for (Map.Entry<String, String> entry : confOverlay.entrySet()) {
    setConfProperty(entry.getKey(), entry.getValue());
  }
  hiveServer2.init(getHiveConf());
  hiveServer2.start();
  waitForStartup();
  setStarted(true);
}
 
开发者ID:bobfreitas,项目名称:hiveunit-mr2,代码行数:19,代码来源:MiniHS2.java


示例9: HCatTableInfo

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
/**
 * Initializes a new HCatTableInfo instance to be used with
 * {@link org.apache.hive.hcatalog.mapreduce.HCatInputFormat} for reading data from
 * a table. Work with hadoop security, the kerberos principal name of the server
 * - else null. The principal name should be of the form:
 * <servicename>/[email protected]<realm> like "hcat/[email protected]"
 * The special string _HOST will be replaced automatically with the correct host name
 * @param databaseName the db name
 * @param tableName the table name
 * @param dataColumns schema of columns which contain data
 * @param partitionColumns schema of partition columns
 * @param storerInfo information about storage descriptor
 * @param table hive metastore table class
 */
HCatTableInfo(
  String databaseName,
  String tableName,
  HCatSchema dataColumns,
  HCatSchema partitionColumns,
  StorerInfo storerInfo,
  Table table) {
  this.databaseName = (databaseName == null) ?
      MetaStoreUtils.DEFAULT_DATABASE_NAME : databaseName;
  this.tableName = tableName;
  this.dataColumns = dataColumns;
  this.table = table;
  this.storerInfo = storerInfo;
  this.partitionColumns = partitionColumns;
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:30,代码来源:HCatTableInfo.java


示例10: getFieldSchemas

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
/**
 * First tries getting the {@code FieldSchema}s from the {@code HiveRegistrationUnit}'s columns, if set.
 * Else, gets the {@code FieldSchema}s from the deserializer.
 */
private static List<FieldSchema> getFieldSchemas(HiveRegistrationUnit unit) {
  List<Column> columns = unit.getColumns();
  List<FieldSchema> fieldSchemas = new ArrayList<>();
  if (columns != null && columns.size() > 0) {
    fieldSchemas = getFieldSchemas(columns);
  } else {
    Deserializer deserializer = getDeserializer(unit);
    if (deserializer != null) {
      try {
        fieldSchemas = MetaStoreUtils.getFieldsFromDeserializer(unit.getTableName(), deserializer);
      } catch (SerDeException | MetaException e) {
        LOG.warn("Encountered exception while getting fields from deserializer.", e);
      }
    }
  }
  return fieldSchemas;
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:22,代码来源:HiveMetaStoreUtils.java


示例11: getThriftSchema

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
/**
 * Get a Schema with fields represented with Thrift DDL types
 */
public Schema getThriftSchema() throws Exception {
  Schema schema;
  try {
    schema = getSchema();
    if (schema != null) {
      List<FieldSchema> lst = schema.getFieldSchemas();
      // Go over the schema and convert type to thrift type
      if (lst != null) {
        for (FieldSchema f : lst) {
          f.setType(MetaStoreUtils.typeToThriftType(f.getType()));
        }
      }
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw e;
  }
  LOG.info("Returning Thrift schema: " + schema);
  return schema;
}
 
开发者ID:adrian-wang,项目名称:project-panthera-skin,代码行数:24,代码来源:SkinDriver.java


示例12: commitDropTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
    //TODO: Should this be implemented to drop the table and its data from cassandra
    boolean isExternal = MetaStoreUtils.isExternalTable(table);
    if (deleteData && !isExternal) {
        CqlManager manager = new CqlManager(table);

        try {
            //open connection to cassandra
            manager.openConnection();
            //drop the table
            manager.dropTable();
        } finally {
            manager.closeConnection();
        }
    }
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:18,代码来源:CqlStorageHandler.java


示例13: commitDropTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
    //TODO: Should this be implemented to drop the table and its data from cassandra
    boolean isExternal = MetaStoreUtils.isExternalTable(table);
    if (deleteData && !isExternal) {
        CassandraManager manager = new CassandraManager(table);

        try {
            //open connection to cassandra
            manager.openConnection();
            //drop the table
            manager.dropTable();
        } finally {
            manager.closeConnection();
        }
    }
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:18,代码来源:CassandraStorageHandler.java


示例14: commitDropTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
  //TODO: Should this be implemented to drop the table and its data from cassandra
  boolean isExternal = MetaStoreUtils.isExternalTable(table);
  if (deleteData && !isExternal) {
    CassandraManager manager = new CassandraManager(table);

    try {
      //open connection to cassandra
      manager.openConnection();
      //drop the table
      manager.dropTable();
    } finally {
      manager.closeConnection();
    }
  }
}
 
开发者ID:dvasilen,项目名称:Hive-Cassandra,代码行数:18,代码来源:CassandraStorageHandler.java


示例15: validate

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
private void validate(TableReplication tableReplication, Source source, Replica replica) {
  source.getDatabase(tableReplication.getSourceTable().getDatabaseName());
  replica.getDatabase(tableReplication.getReplicaDatabaseName());

  TableAndStatistics sourceTableAndStatistics = source.getTableAndStatistics(tableReplication);
  if (tableReplication.getReplicationMode() != ReplicationMode.METADATA_MIRROR
      && MetaStoreUtils.isView(sourceTableAndStatistics.getTable())) {
    throw new CircusTrainException(String.format("Cannot replicate view %s. Only %s is supported for views",
        tableReplication.getSourceTable().getQualifiedName(), ReplicationMode.METADATA_MIRROR.name()));
  }
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:12,代码来源:ReplicationFactoryImpl.java


示例16: newTable

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Test
public void newTable() {
  TableAndStatistics replicaAndStats = factory.newReplicaTable(EVENT_ID, sourceTableAndStats, DB_NAME, TABLE_NAME,
      REPLICA_DATA_DESTINATION, FULL);
  Table replica = replicaAndStats.getTable();

  assertThat(replica.getDbName(), is(sourceTable.getDbName()));
  assertThat(replica.getTableName(), is(sourceTable.getTableName()));
  assertThat(replica.getSd().getInputFormat(), is(INPUT_FORMAT));
  assertThat(replica.getSd().getOutputFormat(), is(OUTPUT_FORMAT));
  assertThat(replica.getSd().getLocation(), is(REPLICA_DATA_DESTINATION.toUri().toString()));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.source.table"), is(DB_NAME + "." + TABLE_NAME));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.source.metastore.uris"),
      is(SOURCE_META_STORE_URIS));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.source.location"), is(TABLE_LOCATION));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.replication.event"), is(EVENT_ID));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.last.replicated"), is(not(nullValue())));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.replication.mode"), is(FULL.name()));
  assertThat(replica.getParameters().get("DO_NOT_UPDATE_STATS"), is("true"));
  assertThat(replica.getParameters().get("STATS_GENERATED_VIA_STATS_TASK"), is("true"));
  assertThat(replica.getParameters().get("STATS_GENERATED"), is("true"));
  assertThat(replica.getParameters().get(StatsSetupConst.ROW_COUNT), is("1"));
  assertThat(replica.getTableType(), is(TableType.EXTERNAL_TABLE.name()));
  assertThat(replica.getParameters().get("EXTERNAL"), is("TRUE"));
  assertTrue(MetaStoreUtils.isExternalTable(replica));

  assertThat(replicaAndStats.getStatistics(), is(nullValue()));
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:29,代码来源:ReplicaTableFactoryTest.java


示例17: newView

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
@Test
public void newView() {
  sourceTableAndStats.getTable().setTableType(TableType.VIRTUAL_VIEW.name());
  sourceTableAndStats.getTable().getSd().setInputFormat(null);
  sourceTableAndStats.getTable().getSd().setOutputFormat(null);
  sourceTableAndStats.getTable().getSd().setLocation(null);

  TableAndStatistics replicaAndStats = factory.newReplicaTable(EVENT_ID, sourceTableAndStats, DB_NAME, TABLE_NAME,
      null, FULL);
  Table replica = replicaAndStats.getTable();

  assertThat(replica.getDbName(), is(sourceTable.getDbName()));
  assertThat(replica.getTableName(), is(sourceTable.getTableName()));
  assertThat(replica.getSd().getInputFormat(), is(nullValue()));
  assertThat(replica.getSd().getOutputFormat(), is(nullValue()));
  assertThat(replica.getSd().getLocation(), is(nullValue()));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.source.table"), is(DB_NAME + "." + TABLE_NAME));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.source.metastore.uris"),
      is(SOURCE_META_STORE_URIS));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.source.location"), is(""));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.replication.event"), is(EVENT_ID));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.last.replicated"), is(not(nullValue())));
  assertThat(replica.getParameters().get("com.hotels.bdp.circustrain.replication.mode"), is(FULL.name()));
  assertThat(replica.getParameters().get("DO_NOT_UPDATE_STATS"), is("true"));
  assertThat(replica.getParameters().get("STATS_GENERATED_VIA_STATS_TASK"), is("true"));
  assertThat(replica.getParameters().get("STATS_GENERATED"), is("true"));
  assertThat(replica.getParameters().get(StatsSetupConst.ROW_COUNT), is("1"));
  assertThat(replica.getTableType(), is(TableType.VIRTUAL_VIEW.name()));
  assertTrue(MetaStoreUtils.isView(replica));

  assertThat(replicaAndStats.getStatistics(), is(nullValue()));
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:33,代码来源:ReplicaTableFactoryTest.java


示例18: getPartitionMetadata

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
/**
 * Wrapper around {@link MetaStoreUtils#getPartitionMetadata(Partition, Table)} which also adds parameters from table
 * to properties returned by {@link MetaStoreUtils#getPartitionMetadata(Partition, Table)}.
 *
 * @param partition the source of partition level parameters
 * @param table     the source of table level parameters
 * @return properties
 */
public static Properties getPartitionMetadata(final Partition partition, final Table table) {
  final Properties properties = MetaStoreUtils.getPartitionMetadata(partition, table);

  // SerDe expects properties from Table, but above call doesn't add Table properties.
  // Include Table properties in final list in order to not to break SerDes that depend on
  // Table properties. For example AvroSerDe gets the schema from properties (passed as second argument)
  for (Map.Entry<String, String> entry : table.getParameters().entrySet()) {
    if (entry.getKey() != null && entry.getKey() != null) {
      properties.put(entry.getKey(), entry.getValue());
    }
  }

  return properties;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:DatasetBuilder.java


示例19: startAddPartition

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
private boolean startAddPartition(
        final RawStore ms, final Partition part, final boolean ifNotExists) throws MetaException, TException {
    MetaStoreUtils.validatePartitionNameCharacters(part.getValues(),
            partitionValidationPattern);
    final boolean doesExist = ms.doesPartitionExist(
            part.getDbName(), part.getTableName(), part.getValues());
    if (doesExist && !ifNotExists) {
        throw new AlreadyExistsException("Partition already exists: " + part);
    }
    return !doesExist;
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:12,代码来源:MetacatHMSHandler.java


示例20: getPartitionSchema

import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入依赖的package包/类
private static Properties getPartitionSchema(Table table, Partition partition)
{
    if (isUnpartitioned(partition)) {
        return MetaStoreUtils.getTableMetadata(table);
    }
    return MetaStoreUtils.getSchema(partition, table);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:BackgroundHiveSplitLoader.java



注:本文中的org.apache.hadoop.hive.metastore.MetaStoreUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Date类代码示例发布时间:2022-05-21
下一篇:
Java MediaList类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap