I write scala code to retrieve data based on its time range. Here're my code :
object Hbase_Scan_TimeRange {
def main(args: Array[String]): Unit = {
//===Basic Hbase (Non Deprecated)===Start
Logger.getLogger(this.getClass)
Logger.getLogger("org").setLevel(Level.ERROR)
BasicConfigurator.configure()
val conf = HBaseConfiguration.create()
val connection = ConnectionFactory.createConnection(conf)
val admin = connection.getAdmin()
//===Basic Hbase (Non Deprecated)===End
val scan = new Scan()
val _min = 1470387596203L
val _max = 1470387596204L
scan.setTimeRange(1470387596203L,1470387596204L)
val table = connection.getTable(TableName.valueOf("tm_movie"))
val scanner = table.getScanner(scan)
var result = scanner.next()
println()
while (result != null ) {
//===start
println(result)
}
}
}
However, it does not work.It still showing all data from tm_movie
.
I am expecting it will same as below query in Hbase Shell :
scan 'tm_movie', { TIMERANGE => [1470387596203,1470387596204] }
Any idea ?