2017-03-05 4 views
0

SparkのHBase ColumnRangeFilterの使用方法を検討しています。
私はorg.apache.hadoop.hbase.mapreduce.TableInputFormatを見ていますが、このAPIにはColumnRangeFilterは含まれていません。
私はSparkでColumnRangeFilterを実行する方法がわかりません。SpaseのHBase ColumnRangeFilterの使用方法

"20170225"で始まり、 "20170305"で終わるColumnRangeFilterを使用したいとします。

コードの下にある行をスキャンします。

val conf = HBaseConfiguration.create() 
conf.set(TableInputFormat.INPUT_TABLE, "like_count") 
val startRow = "001" 
val endRow = "100" 
conf.set(TableInputFormat.SCAN_ROW_START, startRow) 
conf.set(TableInputFormat.SCAN_ROW_STOP, endRow) 
sc.newAPIHadoopRDD(conf, classOf[TableInputFormat], classOf[ImmutableBytesWritable], classOf[Result]) 

どのようなコードを追加する必要がありますか? 誰かが助言を持っているなら、plsはそれについて教えてくれます。

答えて

0

使用開始と終了行を設定し、HBaseの構成でその走査オブジェクトを設定するために、スキャン対象次いでhttps://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Scan.html

Scan scan = new Scan(startRow, endRow); 
scan.setMaxVersions(MAX_VERSIONS); 

//This can also be done if not specified in scan object constructor 
scan.setFilter(new ColumnRangeFilter(startrow,true,endrow,true)); 


HBaseConfiguration.merge(conf, HBaseConfiguration.create(conf)); 

conf.set(TableInputFormat.INPUT_TABLE, username + ":" + path); 
conf.set(TableInputFormat.SCAN, convertScanToString(scan)); 


tableInputFormat.setConf(conf); 
tableInputFormat にその構成オブジェクトを渡します
関連する問題