我能够将 hdfs 中的文本文件读取到 apache 处理管道中。 但现在我需要读取配置单元分区。 问题是根据我们的设计,我不应该直接访问该文件。因此,现在我需要一些方法来使用 HCatalog 之类的东西访问分区。
最佳答案
您可以使用 org.apache.hadoop.hive.metastore API 或 HCat API。下面是一个使用 hive.metastore 的简单示例。除非您想加入映射器/缩减器中的某个 Hive 分区,否则您必须在开始管道之前或之前调用。
HiveMetaStoreClient hmsc = new HiveMetaStoreClient(hiveConf)
HiveMetaStoreClient hiveClient = getHiveMetastoreConnection();
List<Partition> partitions = hiveClient.listPartittions("default", "my_hive_table", 1000)
for(Partition partition: partitions) {
System.out.println("HDFS data location of the partition: " + partition.getSd().getLocation())
}
您唯一需要的另一件事是导出配置单元 conf 目录:
export HIVE_CONF_DIR=/home/mmichalski/hive/conf
关于hadoop - 如何将配置单元分区读入 Apache Crunch 管道?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26461233/