• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

失败使用ARGV

ruby 来源:timatchison 9次浏览

HBASE shell脚本我运行失败以下HBASE shell脚本,我想不通为什么:失败使用ARGV

import org.apache.hadoop.hbase.filter.CompareFilter 
import org.apache.hadoop.hbase.filter.SubstringComparator 
a = ARGV[0] 
myscan="'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('" + a + "'))}" + "\n" 
scan myscan 
exit 

的dcqa_event_agg行存在。当我运行命令:

hbase shell filtertest.rb 2013 

我得到以下错误:

ERROR: Unknown table 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))} 

当我直接在HBASE shell中运行该脚本,它工作正常。有任何想法吗?

我加了一些调试shell脚本:

import org.apache.hadoop.hbase.filter.CompareFilter 
import org.apache.hadoop.hbase.filter.SubstringComparator 
a = ARGV[0] 
myscan="'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('" + a + "'))}" 
print myscan + "\n" 
print "scan " + myscan + "\n" 
scan myscan 
exit 

这是输出:

[test ~]$ hbase shell filtertest.rb 2013 
13/08/23 18:08:44 WARN conf.Configuration: hadoop.native.lib is deprecated. Instead, use io.native.lib.available 
'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))} 
scan 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))} 
ERROR: Unknown table 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))}! 

卸下报价没有解决它。

如果我在运行HBase的shell环境的命令:

import org.apache.hadoop.hbase.filter.CompareFilter 
import org.apache.hadoop.hbase.filter.SubstringComparator 
scan 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('2013'))} 

我没有得到这个错误。


===========解决方案如下:

第二个参数是Hash,而不是String

import org.apache.hadoop.hbase.filter.CompareFilter 
import org.apache.hadoop.hbase.filter.SubstringComparator 
a = ARGV[0] 
scan 'dcqa_event_agg', {FILTER => org.apache.hadoop.hbase.filter.RowFilter.new(CompareFilter::CompareOp.valueOf('EQUAL'),SubstringComparator.new('#{a}'))} 
exit 

版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)