wscourge
wscourge

Reputation: 11301

Hbase REST API: Timerange scan

Q: How to scan Hbase for given timerange using REST API?

I tried this code:

<Scanner batch="1048576"> 
    <filter>
        { 
            "type": "PrefixFilter",
            "value": "NThiMDNjYWRlNTc5NmIwOWI0OGViMTdl", // base64 encoded "58b03cade5796b09b48eb17e"
            "timerange": ["1489502797781", "1489502797788"]
        }
    </filter>
</Scanner>

Hbase shell timerange scan is:

> scan 'tableName', { TIMERANGE => [1489442551458, 1489442551558] }

Encoding timestamps as base64 didn't work, stringifying an array and encoding it as base64 didn't work, passing integers (timestamps) instead of strings didn't work. No errors, all I get is all records I have that pass other condition I provide, which is "58b03cade5796b09b48eb17e" prefix, like it's totally ignored, so I guess it's not the right way.

Upvotes: 1

Views: 714

Answers (1)

Diego Sevilla
Diego Sevilla

Reputation: 29021

For what I see in the XSD of the REST calls, the time parameters are parameters for the scanner, not for the filter. Also, looking at the XSD, it seems that these two attributes are separated in startTime and endTime (both ints). So, you could try something like:

<Scanner batch="1048576" startTime=1489502797781, endTime=1489502797788> 
    <filter>
        { 
            "type": "PrefixFilter",
            "value": "NThiMDNjYWRlNTc5NmIwOWI0OGViMTdl", // base64 encoded "58b03cade5796b09b48eb17e"
        }
    </filter>
</Scanner>

Upvotes: 1

Related Questions