Reputation: 596
How can i pass a list of values to a SingleColumnFilter for an hbase scan and query ?
val ListOfID = List("ID1","ID2",...,"ID15",...,"ID150")
I know how to filter for one value :
val IDFilter = new SingleColumnValueFilter(Bytes.toBytes("header"), Bytes.toBytes("ID"), CompareFilter.CompareOp.EQUAL, Bytes.toBytes(String.valueOf(ID)))
But i would like to pass a list of value to the filter, because my list has more than 150 elements.
Thanks in advance
Upvotes: 1
Views: 840
Reputation: 596
Here is a solution i found, with RegexStringComparator it works, but i don't know if its the best that can be done :
val ListOfID = List("ID1","ID2",...,"ID15",...,"ID150")
val IDListString = ListOfID.mkString("|")
val scan = new Scan
val IDFilter = new SingleColumnValueFilter(Bytes.toBytes("header"), Bytes.toBytes("networkIdentifier"), CompareFilter.CompareOp.EQUAL,new RegexStringComparator(IDListString))
val filters = new FilterList(IDFilter)
scan.setFilter(filters)
Upvotes: 1