有没有办法在外部 table 中动态创建 Columnfamily?
Is there a way to create Columnfamily in external table dynamically?
我像这样创建了一个外部 Table:
CREATE External TABLE IF NOT EXISTS words (word string, timest string,
url string, occs string, nos string, hiveall string, occall string) STORED
BY org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES
('hbase.columns.mapping' =':key, count:timest, count:url, count:occs,
count:nos, other:hiveall, other:occall ')
有什么方法可以动态创建列族吗?所以我有这样的例子:
1397897857000 column=word:occall, timestamp=1449778100184, value=value1
1397897857000 column=otherword:occall, timestamp=1449778100184, value=value2
我想过这样的事情,但是来自 hive,这里的代码来自 hbase :
Configuration config = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
String table = "myTable";
admin.disableTable(table);
HColumnDescriptor cf1 = ...;
admin.addColumn(table, cf1); // adding new ColumnFamily
HColumnDescriptor cf2 = ...;
admin.modifyColumn(table, cf2); // modifying existing ColumnFamily
admin.enableTable(table);
来自这里:
http://hbase.apache.org/0.94/book/schema.html
或者有人对我的问题有其他想法:
我有来自字数统计工作的多个数据。此数据包含 url,从何处读取单词,时间戳,读取单词的时间,在 url 中找到该单词的频率以及有关类别的一些信息(有是新闻,社会和所有)与发生。主要问题是多个单词可以出现在同一个时间戳中,这将覆盖现有的单词。我需要将 rowkey 作为时间戳来对其进行一些查询(比如过去 2 周内最常用的词)。
像这样创建后不能更改列族。在您的场景中,您应该创建不同的列限定符而不是不同的列族。
修复列族并使用单词作为限定符名称。因此,当不同的单词出现在相同的时间戳时,它不会被覆盖。
我像这样创建了一个外部 Table:
CREATE External TABLE IF NOT EXISTS words (word string, timest string,
url string, occs string, nos string, hiveall string, occall string) STORED
BY org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES
('hbase.columns.mapping' =':key, count:timest, count:url, count:occs,
count:nos, other:hiveall, other:occall ')
有什么方法可以动态创建列族吗?所以我有这样的例子:
1397897857000 column=word:occall, timestamp=1449778100184, value=value1
1397897857000 column=otherword:occall, timestamp=1449778100184, value=value2
我想过这样的事情,但是来自 hive,这里的代码来自 hbase :
Configuration config = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
String table = "myTable";
admin.disableTable(table);
HColumnDescriptor cf1 = ...;
admin.addColumn(table, cf1); // adding new ColumnFamily
HColumnDescriptor cf2 = ...;
admin.modifyColumn(table, cf2); // modifying existing ColumnFamily
admin.enableTable(table);
来自这里: http://hbase.apache.org/0.94/book/schema.html
或者有人对我的问题有其他想法: 我有来自字数统计工作的多个数据。此数据包含 url,从何处读取单词,时间戳,读取单词的时间,在 url 中找到该单词的频率以及有关类别的一些信息(有是新闻,社会和所有)与发生。主要问题是多个单词可以出现在同一个时间戳中,这将覆盖现有的单词。我需要将 rowkey 作为时间戳来对其进行一些查询(比如过去 2 周内最常用的词)。
像这样创建后不能更改列族。在您的场景中,您应该创建不同的列限定符而不是不同的列族。
修复列族并使用单词作为限定符名称。因此,当不同的单词出现在相同的时间戳时,它不会被覆盖。