hadoop - 如何将配置单元分区读入 Apache Crunch 管道?

标签 hadoop hive pipeline hcatalog apache-crunch

我能够将 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/

相关文章:

c - C Minishell添加管道

user-interface - Hue 安装在 vanilla hadoop 上

hadoop - 更改 Hadoop 中的数据节点数量

hadoop - Hive 外部表 - 在用包含不同记录数的新文件替换基础数据文件后没有给出正确的计数

database - Laravel 在数据库上执行计划作业

scikit-learn - Doc2Vec 的管道和网格搜索

bash - Bash脚本-列出hadoop文件

regex - 使用 REGEX 在 Hive Create 和 Load Query 中获取空值

hadoop - Windows 'File Not Found'上的hiveserver2并挂起

hive - Beeline 无法在 kerberized 集群中运行 hivescript